From 28d28d8c9eb5ed9f184b572cfd16994c024e4227 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 19 Dec 2013 14:09:59 +0100 Subject: add serverside infrastructure for setting and remembering compact view --- .../unit/controller/UserSettingsControllerTest.php | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'tests') diff --git a/tests/unit/controller/UserSettingsControllerTest.php b/tests/unit/controller/UserSettingsControllerTest.php index 421d45566..cdbebcf1f 100644 --- a/tests/unit/controller/UserSettingsControllerTest.php +++ b/tests/unit/controller/UserSettingsControllerTest.php @@ -63,6 +63,14 @@ class UserSettingsControllerTest extends ControllerTestUtility { $this->assertUserSettingsControllerAnnotations('getLanguage'); } + public function testIsCompactViewAnnotations(){ + $this->assertUserSettingsControllerAnnotations('isCompactView'); + } + + public function testSetCompactViewAnnotations(){ + $this->assertUserSettingsControllerAnnotations('setCompactView'); + } + public function testFoldersAnnotations(){ $this->assertUserSettingsControllerAnnotations('read'); @@ -132,4 +140,47 @@ class UserSettingsControllerTest extends ControllerTestUtility { } + public function testIsCompactView() { + $result = array( + 'compact' => true + ); + $this->api->expects($this->once()) + ->method('getUserValue') + ->with($this->equalTo('compact')) + ->will($this->returnValue('1')); + + $response = $this->controller->isCompactView(); + $this->assertEquals($result, $response->getParams()); + $this->assertTrue($response instanceof JSONResponse); + } + + + public function testUnsetCompactView(){ + $request = new Request(array('post' => array( + 'compact' => false + ))); + $this->controller = new UserSettingsController($this->api, $request); + + $this->api->expects($this->once()) + ->method('setUserValue') + ->with($this->equalTo('compact'), + $this->equalTo(false)); + $response = $this->controller->setCompactView(); + $this->assertTrue($response instanceof JSONResponse); + } + + public function testSetCompactView(){ + $request = new Request(array('post' => array( + 'compact' => true + ))); + $this->controller = new UserSettingsController($this->api, $request); + + $this->api->expects($this->once()) + ->method('setUserValue') + ->with($this->equalTo('compact'), + $this->equalTo(true)); + $response = $this->controller->setCompactView(); + $this->assertTrue($response instanceof JSONResponse); + } + } \ No newline at end of file -- cgit v1.2.3