Fix tests
This commit is contained in:
parent
2de4112176
commit
5306b4feba
|
@ -33,6 +33,7 @@ use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataDownloadResponse;
|
use OCP\AppFramework\Http\DataDownloadResponse;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
use OCP\AppFramework\Http\StreamResponse;
|
use OCP\AppFramework\Http\StreamResponse;
|
||||||
|
use OCP\AppFramework\Utility\ITimeFactory;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
|
@ -49,6 +50,10 @@ use OCA\Theming\Util;
|
||||||
class ThemingController extends Controller {
|
class ThemingController extends Controller {
|
||||||
/** @var Template */
|
/** @var Template */
|
||||||
private $template;
|
private $template;
|
||||||
|
/** @var Util */
|
||||||
|
private $util;
|
||||||
|
/** @var ITimeFactory */
|
||||||
|
private $timeFactory;
|
||||||
/** @var IL10N */
|
/** @var IL10N */
|
||||||
private $l;
|
private $l;
|
||||||
/** @var IConfig */
|
/** @var IConfig */
|
||||||
|
@ -63,6 +68,8 @@ class ThemingController extends Controller {
|
||||||
* @param IRequest $request
|
* @param IRequest $request
|
||||||
* @param IConfig $config
|
* @param IConfig $config
|
||||||
* @param Template $template
|
* @param Template $template
|
||||||
|
* @param Util $util
|
||||||
|
* @param ITimeFactory $timeFactory
|
||||||
* @param IL10N $l
|
* @param IL10N $l
|
||||||
* @param IRootFolder $rootFolder
|
* @param IRootFolder $rootFolder
|
||||||
*/
|
*/
|
||||||
|
@ -71,12 +78,16 @@ class ThemingController extends Controller {
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
IConfig $config,
|
IConfig $config,
|
||||||
Template $template,
|
Template $template,
|
||||||
|
Util $util,
|
||||||
|
ITimeFactory $timeFactory,
|
||||||
IL10N $l,
|
IL10N $l,
|
||||||
IRootFolder $rootFolder
|
IRootFolder $rootFolder
|
||||||
) {
|
) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
|
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
|
$this->util = $util;
|
||||||
|
$this->timeFactory = $timeFactory;
|
||||||
$this->l = $l;
|
$this->l = $l;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->rootFolder = $rootFolder;
|
$this->rootFolder = $rootFolder;
|
||||||
|
@ -178,7 +189,7 @@ class ThemingController extends Controller {
|
||||||
|
|
||||||
$response = new Http\StreamResponse($pathToLogo);
|
$response = new Http\StreamResponse($pathToLogo);
|
||||||
$response->cacheFor(3600);
|
$response->cacheFor(3600);
|
||||||
$response->addHeader('Expires', date(\DateTime::RFC2822));
|
$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
|
||||||
$response->addHeader('Content-Disposition', 'attachment');
|
$response->addHeader('Content-Disposition', 'attachment');
|
||||||
$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
|
$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
|
||||||
return $response;
|
return $response;
|
||||||
|
@ -198,7 +209,7 @@ class ThemingController extends Controller {
|
||||||
|
|
||||||
$response = new StreamResponse($pathToLogo);
|
$response = new StreamResponse($pathToLogo);
|
||||||
$response->cacheFor(3600);
|
$response->cacheFor(3600);
|
||||||
$response->addHeader('Expires', date(\DateTime::RFC2822));
|
$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
|
||||||
$response->addHeader('Content-Disposition', 'attachment');
|
$response->addHeader('Content-Disposition', 'attachment');
|
||||||
$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
|
$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
|
||||||
return $response;
|
return $response;
|
||||||
|
@ -214,7 +225,7 @@ class ThemingController extends Controller {
|
||||||
$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
|
$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
|
||||||
$responseCss = '';
|
$responseCss = '';
|
||||||
$color = $this->config->getAppValue($this->appName, 'color');
|
$color = $this->config->getAppValue($this->appName, 'color');
|
||||||
$elementColor = Util::elementColor($color);
|
$elementColor = $this->util->elementColor($color);
|
||||||
if($color !== '') {
|
if($color !== '') {
|
||||||
$responseCss .= sprintf(
|
$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",
|
'#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 +240,7 @@ class ThemingController extends Controller {
|
||||||
$elementColor
|
$elementColor
|
||||||
);
|
);
|
||||||
$responseCss .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' .
|
$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";
|
"}\n";
|
||||||
$responseCss .= '
|
$responseCss .= '
|
||||||
#firstrunwizard .firstrunwizard-header {
|
#firstrunwizard .firstrunwizard-header {
|
||||||
|
@ -265,7 +276,7 @@ class ThemingController extends Controller {
|
||||||
'background-image: url(\'./loginbackground?v='.$cacheBusterValue.'\');' .
|
'background-image: url(\'./loginbackground?v='.$cacheBusterValue.'\');' .
|
||||||
'}' . "\n";
|
'}' . "\n";
|
||||||
}
|
}
|
||||||
if(Util::invertTextColor($color)) {
|
if($this->util->invertTextColor($color)) {
|
||||||
$responseCss .= '#header .header-appname, #expandDisplayName { color: #000000; }' . "\n";
|
$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 .= '#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"] { background: transparent url(\'' . \OC::$WEBROOT . '/core/img/actions/search.svg\') no-repeat 6px center; color: #000; }' . "\n";
|
||||||
|
@ -273,7 +284,7 @@ class ThemingController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = new DataDownloadResponse($responseCss, 'style', 'text/css');
|
$response = new DataDownloadResponse($responseCss, 'style', 'text/css');
|
||||||
$response->addHeader('Expires', date(\DateTime::RFC2822));
|
$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
|
||||||
$response->cacheFor(3600);
|
$response->cacheFor(3600);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ class Util {
|
||||||
* @param string $color rgb color value
|
* @param string $color rgb color value
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function invertTextColor($color) {
|
public function invertTextColor($color) {
|
||||||
$l = self::calculateLuminance($color);
|
$l = $this->calculateLuminance($color);
|
||||||
if($l>0.5) {
|
if($l>0.5) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,8 +44,8 @@ class Util {
|
||||||
* @param $color
|
* @param $color
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function elementColor($color) {
|
public function elementColor($color) {
|
||||||
$l = self::calculateLuminance($color);
|
$l = $this->calculateLuminance($color);
|
||||||
if($l>0.8) {
|
if($l>0.8) {
|
||||||
return '#555555';
|
return '#555555';
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,7 +57,7 @@ class Util {
|
||||||
* @param string $color rgb color value
|
* @param string $color rgb color value
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public static function calculateLuminance($color) {
|
public function calculateLuminance($color) {
|
||||||
$hex = preg_replace("/[^0-9A-Fa-f]/", '', $color);
|
$hex = preg_replace("/[^0-9A-Fa-f]/", '', $color);
|
||||||
if (strlen($hex) === 3) {
|
if (strlen($hex) === 3) {
|
||||||
$hex = $hex{0} . $hex{0} . $hex{1} . $hex{1} . $hex{2} . $hex{2};
|
$hex = $hex{0} . $hex{0} . $hex{1} . $hex{1} . $hex{2} . $hex{2};
|
||||||
|
@ -75,7 +75,7 @@ class Util {
|
||||||
* @param $color
|
* @param $color
|
||||||
* @return string base64 encoded radio button svg
|
* @return string base64 encoded radio button svg
|
||||||
*/
|
*/
|
||||||
public static function generateRadioButton($color) {
|
public function generateRadioButton($color) {
|
||||||
$radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">' .
|
$radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">' .
|
||||||
'<path d="M8 1a7 7 0 0 0-7 7 7 7 0 0 0 7 7 7 7 0 0 0 7-7 7 7 0 0 0-7-7zm0 1a6 6 0 0 1 6 6 6 6 0 0 1-6 6 6 6 0 0 1-6-6 6 6 0 0 1 6-6zm0 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="'.$color.'"/></svg>';
|
'<path d="M8 1a7 7 0 0 0-7 7 7 7 0 0 0 7 7 7 7 0 0 0 7-7 7 7 0 0 0-7-7zm0 1a6 6 0 0 1 6 6 6 6 0 0 1-6 6 6 6 0 0 1-6-6 6 6 0 0 1 6-6zm0 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="'.$color.'"/></svg>';
|
||||||
return base64_encode($radioButtonIcon);
|
return base64_encode($radioButtonIcon);
|
||||||
|
|
|
@ -42,6 +42,10 @@ class ThemingControllerTest extends TestCase {
|
||||||
private $config;
|
private $config;
|
||||||
/** @var Template */
|
/** @var Template */
|
||||||
private $template;
|
private $template;
|
||||||
|
/** @var Util */
|
||||||
|
private $util;
|
||||||
|
/** @var \OCP\AppFramework\Utility\ITimeFactory */
|
||||||
|
private $timeFactory;
|
||||||
/** @var IL10N */
|
/** @var IL10N */
|
||||||
private $l10n;
|
private $l10n;
|
||||||
/** @var ThemingController */
|
/** @var ThemingController */
|
||||||
|
@ -54,14 +58,24 @@ class ThemingControllerTest extends TestCase {
|
||||||
$this->config = $this->getMock('\\OCP\\IConfig');
|
$this->config = $this->getMock('\\OCP\\IConfig');
|
||||||
$this->template = $this->getMockBuilder('\\OCA\\Theming\\Template')
|
$this->template = $this->getMockBuilder('\\OCA\\Theming\\Template')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
|
$this->util = new Util();
|
||||||
|
$this->timeFactory = $this->getMockBuilder('OCP\AppFramework\Utility\ITimeFactory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
$this->l10n = $this->getMock('\\OCP\\IL10N');
|
$this->l10n = $this->getMock('\\OCP\\IL10N');
|
||||||
$this->rootFolder = $this->getMock('\\OCP\\Files\\IRootFolder');
|
$this->rootFolder = $this->getMock('\\OCP\\Files\\IRootFolder');
|
||||||
|
|
||||||
|
$this->timeFactory->expects($this->any())
|
||||||
|
->method('getTime')
|
||||||
|
->willReturn(123);
|
||||||
|
|
||||||
$this->themingController = new ThemingController(
|
$this->themingController = new ThemingController(
|
||||||
'theming',
|
'theming',
|
||||||
$this->request,
|
$this->request,
|
||||||
$this->config,
|
$this->config,
|
||||||
$this->template,
|
$this->template,
|
||||||
|
$this->util,
|
||||||
|
$this->timeFactory,
|
||||||
$this->l10n,
|
$this->l10n,
|
||||||
$this->rootFolder
|
$this->rootFolder
|
||||||
);
|
);
|
||||||
|
@ -273,6 +287,7 @@ class ThemingControllerTest extends TestCase {
|
||||||
|
|
||||||
@$expected = new Http\StreamResponse($tmpLogo);
|
@$expected = new Http\StreamResponse($tmpLogo);
|
||||||
$expected->cacheFor(3600);
|
$expected->cacheFor(3600);
|
||||||
|
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
|
||||||
$expected->addHeader('Content-Disposition', 'attachment');
|
$expected->addHeader('Content-Disposition', 'attachment');
|
||||||
$expected->addHeader('Content-Type', 'text/svg');
|
$expected->addHeader('Content-Type', 'text/svg');
|
||||||
@$this->assertEquals($expected, $this->themingController->getLogo());
|
@$this->assertEquals($expected, $this->themingController->getLogo());
|
||||||
|
@ -301,6 +316,7 @@ class ThemingControllerTest extends TestCase {
|
||||||
|
|
||||||
@$expected = new Http\StreamResponse($tmpLogo);
|
@$expected = new Http\StreamResponse($tmpLogo);
|
||||||
$expected->cacheFor(3600);
|
$expected->cacheFor(3600);
|
||||||
|
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
|
||||||
$expected->addHeader('Content-Disposition', 'attachment');
|
$expected->addHeader('Content-Disposition', 'attachment');
|
||||||
$expected->addHeader('Content-Type', 'image/png');
|
$expected->addHeader('Content-Type', 'image/png');
|
||||||
@$this->assertEquals($expected, $this->themingController->getLoginBackground());
|
@$this->assertEquals($expected, $this->themingController->getLoginBackground());
|
||||||
|
@ -344,7 +360,7 @@ class ThemingControllerTest extends TestCase {
|
||||||
$color
|
$color
|
||||||
);
|
);
|
||||||
$expectedData .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' .
|
$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";
|
"}\n";
|
||||||
|
|
||||||
$expectedData .= '
|
$expectedData .= '
|
||||||
|
@ -359,6 +375,7 @@ class ThemingControllerTest extends TestCase {
|
||||||
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
||||||
|
|
||||||
$expected->cacheFor(3600);
|
$expected->cacheFor(3600);
|
||||||
|
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
|
||||||
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +416,7 @@ class ThemingControllerTest extends TestCase {
|
||||||
\OC::$WEBROOT
|
\OC::$WEBROOT
|
||||||
);
|
);
|
||||||
$expectedData .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' .
|
$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";
|
"}\n";
|
||||||
|
|
||||||
$expectedData .= '
|
$expectedData .= '
|
||||||
|
@ -419,6 +436,7 @@ class ThemingControllerTest extends TestCase {
|
||||||
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
||||||
|
|
||||||
$expected->cacheFor(3600);
|
$expected->cacheFor(3600);
|
||||||
|
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
|
||||||
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,6 +478,7 @@ class ThemingControllerTest extends TestCase {
|
||||||
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
||||||
|
|
||||||
$expected->cacheFor(3600);
|
$expected->cacheFor(3600);
|
||||||
|
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
|
||||||
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,6 +512,7 @@ class ThemingControllerTest extends TestCase {
|
||||||
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
||||||
|
|
||||||
$expected->cacheFor(3600);
|
$expected->cacheFor(3600);
|
||||||
|
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
|
||||||
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,7 +554,7 @@ class ThemingControllerTest extends TestCase {
|
||||||
$color
|
$color
|
||||||
);
|
);
|
||||||
$expectedData .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' .
|
$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";
|
"}\n";
|
||||||
$expectedData .= '
|
$expectedData .= '
|
||||||
#firstrunwizard .firstrunwizard-header {
|
#firstrunwizard .firstrunwizard-header {
|
||||||
|
@ -565,6 +585,7 @@ class ThemingControllerTest extends TestCase {
|
||||||
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
||||||
|
|
||||||
$expected->cacheFor(3600);
|
$expected->cacheFor(3600);
|
||||||
|
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
|
||||||
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,7 +627,7 @@ class ThemingControllerTest extends TestCase {
|
||||||
\OC::$WEBROOT
|
\OC::$WEBROOT
|
||||||
);
|
);
|
||||||
$expectedData .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' .
|
$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";
|
"}\n";
|
||||||
$expectedData .= '
|
$expectedData .= '
|
||||||
#firstrunwizard .firstrunwizard-header {
|
#firstrunwizard .firstrunwizard-header {
|
||||||
|
@ -641,6 +662,7 @@ class ThemingControllerTest extends TestCase {
|
||||||
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
||||||
|
|
||||||
$expected->cacheFor(3600);
|
$expected->cacheFor(3600);
|
||||||
|
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
|
||||||
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,62 +27,70 @@ use Test\TestCase;
|
||||||
|
|
||||||
class UtilTest extends TestCase {
|
class UtilTest extends TestCase {
|
||||||
|
|
||||||
|
/** @var Util */
|
||||||
|
protected $util;
|
||||||
|
|
||||||
|
protected function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
$this->util = new Util();
|
||||||
|
}
|
||||||
|
|
||||||
public function testInvertTextColorLight() {
|
public function testInvertTextColorLight() {
|
||||||
$invert = Util::invertTextColor('#ffffff');
|
$invert = $this->util->invertTextColor('#ffffff');
|
||||||
$this->assertEquals(true, $invert);
|
$this->assertEquals(true, $invert);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvertTextColorDark() {
|
public function testInvertTextColorDark() {
|
||||||
$invert = Util::invertTextColor('#000000');
|
$invert = $this->util->invertTextColor('#000000');
|
||||||
$this->assertEquals(false, $invert);
|
$this->assertEquals(false, $invert);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCalculateLuminanceLight() {
|
public function testCalculateLuminanceLight() {
|
||||||
$luminance = Util::calculateLuminance('#ffffff');
|
$luminance = $this->util->calculateLuminance('#ffffff');
|
||||||
$this->assertEquals(1, $luminance);
|
$this->assertEquals(1, $luminance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCalculateLuminanceDark() {
|
public function testCalculateLuminanceDark() {
|
||||||
$luminance = Util::calculateLuminance('#000000');
|
$luminance = $this->util->calculateLuminance('#000000');
|
||||||
$this->assertEquals(0, $luminance);
|
$this->assertEquals(0, $luminance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCalculateLuminanceLightShorthand() {
|
public function testCalculateLuminanceLightShorthand() {
|
||||||
$luminance = Util::calculateLuminance('#fff');
|
$luminance = $this->util->calculateLuminance('#fff');
|
||||||
$this->assertEquals(1, $luminance);
|
$this->assertEquals(1, $luminance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCalculateLuminanceDarkShorthand() {
|
public function testCalculateLuminanceDarkShorthand() {
|
||||||
$luminance = Util::calculateLuminance('#000');
|
$luminance = $this->util->calculateLuminance('#000');
|
||||||
$this->assertEquals(0, $luminance);
|
$this->assertEquals(0, $luminance);
|
||||||
}
|
}
|
||||||
public function testInvertTextColorInvalid() {
|
public function testInvertTextColorInvalid() {
|
||||||
$invert = Util::invertTextColor('aaabbbcccddd123');
|
$invert = $this->util->invertTextColor('aaabbbcccddd123');
|
||||||
$this->assertEquals(false, $invert);
|
$this->assertEquals(false, $invert);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvertTextColorEmpty() {
|
public function testInvertTextColorEmpty() {
|
||||||
$invert = Util::invertTextColor('');
|
$invert = $this->util->invertTextColor('');
|
||||||
$this->assertEquals(false, $invert);
|
$this->assertEquals(false, $invert);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testElementColorDefault() {
|
public function testElementColorDefault() {
|
||||||
$elementColor = Util::elementColor("#000000");
|
$elementColor = $this->util->elementColor("#000000");
|
||||||
$this->assertEquals('#000000', $elementColor);
|
$this->assertEquals('#000000', $elementColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testElementColorOnBrightBackground() {
|
public function testElementColorOnBrightBackground() {
|
||||||
$elementColor = Util::elementColor('#ffffff');
|
$elementColor = $this->util->elementColor('#ffffff');
|
||||||
$this->assertEquals('#555555', $elementColor);
|
$this->assertEquals('#555555', $elementColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGenerateRadioButtonWhite() {
|
public function testGenerateRadioButtonWhite() {
|
||||||
$button = Util::generateRadioButton('#ffffff');
|
$button = $this->util->generateRadioButton('#ffffff');
|
||||||
$expected = 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTYiIHdpZHRoPSIxNiI+PHBhdGggZD0iTTggMWE3IDcgMCAwIDAtNyA3IDcgNyAwIDAgMCA3IDcgNyA3IDAgMCAwIDctNyA3IDcgMCAwIDAtNy03em0wIDFhNiA2IDAgMCAxIDYgNiA2IDYgMCAwIDEtNiA2IDYgNiAwIDAgMS02LTYgNiA2IDAgMCAxIDYtNnptMCAyYTQgNCAwIDEgMCAwIDggNCA0IDAgMCAwIDAtOHoiIGZpbGw9IiNmZmZmZmYiLz48L3N2Zz4=';
|
$expected = 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTYiIHdpZHRoPSIxNiI+PHBhdGggZD0iTTggMWE3IDcgMCAwIDAtNyA3IDcgNyAwIDAgMCA3IDcgNyA3IDAgMCAwIDctNyA3IDcgMCAwIDAtNy03em0wIDFhNiA2IDAgMCAxIDYgNiA2IDYgMCAwIDEtNiA2IDYgNiAwIDAgMS02LTYgNiA2IDAgMCAxIDYtNnptMCAyYTQgNCAwIDEgMCAwIDggNCA0IDAgMCAwIDAtOHoiIGZpbGw9IiNmZmZmZmYiLz48L3N2Zz4=';
|
||||||
$this->assertEquals($expected, $button);
|
$this->assertEquals($expected, $button);
|
||||||
}
|
}
|
||||||
public function testGenerateRadioButtonBlack() {
|
public function testGenerateRadioButtonBlack() {
|
||||||
$button = Util::generateRadioButton('#000000');
|
$button = $this->util->generateRadioButton('#000000');
|
||||||
$expected = 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTYiIHdpZHRoPSIxNiI+PHBhdGggZD0iTTggMWE3IDcgMCAwIDAtNyA3IDcgNyAwIDAgMCA3IDcgNyA3IDAgMCAwIDctNyA3IDcgMCAwIDAtNy03em0wIDFhNiA2IDAgMCAxIDYgNiA2IDYgMCAwIDEtNiA2IDYgNiAwIDAgMS02LTYgNiA2IDAgMCAxIDYtNnptMCAyYTQgNCAwIDEgMCAwIDggNCA0IDAgMCAwIDAtOHoiIGZpbGw9IiMwMDAwMDAiLz48L3N2Zz4=';
|
$expected = 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTYiIHdpZHRoPSIxNiI+PHBhdGggZD0iTTggMWE3IDcgMCAwIDAtNyA3IDcgNyAwIDAgMCA3IDcgNyA3IDAgMCAwIDctNyA3IDcgMCAwIDAtNy03em0wIDFhNiA2IDAgMCAxIDYgNiA2IDYgMCAwIDEtNiA2IDYgNiAwIDAgMS02LTYgNiA2IDAgMCAxIDYtNnptMCAyYTQgNCAwIDEgMCAwIDggNCA0IDAgMCAwIDAtOHoiIGZpbGw9IiMwMDAwMDAiLz48L3N2Zz4=';
|
||||||
$this->assertEquals($expected, $button);
|
$this->assertEquals($expected, $button);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue