diff options
author | Julius Haertl <jus@bitgrid.net> | 2016-11-18 10:49:03 +0100 |
---|---|---|
committer | Julius Haertl <jus@bitgrid.net> | 2016-11-18 11:07:44 +0100 |
commit | 2ab4d1e0a3f15af2b8f04edcf18b7fe3fc0be262 (patch) | |
tree | ec035e8aec9d655e07bd06e4337a41c0bb8c4846 /apps/theming/tests | |
parent | d409fe1c525ba05f342d52a9686ae395a0dac465 (diff) | |
download | nextcloud-server-2ab4d1e0a3f15af2b8f04edcf18b7fe3fc0be262.tar.gz nextcloud-server-2ab4d1e0a3f15af2b8f04edcf18b7fe3fc0be262.zip |
Use IAppManager instead of OC_App
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Diffstat (limited to 'apps/theming/tests')
-rw-r--r-- | apps/theming/tests/Controller/ThemingControllerTest.php | 6 | ||||
-rw-r--r-- | apps/theming/tests/IconBuilderTest.php | 6 | ||||
-rw-r--r-- | apps/theming/tests/UtilTest.php | 16 |
3 files changed, 25 insertions, 3 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index 3bf7709b0de..9ce4fb86b52 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -26,6 +26,7 @@ namespace OCA\Theming\Tests\Controller; use OCA\Theming\Controller\ThemingController; use OCA\Theming\Util; +use OCP\App\IAppManager; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\Files\IRootFolder; @@ -55,6 +56,8 @@ class ThemingControllerTest extends TestCase { private $rootFolder; /** @var ITempManager */ private $tempManager; + /** @var IAppManager */ + private $appManager; public function setUp() { $this->request = $this->getMockBuilder('OCP\IRequest')->getMock(); @@ -66,7 +69,8 @@ class ThemingControllerTest extends TestCase { ->getMock(); $this->l10n = $this->getMockBuilder('OCP\IL10N')->getMock(); $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock(); - $this->util = new Util($this->config, $this->rootFolder); + $this->appManager = $this->getMockBuilder('OCP\App\IAppManager')->getMock(); + $this->util = new Util($this->config, $this->rootFolder, $this->appManager); $this->timeFactory->expects($this->any()) ->method('getTime') ->willReturn(123); diff --git a/apps/theming/tests/IconBuilderTest.php b/apps/theming/tests/IconBuilderTest.php index a13d4b9476d..54850c8f3c2 100644 --- a/apps/theming/tests/IconBuilderTest.php +++ b/apps/theming/tests/IconBuilderTest.php @@ -25,6 +25,7 @@ namespace OCA\Theming\Tests; use OCA\Theming\IconBuilder; use OCA\Theming\ThemingDefaults; use OCA\Theming\Util; +use OCP\App\IAppManager; use OCP\AppFramework\Http\NotFoundResponse; use OCP\Files\IRootFolder; use OCP\IConfig; @@ -42,6 +43,8 @@ class IconBuilderTest extends TestCase { protected $util; /** @var IconBuilder */ protected $iconBuilder; + /** @var IAppManager */ + protected $appManager; protected function setUp() { parent::setUp(); @@ -50,7 +53,8 @@ class IconBuilderTest extends TestCase { $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock(); $this->themingDefaults = $this->getMockBuilder('OCA\Theming\ThemingDefaults') ->disableOriginalConstructor()->getMock(); - $this->util = new Util($this->config, $this->rootFolder); + $this->appManager = $this->getMockBuilder('OCP\App\IAppManager')->getMock(); + $this->util = new Util($this->config, $this->rootFolder, $this->appManager); $this->iconBuilder = new IconBuilder($this->themingDefaults, $this->util); } diff --git a/apps/theming/tests/UtilTest.php b/apps/theming/tests/UtilTest.php index d82ec8eeb85..83895208fea 100644 --- a/apps/theming/tests/UtilTest.php +++ b/apps/theming/tests/UtilTest.php @@ -23,6 +23,7 @@ namespace OCA\Theming\Tests; use OCA\Theming\Util; +use OCP\App\IAppManager; use OCP\IConfig; use OCP\Files\IRootFolder; use Test\TestCase; @@ -35,12 +36,15 @@ class UtilTest extends TestCase { protected $config; /** @var IRootFolder */ protected $rootFolder; + /** @var IAppManager */ + protected $appManager; protected function setUp() { parent::setUp(); $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock(); - $this->util = new Util($this->config, $this->rootFolder); + $this->appManager = $this->getMockBuilder('OCP\App\IAppManager')->getMock(); + $this->util = new Util($this->config, $this->rootFolder, $this->appManager); } public function testInvertTextColorLight() { @@ -108,6 +112,10 @@ class UtilTest extends TestCase { * @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); } @@ -134,6 +142,12 @@ class UtilTest extends TestCase { * @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)); } |