diff options
-rw-r--r-- | controller/pagecontroller.php | 14 | ||||
-rw-r--r-- | tests/unit/controller/PageControllerTest.php | 17 |
2 files changed, 27 insertions, 4 deletions
diff --git a/controller/pagecontroller.php b/controller/pagecontroller.php index 4acc5f9e6..137dcf514 100644 --- a/controller/pagecontroller.php +++ b/controller/pagecontroller.php @@ -72,10 +72,16 @@ class PageController extends Controller { * @NoAdminRequired */ public function updateSettings() { - $isShowAll = $this->params('showAll'); - $isCompact = $this->params('compact'); - $this->api->setUserValue('showAll', $isShowAll); - $this->api->setUserValue('compact', $isCompact); + $isShowAll = $this->params('showAll', null); + $isCompact = $this->params('compact', null); + + if($isShowAll !== null) { + $this->api->setUserValue('showAll', $isShowAll); + } + + if($isCompact !== null) { + $this->api->setUserValue('compact', $isCompact); + } return new JSONResponse(); } diff --git a/tests/unit/controller/PageControllerTest.php b/tests/unit/controller/PageControllerTest.php index a2b9b6e16..ff229c79b 100644 --- a/tests/unit/controller/PageControllerTest.php +++ b/tests/unit/controller/PageControllerTest.php @@ -123,4 +123,21 @@ class PageControllerTest extends ControllerTestUtility { $this->assertTrue($response instanceof JSONResponse); } + + + public function testUpdateSettingsNoParameterShouldNotSetIt() { + $request = $this->getRequest(array('post' => array( + 'showAll' => true + ))); + $this->controller = new PageController($this->api, $request); + + $this->api->expects($this->once()) + ->method('setUserValue') + ->with($this->equalTo('showAll'), + $this->equalTo(true)); + + $response = $this->controller->updateSettings(); + + $this->assertTrue($response instanceof JSONResponse); + } }
\ No newline at end of file |