From ab14c0322b0ea8f9b7ae827b91a7170b813ec78b Mon Sep 17 00:00:00 2001 From: Jasper Knockaert Date: Tue, 5 Jan 2021 19:09:16 +0100 Subject: attemtp to fix test --- tests/lib/Files/Storage/Wrapper/EncryptionTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php index 8bdb48fd854..2a2a45e53ce 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -566,6 +566,12 @@ class EncryptionTest extends Storage { * @param string $strippedPath */ public function testGetHeader($path, $strippedPathExists, $strippedPath) { + $cache = $this->getMockBuilder('\OC\Files\Cache\Cache') + ->disableOriginalConstructor()->getMock(); + $cache->expects($this->any()) + ->method('get') + ->willReturn(['encrypted' => true]); + $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') ->disableOriginalConstructor()->getMock(); @@ -597,7 +603,7 @@ class EncryptionTest extends Storage { $this->encryptionManager, $util, $this->logger, $this->file, null, $this->keyStore, $this->update, $this->mountManager, $this->arrayCache ] ) - ->setMethods(['readFirstBlock', 'parseRawHeader']) + ->setMethods(['getCache','readFirstBlock', 'parseRawHeader']) ->getMock(); $instance->expects($this->once())->method(('parseRawHeader')) -- cgit v1.2.3 From bbf191bdef3bef110928cf24bfa3d0931002a1a4 Mon Sep 17 00:00:00 2001 From: Jasper Knockaert Date: Tue, 5 Jan 2021 20:41:02 +0100 Subject: 2nd attempt to fix tests --- tests/lib/Files/Storage/Wrapper/EncryptionTest.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php index 2a2a45e53ce..7042fd09f5e 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -566,12 +566,6 @@ class EncryptionTest extends Storage { * @param string $strippedPath */ public function testGetHeader($path, $strippedPathExists, $strippedPath) { - $cache = $this->getMockBuilder('\OC\Files\Cache\Cache') - ->disableOriginalConstructor()->getMock(); - $cache->expects($this->any()) - ->method('get') - ->willReturn(['encrypted' => true]); - $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') ->disableOriginalConstructor()->getMock(); @@ -590,6 +584,14 @@ class EncryptionTest extends Storage { $this->arrayCache ] )->getMock(); + + $cache = $this->getMockBuilder('\OC\Files\Cache\Cache') + ->disableOriginalConstructor()->getMock(); + $cache->expects($this->any()) + ->method('get') + ->willReturnCallback(function ($path) { + return ['encrypted' => true, 'path' => $path]; + }); $instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') ->setConstructorArgs( @@ -605,7 +607,9 @@ class EncryptionTest extends Storage { ) ->setMethods(['getCache','readFirstBlock', 'parseRawHeader']) ->getMock(); - + + $instance->expects($this->any())->method('getCache')->willReturn($cache); + $instance->expects($this->once())->method(('parseRawHeader')) ->willReturn([Util::HEADER_ENCRYPTION_MODULE_KEY => 'OC_DEFAULT_MODULE']); -- cgit v1.2.3 From 5341807b14d1242d6852377f70ef80b1f9325ff4 Mon Sep 17 00:00:00 2001 From: Jasper Knockaert Date: Tue, 5 Jan 2021 21:45:50 +0100 Subject: Update EncryptionTest.php --- tests/lib/Files/Storage/Wrapper/EncryptionTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php index 7042fd09f5e..a4ee5e45bd5 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -608,7 +608,7 @@ class EncryptionTest extends Storage { ->setMethods(['getCache','readFirstBlock', 'parseRawHeader']) ->getMock(); - $instance->expects($this->any())->method('getCache')->willReturn($cache); + $instance->expects($this->once())->method('getCache')->willReturn($cache); $instance->expects($this->once())->method(('parseRawHeader')) ->willReturn([Util::HEADER_ENCRYPTION_MODULE_KEY => 'OC_DEFAULT_MODULE']); @@ -687,8 +687,8 @@ class EncryptionTest extends Storage { ->setMethods(['readFirstBlock', 'parseRawHeader', 'getCache']) ->getMock(); - $instance->expects($this->once())->method(('parseRawHeader'))->willReturn($header); - $instance->expects($this->any())->method('getCache')->willReturn($cache); + $instance->expects($this->any())->method(('parseRawHeader'))->willReturn($header); + $instance->expects($this->once())->method('getCache')->willReturn($cache); $result = $this->invokePrivate($instance, 'getHeader', ['test.txt']); $this->assertSameSize($expected, $result); -- cgit v1.2.3