diff options
author | Joas Schilling <coding@schilljs.com> | 2016-07-28 16:07:23 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2016-07-28 17:49:08 +0200 |
commit | 5306b4feba0e1650d185f604df8390bcca44e660 (patch) | |
tree | 2aa3cf1b06ecd6757bbc17a8f17ec58934657579 /apps/theming/tests | |
parent | 2de41121766a5d3b31cd61653fce8e107f42f22d (diff) | |
download | nextcloud-server-5306b4feba0e1650d185f604df8390bcca44e660.tar.gz nextcloud-server-5306b4feba0e1650d185f604df8390bcca44e660.zip |
Fix tests
Diffstat (limited to 'apps/theming/tests')
-rw-r--r-- | apps/theming/tests/Controller/ThemingControllerTest.php | 30 | ||||
-rw-r--r-- | apps/theming/tests/UtilTest.php | 32 |
2 files changed, 46 insertions, 16 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index 0cbf125d8fd..933faf8a0a1 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -42,6 +42,10 @@ class ThemingControllerTest extends TestCase { private $config; /** @var Template */ private $template; + /** @var Util */ + private $util; + /** @var \OCP\AppFramework\Utility\ITimeFactory */ + private $timeFactory; /** @var IL10N */ private $l10n; /** @var ThemingController */ @@ -54,14 +58,24 @@ class ThemingControllerTest extends TestCase { $this->config = $this->getMock('\\OCP\\IConfig'); $this->template = $this->getMockBuilder('\\OCA\\Theming\\Template') ->disableOriginalConstructor()->getMock(); + $this->util = new Util(); + $this->timeFactory = $this->getMockBuilder('OCP\AppFramework\Utility\ITimeFactory') + ->disableOriginalConstructor() + ->getMock(); $this->l10n = $this->getMock('\\OCP\\IL10N'); $this->rootFolder = $this->getMock('\\OCP\\Files\\IRootFolder'); + $this->timeFactory->expects($this->any()) + ->method('getTime') + ->willReturn(123); + $this->themingController = new ThemingController( 'theming', $this->request, $this->config, $this->template, + $this->util, + $this->timeFactory, $this->l10n, $this->rootFolder ); @@ -273,6 +287,7 @@ class ThemingControllerTest extends TestCase { @$expected = new Http\StreamResponse($tmpLogo); $expected->cacheFor(3600); + $expected->addHeader('Expires', date(\DateTime::RFC2822, 123)); $expected->addHeader('Content-Disposition', 'attachment'); $expected->addHeader('Content-Type', 'text/svg'); @$this->assertEquals($expected, $this->themingController->getLogo()); @@ -301,6 +316,7 @@ class ThemingControllerTest extends TestCase { @$expected = new Http\StreamResponse($tmpLogo); $expected->cacheFor(3600); + $expected->addHeader('Expires', date(\DateTime::RFC2822, 123)); $expected->addHeader('Content-Disposition', 'attachment'); $expected->addHeader('Content-Type', 'image/png'); @$this->assertEquals($expected, $this->themingController->getLoginBackground()); @@ -344,7 +360,7 @@ class ThemingControllerTest extends TestCase { $color ); $expectedData .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' . - 'background-image: url(\'data:image/svg+xml;base64,'.Util::generateRadioButton($color).'\');' . + 'background-image: url(\'data:image/svg+xml;base64,'.$this->util->generateRadioButton($color).'\');' . "}\n"; $expectedData .= ' @@ -359,6 +375,7 @@ class ThemingControllerTest extends TestCase { $expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css'); $expected->cacheFor(3600); + $expected->addHeader('Expires', date(\DateTime::RFC2822, 123)); @$this->assertEquals($expected, $this->themingController->getStylesheet()); } @@ -399,7 +416,7 @@ class ThemingControllerTest extends TestCase { \OC::$WEBROOT ); $expectedData .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' . - 'background-image: url(\'data:image/svg+xml;base64,'.Util::generateRadioButton('#555555').'\');' . + 'background-image: url(\'data:image/svg+xml;base64,'.$this->util->generateRadioButton('#555555').'\');' . "}\n"; $expectedData .= ' @@ -419,6 +436,7 @@ class ThemingControllerTest extends TestCase { $expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css'); $expected->cacheFor(3600); + $expected->addHeader('Expires', date(\DateTime::RFC2822, 123)); @$this->assertEquals($expected, $this->themingController->getStylesheet()); } @@ -460,6 +478,7 @@ class ThemingControllerTest extends TestCase { $expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css'); $expected->cacheFor(3600); + $expected->addHeader('Expires', date(\DateTime::RFC2822, 123)); @$this->assertEquals($expected, $this->themingController->getStylesheet()); } @@ -493,6 +512,7 @@ class ThemingControllerTest extends TestCase { $expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css'); $expected->cacheFor(3600); + $expected->addHeader('Expires', date(\DateTime::RFC2822, 123)); @$this->assertEquals($expected, $this->themingController->getStylesheet()); } @@ -534,7 +554,7 @@ class ThemingControllerTest extends TestCase { $color ); $expectedData .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' . - 'background-image: url(\'data:image/svg+xml;base64,'.Util::generateRadioButton($color).'\');' . + 'background-image: url(\'data:image/svg+xml;base64,'.$this->util->generateRadioButton($color).'\');' . "}\n"; $expectedData .= ' #firstrunwizard .firstrunwizard-header { @@ -565,6 +585,7 @@ class ThemingControllerTest extends TestCase { $expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css'); $expected->cacheFor(3600); + $expected->addHeader('Expires', date(\DateTime::RFC2822, 123)); @$this->assertEquals($expected, $this->themingController->getStylesheet()); } @@ -606,7 +627,7 @@ class ThemingControllerTest extends TestCase { \OC::$WEBROOT ); $expectedData .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' . - 'background-image: url(\'data:image/svg+xml;base64,'.Util::generateRadioButton('#555555').'\');' . + 'background-image: url(\'data:image/svg+xml;base64,'.$this->util->generateRadioButton('#555555').'\');' . "}\n"; $expectedData .= ' #firstrunwizard .firstrunwizard-header { @@ -641,6 +662,7 @@ class ThemingControllerTest extends TestCase { $expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css'); $expected->cacheFor(3600); + $expected->addHeader('Expires', date(\DateTime::RFC2822, 123)); @$this->assertEquals($expected, $this->themingController->getStylesheet()); } diff --git a/apps/theming/tests/UtilTest.php b/apps/theming/tests/UtilTest.php index cf64b389d11..c7fc385d25d 100644 --- a/apps/theming/tests/UtilTest.php +++ b/apps/theming/tests/UtilTest.php @@ -27,62 +27,70 @@ use Test\TestCase; class UtilTest extends TestCase { + /** @var Util */ + protected $util; + + protected function setUp() { + parent::setUp(); + $this->util = new Util(); + } + public function testInvertTextColorLight() { - $invert = Util::invertTextColor('#ffffff'); + $invert = $this->util->invertTextColor('#ffffff'); $this->assertEquals(true, $invert); } public function testInvertTextColorDark() { - $invert = Util::invertTextColor('#000000'); + $invert = $this->util->invertTextColor('#000000'); $this->assertEquals(false, $invert); } public function testCalculateLuminanceLight() { - $luminance = Util::calculateLuminance('#ffffff'); + $luminance = $this->util->calculateLuminance('#ffffff'); $this->assertEquals(1, $luminance); } public function testCalculateLuminanceDark() { - $luminance = Util::calculateLuminance('#000000'); + $luminance = $this->util->calculateLuminance('#000000'); $this->assertEquals(0, $luminance); } public function testCalculateLuminanceLightShorthand() { - $luminance = Util::calculateLuminance('#fff'); + $luminance = $this->util->calculateLuminance('#fff'); $this->assertEquals(1, $luminance); } public function testCalculateLuminanceDarkShorthand() { - $luminance = Util::calculateLuminance('#000'); + $luminance = $this->util->calculateLuminance('#000'); $this->assertEquals(0, $luminance); } public function testInvertTextColorInvalid() { - $invert = Util::invertTextColor('aaabbbcccddd123'); + $invert = $this->util->invertTextColor('aaabbbcccddd123'); $this->assertEquals(false, $invert); } public function testInvertTextColorEmpty() { - $invert = Util::invertTextColor(''); + $invert = $this->util->invertTextColor(''); $this->assertEquals(false, $invert); } public function testElementColorDefault() { - $elementColor = Util::elementColor("#000000"); + $elementColor = $this->util->elementColor("#000000"); $this->assertEquals('#000000', $elementColor); } public function testElementColorOnBrightBackground() { - $elementColor = Util::elementColor('#ffffff'); + $elementColor = $this->util->elementColor('#ffffff'); $this->assertEquals('#555555', $elementColor); } public function testGenerateRadioButtonWhite() { - $button = Util::generateRadioButton('#ffffff'); + $button = $this->util->generateRadioButton('#ffffff'); $expected = 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTYiIHdpZHRoPSIxNiI+PHBhdGggZD0iTTggMWE3IDcgMCAwIDAtNyA3IDcgNyAwIDAgMCA3IDcgNyA3IDAgMCAwIDctNyA3IDcgMCAwIDAtNy03em0wIDFhNiA2IDAgMCAxIDYgNiA2IDYgMCAwIDEtNiA2IDYgNiAwIDAgMS02LTYgNiA2IDAgMCAxIDYtNnptMCAyYTQgNCAwIDEgMCAwIDggNCA0IDAgMCAwIDAtOHoiIGZpbGw9IiNmZmZmZmYiLz48L3N2Zz4='; $this->assertEquals($expected, $button); } public function testGenerateRadioButtonBlack() { - $button = Util::generateRadioButton('#000000'); + $button = $this->util->generateRadioButton('#000000'); $expected = 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTYiIHdpZHRoPSIxNiI+PHBhdGggZD0iTTggMWE3IDcgMCAwIDAtNyA3IDcgNyAwIDAgMCA3IDcgNyA3IDAgMCAwIDctNyA3IDcgMCAwIDAtNy03em0wIDFhNiA2IDAgMCAxIDYgNiA2IDYgMCAwIDEtNiA2IDYgNiAwIDAgMS02LTYgNiA2IDAgMCAxIDYtNnptMCAyYTQgNCAwIDEgMCAwIDggNCA0IDAgMCAwIDAtOHoiIGZpbGw9IiMwMDAwMDAiLz48L3N2Zz4='; $this->assertEquals($expected, $button); } |