diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-07-18 12:34:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-18 12:34:11 +0200 |
commit | 6c3c7a5e4da693f91fa4abf7f2495ff479ad42a0 (patch) | |
tree | cd3fe8c71fad7334f0fe716cb099950d6f2ebd94 /tests | |
parent | 929aaaa129519e554f56b19815d0e2ff0f41cd2b (diff) | |
parent | 19a36b58a69f9a8cc31da213657fdf828d9fdb3c (diff) | |
download | nextcloud-server-6c3c7a5e4da693f91fa4abf7f2495ff479ad42a0.tar.gz nextcloud-server-6c3c7a5e4da693f91fa4abf7f2495ff479ad42a0.zip |
Merge pull request #32981 from nextcloud/typing/carl/simplefs
Add typing to SimpleFS
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Avatar/UserAvatarTest.php | 11 | ||||
-rw-r--r-- | tests/lib/Preview/GeneratorTest.php | 8 |
2 files changed, 15 insertions, 4 deletions
diff --git a/tests/lib/Avatar/UserAvatarTest.php b/tests/lib/Avatar/UserAvatarTest.php index b2b4ebba343..9a81f0bcd35 100644 --- a/tests/lib/Avatar/UserAvatarTest.php +++ b/tests/lib/Avatar/UserAvatarTest.php @@ -11,7 +11,6 @@ namespace Test\Avatar; use OC\Files\SimpleFS\SimpleFolder; use OC\User\User; use OCP\Files\File; -use OCP\Files\Folder; use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFile; use OCP\IConfig; @@ -19,7 +18,7 @@ use OCP\IL10N; use Psr\Log\LoggerInterface; class UserAvatarTest extends \Test\TestCase { - /** @var Folder | \PHPUnit\Framework\MockObject\MockObject */ + /** @var SimpleFolder | \PHPUnit\Framework\MockObject\MockObject */ private $folder; /** @var \OC\Avatar\UserAvatar */ @@ -91,6 +90,7 @@ class UserAvatarTest extends \Test\TestCase { ->willReturnMap([ ['avatar.jpg', true], ['avatar.128.jpg', true], + ['generated', false], ]); $expected = new \OC_Image(); @@ -107,6 +107,7 @@ class UserAvatarTest extends \Test\TestCase { $this->folder->method('fileExists') ->willReturnMap([ ['avatar.jpg', true], + ['generated', false], ]); $expected = new \OC_Image(); @@ -122,8 +123,10 @@ class UserAvatarTest extends \Test\TestCase { public function testGetAvatarNoSizeMatch() { $this->folder->method('fileExists') ->willReturnMap([ + ['avatar.jpg', false], ['avatar.png', true], ['avatar.32.png', false], + ['generated', false], ]); $expected = new \OC_Image(); @@ -202,12 +205,12 @@ class UserAvatarTest extends \Test\TestCase { $this->folder->method('getDirectoryListing') ->willReturn([$avatarFileJPG, $avatarFilePNG, $resizedAvatarFile]); - $generated = $this->createMock(File::class); + $generated = $this->createMock(ISimpleFile::class); $this->folder->method('getFile') ->with('generated') ->willReturn($generated); - $newFile = $this->createMock(File::class); + $newFile = $this->createMock(ISimpleFile::class); $this->folder->expects($this->once()) ->method('newFile') ->with('avatar.png') diff --git a/tests/lib/Preview/GeneratorTest.php b/tests/lib/Preview/GeneratorTest.php index 43f5c1e0d36..1e38afd7744 100644 --- a/tests/lib/Preview/GeneratorTest.php +++ b/tests/lib/Preview/GeneratorTest.php @@ -95,6 +95,7 @@ class GeneratorTest extends \Test\TestCase { $maxPreview = $this->createMock(ISimpleFile::class); $maxPreview->method('getName') ->willReturn('1000-1000-max.png'); + $maxPreview->method('getSize')->willReturn(1000); $maxPreview->method('getMimeType') ->willReturn('image/png'); @@ -102,6 +103,7 @@ class GeneratorTest extends \Test\TestCase { ->willReturn([$maxPreview]); $previewFile = $this->createMock(ISimpleFile::class); + $previewFile->method('getSize')->willReturn(1000); $previewFolder->method('getFile') ->with($this->equalTo('256-256.png')) @@ -203,8 +205,10 @@ class GeneratorTest extends \Test\TestCase { $maxPreview = $this->createMock(ISimpleFile::class); $maxPreview->method('getName')->willReturn('2048-2048-max.png'); $maxPreview->method('getMimeType')->willReturn('image/png'); + $maxPreview->method('getSize')->willReturn(1000); $previewFile = $this->createMock(ISimpleFile::class); + $previewFile->method('getSize')->willReturn(1000); $previewFolder->method('getDirectoryListing') ->willReturn([]); @@ -313,6 +317,7 @@ class GeneratorTest extends \Test\TestCase { $maxPreview = $this->createMock(ISimpleFile::class); $maxPreview->method('getName') ->willReturn('2048-2048-max.png'); + $maxPreview->method('getSize')->willReturn(1000); $maxPreview->method('getMimeType') ->willReturn('image/png'); @@ -320,6 +325,7 @@ class GeneratorTest extends \Test\TestCase { ->willReturn([$maxPreview]); $preview = $this->createMock(ISimpleFile::class); + $preview->method('getSize')->willReturn(1000); $previewFolder->method('getFile') ->with($this->equalTo('1024-512-crop.png')) ->willReturn($preview); @@ -471,6 +477,7 @@ class GeneratorTest extends \Test\TestCase { ->willReturn($maxX . '-' . $maxY . '-max.png'); $maxPreview->method('getMimeType') ->willReturn('image/png'); + $maxPreview->method('getSize')->willReturn(1000); $previewFolder->method('getDirectoryListing') ->willReturn([$maxPreview]); @@ -490,6 +497,7 @@ class GeneratorTest extends \Test\TestCase { ->willReturn($image); $preview = $this->createMock(ISimpleFile::class); + $preview->method('getSize')->willReturn(1000); $previewFolder->method('newFile') ->with($this->equalTo($filename)) ->willReturn($preview); |