diff options
Diffstat (limited to 'tests/unit/controller/PageControllerTest.php')
-rw-r--r-- | tests/unit/controller/PageControllerTest.php | 50 |
1 files changed, 14 insertions, 36 deletions
diff --git a/tests/unit/controller/PageControllerTest.php b/tests/unit/controller/PageControllerTest.php index 331303495..ef3384431 100644 --- a/tests/unit/controller/PageControllerTest.php +++ b/tests/unit/controller/PageControllerTest.php @@ -13,14 +13,11 @@ namespace OCA\News\Controller; -use \OCP\IRequest; - -use \OCA\News\Utility\ControllerTestUtility; require_once(__DIR__ . "/../../classloader.php"); -class PageControllerTest extends ControllerTestUtility { +class PageControllerTest extends \PHPUnit_Framework_TestCase { private $settings; private $appName; @@ -36,32 +33,23 @@ class PageControllerTest extends ControllerTestUtility { public function setUp(){ $this->appName = 'news'; $this->user = 'becka'; - $this->l10n = $this->getMock('L10N', array('findLanguage')); + $this->l10n = $this->request = $this->getMockBuilder( + '\OCP\IL10n') + ->disableOriginalConstructor() + ->getMock(); $this->settings = $this->getMockBuilder( '\OCP\IConfig') ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getRequest(); + $this->request = $this->getMockBuilder( + '\OCP\IRequest') + ->disableOriginalConstructor() + ->getMock(); $this->controller = new PageController($this->appName, $this->request, $this->settings, $this->l10n, $this->user); } - public function testIndexAnnotations(){ - $annotations = array('NoAdminRequired', 'NoCSRFRequired'); - $this->assertAnnotations($this->controller, 'index', $annotations); - } - - public function testSettingsAnnotations(){ - $annotations = array('NoAdminRequired'); - $this->assertAnnotations($this->controller, 'settings', $annotations); - } - - public function testUpdateSettingsAnnotations(){ - $annotations = array('NoAdminRequired'); - $this->assertAnnotations($this->controller, 'updateSettings', $annotations); - } - public function testIndex(){ $response = $this->controller->index(); $this->assertEquals('main', $response->getTemplateName()); @@ -76,7 +64,7 @@ class PageControllerTest extends ControllerTestUtility { ); $this->l10n->expects($this->once()) - ->method('findLanguage') + ->method('getLanguageCode') ->will($this->returnValue('de')); $this->settings->expects($this->at(0)) ->method('getUserValue') @@ -92,18 +80,11 @@ class PageControllerTest extends ControllerTestUtility { ->will($this->returnValue('1')); $response = $this->controller->settings(); - $this->assertEquals($result, $response->getData()); + $this->assertEquals($result, $response); } public function testUpdateSettings() { - $request = $this->getRequest(array('post' => array( - 'showAll' => true, - 'compact' => true - ))); - $this->controller = new PageController($this->appName, $request, - $this->settings, $this->l10n, $this->user); - $this->settings->expects($this->at(0)) ->method('setUserValue') ->with($this->equalTo($this->user), @@ -116,16 +97,13 @@ class PageControllerTest extends ControllerTestUtility { $this->equalTo($this->appName), $this->equalTo('compact'), $this->equalTo(true)); - $this->controller->updateSettings(); + $this->controller->updateSettings(true, true); } public function testUpdateSettingsNoParameterShouldNotSetIt() { - $request = $this->getRequest(array('post' => array( - 'showAll' => true - ))); - $this->controller = new PageController($this->appName, $request, + $this->controller = new PageController($this->appName, $this->request, $this->settings, $this->l10n, $this->user); $this->settings->expects($this->once()) @@ -135,7 +113,7 @@ class PageControllerTest extends ControllerTestUtility { $this->equalTo('showAll'), $this->equalTo(true)); - $this->controller->updateSettings(); + $this->controller->updateSettings(true, null); } }
\ No newline at end of file |