diff --git a/apps/theming/appinfo/app.php b/apps/theming/appinfo/app.php index 76580879ca112..5ef506e5acd26 100644 --- a/apps/theming/appinfo/app.php +++ b/apps/theming/appinfo/app.php @@ -31,7 +31,7 @@ 'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'), ] ); -\OC_Util::addHeader( +\OCP\Util::addHeader( 'link', [ 'rel' => 'stylesheet', diff --git a/apps/theming/appinfo/routes.php b/apps/theming/appinfo/routes.php index 073dacb789c71..e062a68d69df8 100644 --- a/apps/theming/appinfo/routes.php +++ b/apps/theming/appinfo/routes.php @@ -24,9 +24,7 @@ * */ -namespace OCA\Theming\AppInfo; - -(new \OCP\AppFramework\App('theming'))->registerRoutes($this, array('routes' => array( +return ['routes' => [ [ 'name' => 'Theming#updateStylesheet', 'url' => '/ajax/updateStylesheet', @@ -57,5 +55,5 @@ 'url' => '/loginbackground', 'verb' => 'GET', ], -))); +]]; diff --git a/apps/theming/lib/controller/themingcontroller.php b/apps/theming/lib/Controller/ThemingController.php similarity index 79% rename from apps/theming/lib/controller/themingcontroller.php rename to apps/theming/lib/Controller/ThemingController.php index 6f8af0bb78c55..8d9869b84a7c6 100644 --- a/apps/theming/lib/controller/themingcontroller.php +++ b/apps/theming/lib/Controller/ThemingController.php @@ -30,7 +30,10 @@ use OCA\Theming\Template; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\DataDownloadResponse; use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\Http\StreamResponse; +use OCP\AppFramework\Utility\ITimeFactory; use OCP\Files\IRootFolder; use OCP\IConfig; use OCP\IL10N; @@ -47,6 +50,10 @@ class ThemingController extends Controller { /** @var Template */ private $template; + /** @var Util */ + private $util; + /** @var ITimeFactory */ + private $timeFactory; /** @var IL10N */ private $l; /** @var IConfig */ @@ -61,6 +68,8 @@ class ThemingController extends Controller { * @param IRequest $request * @param IConfig $config * @param Template $template + * @param Util $util + * @param ITimeFactory $timeFactory * @param IL10N $l * @param IRootFolder $rootFolder */ @@ -69,12 +78,16 @@ public function __construct( IRequest $request, IConfig $config, Template $template, + Util $util, + ITimeFactory $timeFactory, IL10N $l, IRootFolder $rootFolder ) { parent::__construct($appName, $request); $this->template = $template; + $this->util = $util; + $this->timeFactory = $timeFactory; $this->l = $l; $this->config = $config; $this->rootFolder = $rootFolder; @@ -87,6 +100,50 @@ public function __construct( * @internal param string $color */ public function updateStylesheet($setting, $value) { + $value = trim($value); + switch ($setting) { + case 'name': + if (strlen($value) > 250) { + return new DataResponse([ + 'data' => [ + 'message' => $this->l->t('The given name is too long'), + ], + 'status' => 'error' + ]); + } + break; + case 'url': + if (strlen($value) > 500) { + return new DataResponse([ + 'data' => [ + 'message' => $this->l->t('The given web address is too long'), + ], + 'status' => 'error' + ]); + } + break; + case 'slogan': + if (strlen($value) > 500) { + return new DataResponse([ + 'data' => [ + 'message' => $this->l->t('The given slogan is too long'), + ], + 'status' => 'error' + ]); + } + break; + case 'color': + if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) { + return new DataResponse([ + 'data' => [ + 'message' => $this->l->t('The given color is invalid'), + ], + 'status' => 'error' + ]); + } + break; + } + $this->template->set($setting, $value); return new DataResponse( [ @@ -166,7 +223,7 @@ public function undo($setting) { * @PublicPage * @NoCSRFRequired * - * @return Http\StreamResponse + * @return StreamResponse|DataResponse */ public function getLogo() { $pathToLogo = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/') . '/themedinstancelogo'; @@ -174,10 +231,9 @@ public function getLogo() { return new DataResponse(); } - \OC_Response::setExpiresHeader(gmdate('D, d M Y H:i:s', time() + (60*60*24*45)) . ' GMT'); - \OC_Response::enableCaching(); $response = new Http\StreamResponse($pathToLogo); $response->cacheFor(3600); + $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime())); $response->addHeader('Content-Disposition', 'attachment'); $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', '')); return $response; @@ -187,7 +243,7 @@ public function getLogo() { * @PublicPage * @NoCSRFRequired * - * @return Http\StreamResponse + * @return StreamResponse|DataResponse */ public function getLoginBackground() { $pathToLogo = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/') . '/themedbackgroundlogo'; @@ -195,10 +251,9 @@ public function getLoginBackground() { return new DataResponse(); } - \OC_Response::setExpiresHeader(gmdate('D, d M Y H:i:s', time() + (60*60*24*45)) . ' GMT'); - \OC_Response::enableCaching(); - $response = new Http\StreamResponse($pathToLogo); + $response = new StreamResponse($pathToLogo); $response->cacheFor(3600); + $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime())); $response->addHeader('Content-Disposition', 'attachment'); $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', '')); return $response; @@ -208,13 +263,13 @@ public function getLoginBackground() { * @NoCSRFRequired * @PublicPage * - * @return Http\DataDownloadResponse + * @return DataDownloadResponse */ public function getStylesheet() { $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); $responseCss = ''; $color = $this->config->getAppValue($this->appName, 'color'); - $elementColor = Util::elementColor($color); + $elementColor = $this->util->elementColor($color); if($color !== '') { $responseCss .= sprintf( '#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: %s}' . "\n", @@ -229,7 +284,7 @@ public function getStylesheet() { $elementColor ); $responseCss .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' . - 'background-image: url(\'data:image/svg+xml;base64,'.Util::generateRadioButton($elementColor).'\');' . + 'background-image: url(\'data:image/svg+xml;base64,'.$this->util->generateRadioButton($elementColor).'\');' . "}\n"; $responseCss .= ' #firstrunwizard .firstrunwizard-header { @@ -265,16 +320,15 @@ public function getStylesheet() { 'background-image: url(\'./loginbackground?v='.$cacheBusterValue.'\');' . '}' . "\n"; } - if(Util::invertTextColor($color)) { + if($this->util->invertTextColor($color)) { $responseCss .= '#header .header-appname, #expandDisplayName { color: #000000; }' . "\n"; $responseCss .= '#header .icon-caret { background-image: url(\'' . \OC::$WEBROOT . '/core/img/actions/caret-dark.svg\'); }' . "\n"; $responseCss .= '.searchbox input[type="search"] { background: transparent url(\'' . \OC::$WEBROOT . '/core/img/actions/search.svg\') no-repeat 6px center; color: #000; }' . "\n"; $responseCss .= '.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid { color: #000; border: 1px solid rgba(0, 0, 0, .5); }' . "\n"; } - \OC_Response::setExpiresHeader(gmdate('D, d M Y H:i:s', time() + (60*60*24*45)) . ' GMT'); - \OC_Response::enableCaching(); - $response = new Http\DataDownloadResponse($responseCss, 'style', 'text/css'); + $response = new DataDownloadResponse($responseCss, 'style', 'text/css'); + $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime())); $response->cacheFor(3600); return $response; } diff --git a/apps/theming/lib/template.php b/apps/theming/lib/Template.php similarity index 99% rename from apps/theming/lib/template.php rename to apps/theming/lib/Template.php index 8cd2befc1d112..25730aad95b14 100644 --- a/apps/theming/lib/template.php +++ b/apps/theming/lib/Template.php @@ -40,7 +40,7 @@ class Template extends \OC_Defaults { /** @var IConfig */ private $config; - /** @var IL10N */ + /** @var IL10N */ private $l; /** @var IURLGenerator */ private $urlGenerator; diff --git a/apps/theming/lib/util.php b/apps/theming/lib/Util.php similarity index 87% rename from apps/theming/lib/util.php rename to apps/theming/lib/Util.php index f0ce30ac5ba7d..71ed0958e42a9 100644 --- a/apps/theming/lib/util.php +++ b/apps/theming/lib/Util.php @@ -29,8 +29,8 @@ class Util { * @param string $color rgb color value * @return bool */ - public static function invertTextColor($color) { - $l = self::calculateLuminance($color); + public function invertTextColor($color) { + $l = $this->calculateLuminance($color); if($l>0.5) { return true; } else { @@ -44,8 +44,8 @@ public static function invertTextColor($color) { * @param $color * @return string */ - public static function elementColor($color) { - $l = self::calculateLuminance($color); + public function elementColor($color) { + $l = $this->calculateLuminance($color); if($l>0.8) { return '#555555'; } else { @@ -57,7 +57,7 @@ public static function elementColor($color) { * @param string $color rgb color value * @return float */ - public static function calculateLuminance($color) { + public function calculateLuminance($color) { $hex = preg_replace("/[^0-9A-Fa-f]/", '', $color); if (strlen($hex) === 3) { $hex = $hex{0} . $hex{0} . $hex{1} . $hex{1} . $hex{2} . $hex{2}; @@ -75,7 +75,7 @@ public static function calculateLuminance($color) { * @param $color * @return string base64 encoded radio button svg */ - public static function generateRadioButton($color) { + public function generateRadioButton($color) { $radioButtonIcon = '' . ''; return base64_encode($radioButtonIcon); diff --git a/apps/theming/settings/settings-admin.php b/apps/theming/settings/settings-admin.php index d9aa05cfca064..8ef499789e899 100644 --- a/apps/theming/settings/settings-admin.php +++ b/apps/theming/settings/settings-admin.php @@ -23,8 +23,6 @@ * */ -\OC_Util::checkAdminUser(); - $config = \OC::$server->getConfig(); $l = \OC::$server->getL10N('theming'); $urlGenerator = \OC::$server->getURLGenerator(); @@ -40,7 +38,7 @@ $errorMessage = $l->t('You already use a custom theme'); } -$template = new OCP\Template('theming', 'settings-admin'); +$template = new \OCP\Template('theming', 'settings-admin'); $template->assign('themable', $themable); $template->assign('errorMessage', $errorMessage); diff --git a/apps/theming/templates/settings-admin.php b/apps/theming/templates/settings-admin.php index 27cdd8b60a3d4..3589812070e07 100644 --- a/apps/theming/templates/settings-admin.php +++ b/apps/theming/templates/settings-admin.php @@ -15,25 +15,25 @@

diff --git a/apps/theming/tests/lib/controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php similarity index 85% rename from apps/theming/tests/lib/controller/ThemingControllerTest.php rename to apps/theming/tests/Controller/ThemingControllerTest.php index c9b55001f8c22..82eb8259af58a 100644 --- a/apps/theming/tests/lib/controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -36,32 +36,46 @@ use Test\TestCase; class ThemingControllerTest extends TestCase { - /** @var IRequest */ + /** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */ private $request; - /** @var IConfig */ + /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ private $config; - /** @var Template */ + /** @var Template|\PHPUnit_Framework_MockObject_MockObject */ private $template; - /** @var IL10N */ + /** @var Util */ + private $util; + /** @var \OCP\AppFramework\Utility\ITimeFactory */ + private $timeFactory; + /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */ private $l10n; /** @var ThemingController */ private $themingController; - /** @var IRootFolder */ + /** @var IRootFolder|\PHPUnit_Framework_MockObject_MockObject */ private $rootFolder; public function setUp() { - $this->request = $this->getMock('\\OCP\\IRequest'); - $this->config = $this->getMock('\\OCP\\IConfig'); - $this->template = $this->getMockBuilder('\\OCA\\Theming\\Template') + $this->request = $this->getMockBuilder('OCP\IRequest')->getMock(); + $this->config = $this->getMockBuilder('OCP\IConfig')->getMock(); + $this->template = $this->getMockBuilder('OCA\Theming\Template') ->disableOriginalConstructor()->getMock(); - $this->l10n = $this->getMock('\\OCP\\IL10N'); - $this->rootFolder = $this->getMock('\\OCP\\Files\\IRootFolder'); + $this->util = new Util(); + $this->timeFactory = $this->getMockBuilder('OCP\AppFramework\Utility\ITimeFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->l10n = $this->getMockBuilder('OCP\IL10N')->getMock(); + $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock(); + + $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 ); @@ -69,27 +83,48 @@ public function setUp() { return parent::setUp(); } - public function testUpdateStylesheet() { + public function dataUpdateStylesheet() { + return [ + ['name', str_repeat('a', 250), 'success', 'Saved'], + ['name', str_repeat('a', 251), 'error', 'The given name is too long'], + ['url', str_repeat('a', 500), 'success', 'Saved'], + ['url', str_repeat('a', 501), 'error', 'The given web address is too long'], + ['slogan', str_repeat('a', 500), 'success', 'Saved'], + ['slogan', str_repeat('a', 501), 'error', 'The given slogan is too long'], + ['color', '#0082c9', 'success', 'Saved'], + ['color', '#0082C9', 'success', 'Saved'], + ['color', '0082C9', 'error', 'The given color is invalid'], + ['color', '#0082Z9', 'error', 'The given color is invalid'], + ['color', 'Nextcloud', 'error', 'The given color is invalid'], + ]; + } + + /** + * @dataProvider dataUpdateStylesheet + * + * @param string $setting + * @param string $value + * @param string $status + * @param string $message + */ + public function testUpdateStylesheet($setting, $value, $status, $message) { $this->template - ->expects($this->once()) + ->expects($status === 'success' ? $this->once() : $this->never()) ->method('set') - ->with('MySetting', 'MyValue'); + ->with($setting, $value); $this->l10n ->expects($this->once()) ->method('t') - ->with('Saved') - ->willReturn('Saved'); + ->with($message) + ->willReturn($message); - $expected = new DataResponse( - [ - 'data' => - [ - 'message' => 'Saved', - ], - 'status' => 'success' - ] - ); - $this->assertEquals($expected, $this->themingController->updateStylesheet('MySetting', 'MyValue')); + $expected = new DataResponse([ + 'data' => [ + 'message' => $message, + ], + 'status' => $status, + ]); + $this->assertEquals($expected, $this->themingController->updateStylesheet($setting, $value)); } public function testUpdateLogoNoData() { @@ -273,6 +308,7 @@ public function testGetLogo() { @$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 +337,7 @@ public function testGetLoginBackground() { @$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 +381,7 @@ public function testGetStylesheetWithOnlyColor() { $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 +396,7 @@ public function testGetStylesheetWithOnlyColor() { $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 +437,7 @@ public function testGetStylesheetWithOnlyColorInvert() { \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 +457,7 @@ public function testGetStylesheetWithOnlyColorInvert() { $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 +499,7 @@ public function testGetStylesheetWithOnlyHeaderLogo() { $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 +533,7 @@ public function testGetStylesheetWithOnlyBackgroundLogin() { $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 +575,7 @@ public function testGetStylesheetWithAllCombined() { $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 +606,7 @@ public function testGetStylesheetWithAllCombined() { $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 +648,7 @@ public function testGetStylesheetWithAllCombinedInverted() { \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,7 +683,7 @@ public function testGetStylesheetWithAllCombinedInverted() { $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/lib/TemplateTest.php b/apps/theming/tests/TemplateTest.php similarity index 100% rename from apps/theming/tests/lib/TemplateTest.php rename to apps/theming/tests/TemplateTest.php diff --git a/apps/theming/tests/lib/UtilTest.php b/apps/theming/tests/UtilTest.php similarity index 78% rename from apps/theming/tests/lib/UtilTest.php rename to apps/theming/tests/UtilTest.php index cf64b389d113b..c7fc385d25d9b 100644 --- a/apps/theming/tests/lib/UtilTest.php +++ b/apps/theming/tests/UtilTest.php @@ -27,62 +27,70 @@ 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); }