diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-08-10 11:21:43 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-08-10 12:37:57 +0200 |
commit | 986dffdae45402b9642f51565c608cb7d85ac817 (patch) | |
tree | 02adb72d20964f157443ef2a2fdcbc45b931abe5 /apps/theming | |
parent | d7e45d45c423a3b58467309fbee4592bd0d924c6 (diff) | |
download | nextcloud-server-986dffdae45402b9642f51565c608cb7d85ac817.tar.gz nextcloud-server-986dffdae45402b9642f51565c608cb7d85ac817.zip |
Split updateStylesheet tests for success and error
This is a preparatory step for a following commit in which the
properties present in the response will change depending on whether the
request was successful or not.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/theming')
-rw-r--r-- | apps/theming/tests/Controller/ThemingControllerTest.php | 68 |
1 files changed, 51 insertions, 17 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index a5a8798217d..960ce03b139 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -102,33 +102,67 @@ class ThemingControllerTest extends TestCase { return parent::setUp(); } - public function dataUpdateStylesheet() { + public function dataUpdateStylesheetSuccess() { return [ - ['name', str_repeat('a', 250), 'success', 'Saved'], - ['name', str_repeat('a', 251), 'error', 'The given name is too long'], - ['url', str_repeat('a', 500), 'success', 'Saved'], - ['url', str_repeat('a', 501), 'error', 'The given web address is too long'], - ['slogan', str_repeat('a', 500), 'success', 'Saved'], - ['slogan', str_repeat('a', 501), 'error', 'The given slogan is too long'], - ['color', '#0082c9', 'success', 'Saved'], - ['color', '#0082C9', 'success', 'Saved'], - ['color', '0082C9', 'error', 'The given color is invalid'], - ['color', '#0082Z9', 'error', 'The given color is invalid'], - ['color', 'Nextcloud', 'error', 'The given color is invalid'], + ['name', str_repeat('a', 250), 'Saved'], + ['url', str_repeat('a', 500), 'Saved'], + ['slogan', str_repeat('a', 500), 'Saved'], + ['color', '#0082c9', 'Saved'], + ['color', '#0082C9', 'Saved'], ]; } /** - * @dataProvider dataUpdateStylesheet + * @dataProvider dataUpdateStylesheetSuccess * * @param string $setting * @param string $value - * @param string $status * @param string $message */ - public function testUpdateStylesheet($setting, $value, $status, $message) { + public function testUpdateStylesheetSuccess($setting, $value, $message) { $this->themingDefaults - ->expects($status === 'success' ? $this->once() : $this->never()) + ->expects($this->once()) + ->method('set') + ->with($setting, $value); + $this->l10n + ->expects($this->once()) + ->method('t') + ->with($message) + ->willReturn($message); + + $expected = new DataResponse( + [ + 'data' => + [ + 'message' => $message, + ], + 'status' => 'success', + ] + ); + $this->assertEquals($expected, $this->themingController->updateStylesheet($setting, $value)); + } + + public function dataUpdateStylesheetError() { + return [ + ['name', str_repeat('a', 251), 'The given name is too long'], + ['url', str_repeat('a', 501), 'The given web address is too long'], + ['slogan', str_repeat('a', 501), 'The given slogan is too long'], + ['color', '0082C9', 'The given color is invalid'], + ['color', '#0082Z9', 'The given color is invalid'], + ['color', 'Nextcloud', 'The given color is invalid'], + ]; + } + + /** + * @dataProvider dataUpdateStylesheetError + * + * @param string $setting + * @param string $value + * @param string $message + */ + public function testUpdateStylesheetError($setting, $value, $message) { + $this->themingDefaults + ->expects($this->never()) ->method('set') ->with($setting, $value); $this->l10n @@ -143,7 +177,7 @@ class ThemingControllerTest extends TestCase { [ 'message' => $message, ], - 'status' => $status, + 'status' => 'error', ] ); $this->assertEquals($expected, $this->themingController->updateStylesheet($setting, $value)); |