diff options
author | Marcel Klehr <mklehr@gmx.net> | 2024-05-10 07:18:14 +0200 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2024-05-14 11:38:42 +0200 |
commit | 9cc1a01ea0847b65ab8d2c90a1dd9582d6048058 (patch) | |
tree | bdac566d07c1311cc8871d6c8b45f4047d39ef68 /tests/lib | |
parent | a8afa7f23d8bf0c1fdb1725669ff9d8d6b5ebebb (diff) | |
download | nextcloud-server-9cc1a01ea0847b65ab8d2c90a1dd9582d6048058.tar.gz nextcloud-server-9cc1a01ea0847b65ab8d2c90a1dd9582d6048058.zip |
test: Put input files in user storage
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/TaskProcessing/TaskProcessingTest.php | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/tests/lib/TaskProcessing/TaskProcessingTest.php b/tests/lib/TaskProcessing/TaskProcessingTest.php index ac220ad7c63..bc4da99cbd9 100644 --- a/tests/lib/TaskProcessing/TaskProcessingTest.php +++ b/tests/lib/TaskProcessing/TaskProcessingTest.php @@ -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() { |