summaryrefslogtreecommitdiffstats
path: root/apps/theming/tests/UtilTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/theming/tests/UtilTest.php')
-rw-r--r--apps/theming/tests/UtilTest.php75
1 files changed, 74 insertions, 1 deletions
diff --git a/apps/theming/tests/UtilTest.php b/apps/theming/tests/UtilTest.php
index c7fc385d25d..83895208fea 100644
--- a/apps/theming/tests/UtilTest.php
+++ b/apps/theming/tests/UtilTest.php
@@ -23,16 +23,28 @@
namespace OCA\Theming\Tests;
use OCA\Theming\Util;
+use OCP\App\IAppManager;
+use OCP\IConfig;
+use OCP\Files\IRootFolder;
use Test\TestCase;
class UtilTest extends TestCase {
/** @var Util */
protected $util;
+ /** @var IConfig */
+ protected $config;
+ /** @var IRootFolder */
+ protected $rootFolder;
+ /** @var IAppManager */
+ protected $appManager;
protected function setUp() {
parent::setUp();
- $this->util = new Util();
+ $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+ $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock();
+ $this->appManager = $this->getMockBuilder('OCP\App\IAppManager')->getMock();
+ $this->util = new Util($this->config, $this->rootFolder, $this->appManager);
}
public function testInvertTextColorLight() {
@@ -89,9 +101,70 @@ class UtilTest extends TestCase {
$expected = 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTYiIHdpZHRoPSIxNiI+PHBhdGggZD0iTTggMWE3IDcgMCAwIDAtNyA3IDcgNyAwIDAgMCA3IDcgNyA3IDAgMCAwIDctNyA3IDcgMCAwIDAtNy03em0wIDFhNiA2IDAgMCAxIDYgNiA2IDYgMCAwIDEtNiA2IDYgNiAwIDAgMS02LTYgNiA2IDAgMCAxIDYtNnptMCAyYTQgNCAwIDEgMCAwIDggNCA0IDAgMCAwIDAtOHoiIGZpbGw9IiNmZmZmZmYiLz48L3N2Zz4=';
$this->assertEquals($expected, $button);
}
+
public function testGenerateRadioButtonBlack() {
$button = $this->util->generateRadioButton('#000000');
$expected = 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTYiIHdpZHRoPSIxNiI+PHBhdGggZD0iTTggMWE3IDcgMCAwIDAtNyA3IDcgNyAwIDAgMCA3IDcgNyA3IDAgMCAwIDctNyA3IDcgMCAwIDAtNy03em0wIDFhNiA2IDAgMCAxIDYgNiA2IDYgMCAwIDEtNiA2IDYgNiAwIDAgMS02LTYgNiA2IDAgMCAxIDYtNnptMCAyYTQgNCAwIDEgMCAwIDggNCA0IDAgMCAwIDAtOHoiIGZpbGw9IiMwMDAwMDAiLz48L3N2Zz4=';
$this->assertEquals($expected, $button);
}
+
+ /**
+ * @dataProvider dataGetAppIcon
+ */
+ public function testGetAppIcon($app, $expected) {
+ $this->appManager->expects($this->once())
+ ->method('getAppPath')
+ ->with($app)
+ ->willReturn(\OC_App::getAppPath($app));
+ $icon = $this->util->getAppIcon($app);
+ $this->assertEquals($expected, $icon);
+ }
+
+ public function dataGetAppIcon() {
+ return [
+ ['user_ldap', \OC_App::getAppPath('user_ldap') . '/img/app.svg'],
+ ['noapplikethis', \OC::$SERVERROOT . '/core/img/logo.svg'],
+ ['comments', \OC_App::getAppPath('comments') . '/img/comments.svg'],
+ ];
+ }
+
+ public function testGetAppIconThemed() {
+ $this->rootFolder->expects($this->once())
+ ->method('nodeExists')
+ ->with('/themedinstancelogo')
+ ->willReturn(true);
+ $expected = '/themedinstancelogo';
+ $icon = $this->util->getAppIcon('noapplikethis');
+ $this->assertEquals($expected, $icon);
+ }
+
+ /**
+ * @dataProvider dataGetAppImage
+ */
+ public function testGetAppImage($app, $image, $expected) {
+ if($app !== 'core') {
+ $this->appManager->expects($this->once())
+ ->method('getAppPath')
+ ->with($app)
+ ->willReturn(\OC_App::getAppPath($app));
+ }
+ $this->assertEquals($expected, $this->util->getAppImage($app, $image));
+ }
+
+ public function dataGetAppImage() {
+ return [
+ ['core', 'logo.svg', \OC::$SERVERROOT . '/core/img/logo.svg'],
+ ['files', 'external', \OC::$SERVERROOT . '/apps/files/img/external.svg'],
+ ['files', 'external.svg', \OC::$SERVERROOT . '/apps/files/img/external.svg'],
+ ['noapplikethis', 'foobar.svg', false],
+ ];
+ }
+
+ public function testColorizeSvg() {
+ $input = "#0082c9 #0082C9 #000000 #FFFFFF";
+ $expected = "#AAAAAA #AAAAAA #000000 #FFFFFF";
+ $result = $this->util->colorizeSvg($input, '#AAAAAA');
+ $this->assertEquals($expected, $result);
+ }
+
}