diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-11-08 19:46:09 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2016-11-16 15:30:37 +0100 |
commit | 07acd34d6e92e82becb8f5d364f7aad72d8ee219 (patch) | |
tree | 4387df498c804eeb002ba9613bc63fe01f2c7302 /apps/theming | |
parent | c22776f04abc5133227b8b34171c36086f955da5 (diff) | |
download | nextcloud-server-07acd34d6e92e82becb8f5d364f7aad72d8ee219.tar.gz nextcloud-server-07acd34d6e92e82becb8f5d364f7aad72d8ee219.zip |
Fix themeing unit tests
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/theming')
-rw-r--r-- | apps/theming/tests/Controller/ThemingControllerTest.php | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index 4325e1988b2..ff46ed40d82 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -28,7 +28,9 @@ use OCA\Theming\Controller\ThemingController; use OCA\Theming\Util; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; +use OCP\Files\File; use OCP\Files\IRootFolder; +use OCP\Files\NotFoundException; use OCP\IConfig; use OCP\IL10N; use OCP\IRequest; @@ -338,26 +340,30 @@ class ThemingControllerTest extends TestCase { } public function testGetLogoNotExistent() { - $expected = new DataResponse(); + $this->rootFolder->method('get') + ->with($this->equalTo('themedinstancelogo')) + ->willThrowException(new NotFoundException()); + + $expected = new Http\NotFoundResponse(); $this->assertEquals($expected, $this->themingController->getLogo()); } public function testGetLogo() { - $dataFolder = \OC::$server->getTempManager()->getTemporaryFolder(); - $tmpLogo = $dataFolder . '/themedinstancelogo'; - touch($tmpLogo); - $this->config - ->expects($this->once()) - ->method('getSystemValue') - ->with('datadirectory', \OC::$SERVERROOT . '/data/') - ->willReturn($dataFolder); + $file = $this->createMock(File::class); + $this->rootFolder->method('get') + ->with('themedinstancelogo') + ->willReturn($file); + $file->method('fopen') + ->with('r') + ->willReturn('mypath'); + $this->config ->expects($this->once()) ->method('getAppValue') ->with('theming', 'logoMime', '') ->willReturn('text/svg'); - @$expected = new Http\StreamResponse($tmpLogo); + @$expected = new Http\StreamResponse('mypath'); $expected->cacheFor(3600); $expected->addHeader('Expires', date(\DateTime::RFC2822, 123)); $expected->addHeader('Content-Disposition', 'attachment'); @@ -368,26 +374,29 @@ class ThemingControllerTest extends TestCase { public function testGetLoginBackgroundNotExistent() { - $expected = new DataResponse(); + $this->rootFolder->method('get') + ->with('themedbackgroundlogo') + ->willThrowException(new NotFoundException()); + $expected = new Http\NotFoundResponse(); $this->assertEquals($expected, $this->themingController->getLoginBackground()); } public function testGetLoginBackground() { - $dataFolder = \OC::$server->getTempManager()->getTemporaryFolder(); - $tmpLogo = $dataFolder . '/themedbackgroundlogo'; - touch($tmpLogo); - $this->config - ->expects($this->once()) - ->method('getSystemValue') - ->with('datadirectory', \OC::$SERVERROOT . '/data/') - ->willReturn($dataFolder); + $file = $this->createMock(File::class); + $this->rootFolder->method('get') + ->with('themedbackgroundlogo') + ->willReturn($file); + $file->method('fopen') + ->with('r') + ->willReturn('mypath'); + $this->config ->expects($this->once()) ->method('getAppValue') ->with('theming', 'backgroundMime', '') ->willReturn('image/png'); - @$expected = new Http\StreamResponse($tmpLogo); + @$expected = new Http\StreamResponse('mypath'); $expected->cacheFor(3600); $expected->addHeader('Expires', date(\DateTime::RFC2822, 123)); $expected->addHeader('Content-Disposition', 'attachment'); |