mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
test: Put input files in user storage
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
a8afa7f23d
commit
9cc1a01ea0
1 changed files with 10 additions and 11 deletions
|
|
@ -24,6 +24,7 @@ use OCP\Files\IRootFolder;
|
|||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IServerContainer;
|
||||
use OCP\IUserManager;
|
||||
use OCP\SpeechToText\ISpeechToTextManager;
|
||||
use OCP\TaskProcessing\EShapeType;
|
||||
use OCP\TaskProcessing\Events\TaskFailedEvent;
|
||||
|
|
@ -301,6 +302,8 @@ class TaskProcessingTest extends \Test\TestCase {
|
|||
private \OCP\Share\IManager $shareManager;
|
||||
private IRootFolder $rootFolder;
|
||||
|
||||
const TEST_USER = 'testuser';
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
|
|
@ -316,6 +319,11 @@ class TaskProcessingTest extends \Test\TestCase {
|
|||
FailingTextToImageProvider::class => new FailingTextToImageProvider(),
|
||||
];
|
||||
|
||||
$userManager = \OCP\Server::get(IUserManager::class);
|
||||
if (!$userManager->userExists(self::TEST_USER)) {
|
||||
$userManager->createUser(self::TEST_USER, 'test');
|
||||
}
|
||||
|
||||
$this->serverContainer = $this->createMock(IServerContainer::class);
|
||||
$this->serverContainer->expects($this->any())->method('get')->willReturnCallback(function ($class) {
|
||||
return $this->providers[$class];
|
||||
|
|
@ -384,18 +392,9 @@ class TaskProcessingTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
private function getFile(string $name, string $content): \OCP\Files\File {
|
||||
$this->appData = \OC::$server->get(IAppDataFactory::class)->get('core');
|
||||
try {
|
||||
$folder = $this->appData->getFolder('test');
|
||||
} catch (\OCP\Files\NotFoundException $e) {
|
||||
$folder = $this->appData->newFolder('test');
|
||||
}
|
||||
$folder = $this->rootFolder->getUserFolder(self::TEST_USER);
|
||||
$file = $folder->newFile($name, $content);
|
||||
$inputFile = current($this->rootFolder->getByIdInPath($file->getId(), '/' . $this->rootFolder->getAppDataDirectoryName() . '/'));
|
||||
if (!$inputFile instanceof \OCP\Files\File) {
|
||||
throw new \Exception('PEBCAK');
|
||||
}
|
||||
return $inputFile;
|
||||
return $file;
|
||||
}
|
||||
|
||||
public function testShouldNotHaveAnyProviders() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue