From 21233b7e17a6966b3cd2088749c837e1b642aaac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 26 Nov 2024 11:07:40 +0100 Subject: [PATCH] fix(tests): Remove Encryption disabling in ViewTest to avoid side effects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adapt tests a bit to make them pass with Encryption wrapper registered Signed-off-by: Côme Chilliet --- tests/lib/Files/ViewTest.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index a0723dce6ca..0b67826b603 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -111,12 +111,6 @@ class ViewTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); \OC_Hook::clear(); - /* Disable encryption, this is not what we want to test */ - $encryptionManager = Server::get(\OCP\Encryption\IManager::class); - $encryptionModules = $encryptionManager->getEncryptionModules(); - foreach (array_keys($encryptionModules) as $encryptionModuleId) { - $encryptionManager->unregisterEncryptionModule($encryptionModuleId); - } Server::get(IUserManager::class)->clearBackends(); Server::get(IUserManager::class)->registerBackend(new \Test\Util\User\Dummy()); @@ -524,10 +518,10 @@ class ViewTest extends \Test\TestCase { } public function moveBetweenStorages($storage1, $storage2) { - Filesystem::mount($storage1, [], '/'); - Filesystem::mount($storage2, [], '/substorage'); + Filesystem::mount($storage1, [], '/' . $this->user . '/'); + Filesystem::mount($storage2, [], '/' . $this->user . '/substorage'); - $rootView = new View(''); + $rootView = new View('/' . $this->user); $rootView->rename('foo.txt', 'substorage/folder/foo.txt'); $this->assertFalse($rootView->file_exists('foo.txt')); $this->assertTrue($rootView->file_exists('substorage/folder/foo.txt')); @@ -947,14 +941,16 @@ class ViewTest extends \Test\TestCase { $storage = new Temporary([]); $scanner = $storage->getScanner(); Filesystem::mount($storage, [], '/test/'); - $storage->file_put_contents('test.part', 'foobar'); + $sizeWritten = $storage->file_put_contents('test.part', 'foobar'); $scanner->scan(''); $view = new View('/test'); $info = $view->getFileInfo('test.part'); $this->assertInstanceOf('\OCP\Files\FileInfo', $info); $this->assertNull($info->getId()); + $this->assertEquals(6, $sizeWritten); $this->assertEquals(6, $info->getSize()); + $this->assertEquals('foobar', $view->file_get_contents('test.part')); } public static function absolutePathProvider(): array {