summaryrefslogtreecommitdiffstats
path: root/apps/theming/tests/UtilTest.php
diff options
context:
space:
mode:
authorJulius Haertl <jus@bitgrid.net>2016-08-29 11:53:44 +0200
committerJulius Haertl <jus@bitgrid.net>2016-11-18 10:23:23 +0100
commitb466628bfddee71b3c4d9f8d903e327269f57b4a (patch)
treec2ab37d5f9e1420039cf377fbfd9450e5a0019a3 /apps/theming/tests/UtilTest.php
parentac7f852ed996079785e6b5f1c1789f76a7a26386 (diff)
downloadnextcloud-server-b466628bfddee71b3c4d9f8d903e327269f57b4a.tar.gz
nextcloud-server-b466628bfddee71b3c4d9f8d903e327269f57b4a.zip
Improve unit tests for image generation
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Diffstat (limited to 'apps/theming/tests/UtilTest.php')
-rw-r--r--apps/theming/tests/UtilTest.php61
1 files changed, 59 insertions, 2 deletions
diff --git a/apps/theming/tests/UtilTest.php b/apps/theming/tests/UtilTest.php
index c7fc385d25d..499a3ffc45d 100644
--- a/apps/theming/tests/UtilTest.php
+++ b/apps/theming/tests/UtilTest.php
@@ -23,16 +23,22 @@
namespace OCA\Theming\Tests;
use OCA\Theming\Util;
+use OCP\IConfig;
+use OCP\Files\IRootFolder;
use Test\TestCase;
class UtilTest extends TestCase {
/** @var Util */
protected $util;
-
+ /** @var IConfig */
+ protected $config;
+ protected $rootFolder;
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->util = new Util($this->config, $this->rootFolder);
}
public function testInvertTextColorLight() {
@@ -94,4 +100,55 @@ class UtilTest extends TestCase {
$expected = 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTYiIHdpZHRoPSIxNiI+PHBhdGggZD0iTTggMWE3IDcgMCAwIDAtNyA3IDcgNyAwIDAgMCA3IDcgNyA3IDAgMCAwIDctNyA3IDcgMCAwIDAtNy03em0wIDFhNiA2IDAgMCAxIDYgNiA2IDYgMCAwIDEtNiA2IDYgNiAwIDAgMS02LTYgNiA2IDAgMCAxIDYtNnptMCAyYTQgNCAwIDEgMCAwIDggNCA0IDAgMCAwIDAtOHoiIGZpbGw9IiMwMDAwMDAiLz48L3N2Zz4=';
$this->assertEquals($expected, $button);
}
+
+
+
+ /**
+ * @dataProvider dataGetAppIcon
+ */
+ public function testGetAppIcon($app, $expected) {
+ $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) {
+ $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);
+ }
+
}