diff options
author | Julius Härtl <jus@bitgrid.net> | 2017-05-18 10:45:42 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2017-05-18 10:45:42 +0200 |
commit | 489131333ab2db67d84baca623f3649336f417c1 (patch) | |
tree | f7677d41ba68954917608ae75aec943ee311f288 /apps/theming/tests | |
parent | edb5502b9d695f1eb12b58eac09d64d76339ec05 (diff) | |
download | nextcloud-server-489131333ab2db67d84baca623f3649336f417c1.tar.gz nextcloud-server-489131333ab2db67d84baca623f3649336f417c1.zip |
Inject FileAccessHelper for proper testing
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/theming/tests')
-rw-r--r-- | apps/theming/tests/Controller/IconControllerTest.php | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php index 0a93ce1f10d..c6a40b5942e 100644 --- a/apps/theming/tests/Controller/IconControllerTest.php +++ b/apps/theming/tests/Controller/IconControllerTest.php @@ -24,6 +24,7 @@ namespace OCA\Theming\Tests\Controller; use OC\Files\SimpleFS\SimpleFile; +use OC\IntegrityCheck\Helpers\FileAccessHelper; use OCA\Theming\IconBuilder; use OCA\Theming\ImageManager; use OCA\Theming\ThemingDefaults; @@ -54,6 +55,8 @@ class IconControllerTest extends TestCase { private $config; /** @var IconBuilder|\PHPUnit_Framework_MockObject_MockObject */ private $iconBuilder; + /** @var FileAccessHelper|\PHPUnit_Framework_MockObject_MockObject */ + private $fileAccessHelper; /** @var ImageManager */ private $imageManager; @@ -70,6 +73,7 @@ class IconControllerTest extends TestCase { $this->iconBuilder = $this->getMockBuilder('OCA\Theming\IconBuilder') ->disableOriginalConstructor()->getMock(); $this->imageManager = $this->getMockBuilder('OCA\Theming\ImageManager')->disableOriginalConstructor()->getMock(); + $this->fileAccessHelper = $this->createMock(FileAccessHelper::class); $this->timeFactory->expects($this->any()) ->method('getTime') ->willReturn(123); @@ -82,7 +86,8 @@ class IconControllerTest extends TestCase { $this->timeFactory, $this->config, $this->iconBuilder, - $this->imageManager + $this->imageManager, + $this->fileAccessHelper ); parent::setUp(); @@ -152,6 +157,10 @@ class IconControllerTest extends TestCase { ->method('shouldReplaceIcons') ->willReturn(false); $fallbackLogo = \OC::$SERVERROOT . '/core/img/favicon.png'; + $this->fileAccessHelper->expects($this->once()) + ->method('file_get_contents') + ->with($fallbackLogo) + ->willReturn(file_get_contents($fallbackLogo)); $expected = new DataDisplayResponse(file_get_contents($fallbackLogo), Http::STATUS_OK, ['Content-Type' => 'image/x-icon']); $expected->cacheFor(86400); $expires = new \DateTime(); @@ -201,6 +210,10 @@ class IconControllerTest extends TestCase { ->method('shouldReplaceIcons') ->willReturn(false); $fallbackLogo = \OC::$SERVERROOT . '/core/img/favicon-touch.png'; + $this->fileAccessHelper->expects($this->once()) + ->method('file_get_contents') + ->with($fallbackLogo) + ->willReturn(file_get_contents($fallbackLogo)); $expected = new DataDisplayResponse(file_get_contents($fallbackLogo), Http::STATUS_OK, ['Content-Type' => 'image/png']); $expected->cacheFor(86400); $expires = new \DateTime(); |