diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-29 21:22:34 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-29 21:22:34 +0200 |
commit | 26d950486ba5e48dd5ba44a4924760c88ed6c7ac (patch) | |
tree | 1e4c039fc3250e9d049c93ab6b3cea462b00f5f9 /tests | |
parent | 45d7c475d3075f33017111fa8e8f952abedd7b46 (diff) |
add default locale and developer names and move the method to the pagecontroller, @cosenal
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/controller/AppControllerTest.php | 70 | ||||
-rw-r--r-- | tests/unit/controller/PageControllerTest.php | 43 |
2 files changed, 42 insertions, 71 deletions
diff --git a/tests/unit/controller/AppControllerTest.php b/tests/unit/controller/AppControllerTest.php deleted file mode 100644 index 7c1f5f12a..000000000 --- a/tests/unit/controller/AppControllerTest.php +++ /dev/null @@ -1,70 +0,0 @@ -<?php -/** - * ownCloud - News - * - * This file is licensed under the Affero General Public License version 3 or - * later. See the COPYING file. - * - * @author Alessandro Cosentino <cosenal@gmail.com> - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @copyright Alessandro Cosentino 2014 - * @copyright Bernhard Posselt 2014 - */ - -namespace OCA\News\Controller; - - -class AppControllerTest extends \PHPUnit_Framework_TestCase { - - private $appName; - private $request; - private $urlGenerator; - private $appConfig; - private $controller; - private $configData; - - /** - * Gets run before each test - */ - public function setUp(){ - $this->appName = 'news'; - $this->request = $this->getMockBuilder( - '\OCP\IRequest') - ->disableOriginalConstructor() - ->getMock(); - $this->urlGenerator = $this->getMockBuilder( - '\OCP\IURLGenerator') - ->disableOriginalConstructor() - ->getMock(); - $this->appConfig = $this->getMockBuilder( - '\OCA\News\Config\AppConfig') - ->disableOriginalConstructor() - ->getMock(); - - $this->configData = [ - 'name' => 'AppTest', - 'id' => 'apptest', - 'authors' => [ - ['name' => 'john'], - ['name' => 'test'] - ], - 'description' => 'This is a test app', - 'homepage' => 'https://github.com/owncloud/test' - ]; - - $this->controller = new AppController($this->appName, $this->request, - $this->urlGenerator, $this->appConfig); - } - - public function testManifest(){ - $this->appConfig->expects($this->once()) - ->method('getConfig') - ->will($this->returnValue($this->configData)); - $result = $this->controller->manifest(); - $this->assertEquals($this->configData['name'], $result['name']); - $this->assertEquals($this->configData['description'], $result['description']); - $this->assertEquals($this->configData['homepage'], $result['developer']['url']); - $this->assertEquals('john, test', $result['developer']['name']); - } - -}
\ No newline at end of file diff --git a/tests/unit/controller/PageControllerTest.php b/tests/unit/controller/PageControllerTest.php index d27049f95..ec2fcae14 100644 --- a/tests/unit/controller/PageControllerTest.php +++ b/tests/unit/controller/PageControllerTest.php @@ -22,6 +22,9 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase { private $controller; private $user; private $l10n; + private $urlGenerator; + private $appConfig; + private $configData; /** * Gets run before each test @@ -29,6 +32,16 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase { public function setUp(){ $this->appName = 'news'; $this->user = 'becka'; + $this->configData = [ + 'name' => 'AppTest', + 'id' => 'apptest', + 'authors' => [ + ['name' => 'john'], + ['name' => 'test'] + ], + 'description' => 'This is a test app', + 'homepage' => 'https://github.com/owncloud/test' + ]; $this->l10n = $this->request = $this->getMockBuilder( '\OCP\IL10n') ->disableOriginalConstructor() @@ -41,8 +54,17 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase { '\OCP\IRequest') ->disableOriginalConstructor() ->getMock(); + $this->urlGenerator = $this->getMockBuilder( + '\OCP\IURLGenerator') + ->disableOriginalConstructor() + ->getMock(); + $this->appConfig = $this->getMockBuilder( + '\OCA\News\Config\AppConfig') + ->disableOriginalConstructor() + ->getMock(); $this->controller = new PageController($this->appName, $this->request, - $this->settings, $this->l10n, $this->user); + $this->settings, $this->urlGenerator, $this->appConfig, $this->l10n, + $this->user); } @@ -125,4 +147,23 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase { } + + public function testManifest(){ + $this->appConfig->expects($this->once()) + ->method('getConfig') + ->will($this->returnValue($this->configData)); + $this->l10n->expects($this->once()) + ->method('getLanguageCode') + ->will($this->returnValue('de_DE')); + + $result = $this->controller->manifest(); + $this->assertEquals($this->configData['name'], $result['name']); + $this->assertEquals('web', $result['type']); + $this->assertEquals($this->configData['description'], $result['description']); + $this->assertEquals('de-DE', $result['default_locale']); + $this->assertEquals($this->configData['homepage'], $result['developer']['url']); + $this->assertEquals('john, test', $result['developer']['name']); + } + + }
\ No newline at end of file |