diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index a5a8798217..960ce03b13 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -102,33 +102,26 @@ 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 @@ -143,7 +136,48 @@ class ThemingControllerTest extends TestCase { [ 'message' => $message, ], - 'status' => $status, + '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 + ->expects($this->once()) + ->method('t') + ->with($message) + ->willReturn($message); + + $expected = new DataResponse( + [ + 'data' => + [ + 'message' => $message, + ], + 'status' => 'error', ] ); $this->assertEquals($expected, $this->themingController->updateStylesheet($setting, $value));