diff options
author | Julius Härtl <jus@bitgrid.net> | 2017-05-01 10:42:19 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2017-05-08 10:16:30 +0200 |
commit | 510f7cf1b6b94be7ee640b9e139e536cbc7d23fb (patch) | |
tree | 7df7dddcf7bfc61f7021dcbd83108bdf0e2effd0 /apps | |
parent | 4199a569127699cc893416bf47ece5a8d28a18a3 (diff) | |
download | nextcloud-server-510f7cf1b6b94be7ee640b9e139e536cbc7d23fb.tar.gz nextcloud-server-510f7cf1b6b94be7ee640b9e139e536cbc7d23fb.zip |
Fix tests for theming backgroundColor
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/theming/lib/Controller/ThemingController.php | 2 | ||||
-rw-r--r-- | apps/theming/tests/Controller/ThemingControllerTest.php | 51 | ||||
-rw-r--r-- | apps/theming/tests/ThemingDefaultsTest.php | 3 |
3 files changed, 50 insertions, 6 deletions
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php index 1b3420f3cb7..225673079a3 100644 --- a/apps/theming/lib/Controller/ThemingController.php +++ b/apps/theming/lib/Controller/ThemingController.php @@ -185,7 +185,7 @@ class ThemingController extends Controller { * @return DataResponse */ public function updateLogo() { - $backgroundColor = $this->request->getParam('backgroundColor'); + $backgroundColor = $this->request->getParam('backgroundColor', false); if($backgroundColor) { $this->themingDefaults->set('backgroundMime', 'backgroundColor'); return new DataResponse( diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index f22c317d73d..cbdb86d0358 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -152,11 +152,16 @@ class ThemingControllerTest extends TestCase { public function testUpdateLogoNoData() { $this->request ->expects($this->at(0)) + ->method('getParam') + ->with('backgroundColor') + ->willReturn(false); + $this->request + ->expects($this->at(1)) ->method('getUploadedFile') ->with('uploadlogo') ->willReturn(null); $this->request - ->expects($this->at(1)) + ->expects($this->at(2)) ->method('getUploadedFile') ->with('upload-login-background') ->willReturn(null); @@ -179,6 +184,29 @@ class ThemingControllerTest extends TestCase { $this->assertEquals($expected, $this->themingController->updateLogo()); } + public function testUpdateBackgroundColor() { + $this->request + ->expects($this->at(0)) + ->method('getParam') + ->with('backgroundColor') + ->willReturn(true); + $this->themingDefaults + ->expects($this->once()) + ->method('set') + ->with('backgroundMime', 'backgroundColor'); + $expected = new DataResponse( + [ + 'data' => + [ + 'name' => 'backgroundColor', + 'message' => $this->l10n->t('Saved') + ], + 'status' => 'success' + ] + ); + $this->assertEquals($expected, $this->themingController->updateLogo()); + } + public function dataUpdateImages() { return [ [false], @@ -194,6 +222,11 @@ class ThemingControllerTest extends TestCase { touch($tmpLogo); $this->request ->expects($this->at(0)) + ->method('getParam') + ->with('backgroundColor') + ->willReturn(false); + $this->request + ->expects($this->at(1)) ->method('getUploadedFile') ->with('uploadlogo') ->willReturn([ @@ -202,7 +235,7 @@ class ThemingControllerTest extends TestCase { 'name' => 'logo.svg', ]); $this->request - ->expects($this->at(1)) + ->expects($this->at(2)) ->method('getUploadedFile') ->with('upload-login-background') ->willReturn(null); @@ -259,11 +292,16 @@ class ThemingControllerTest extends TestCase { file_put_contents($tmpLogo, file_get_contents(__DIR__ . '/../../../../tests/data/desktopapp.png')); $this->request ->expects($this->at(0)) + ->method('getParam') + ->with('backgroundColor') + ->willReturn(false); + $this->request + ->expects($this->at(1)) ->method('getUploadedFile') ->with('uploadlogo') ->willReturn(null); $this->request - ->expects($this->at(1)) + ->expects($this->at(2)) ->method('getUploadedFile') ->with('upload-login-background') ->willReturn([ @@ -322,11 +360,16 @@ class ThemingControllerTest extends TestCase { file_put_contents($tmpLogo, file_get_contents(__DIR__ . '/../../../../tests/data/data.zip')); $this->request ->expects($this->at(0)) + ->method('getParam') + ->with('backgroundColor') + ->willReturn(false); + $this->request + ->expects($this->at(1)) ->method('getUploadedFile') ->with('uploadlogo') ->willReturn(null); $this->request - ->expects($this->at(1)) + ->expects($this->at(2)) ->method('getUploadedFile') ->with('upload-login-background') ->willReturn([ diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index 7535eddb4f0..e3acab78bb7 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -525,7 +525,8 @@ class ThemingDefaultsTest extends TestCase { 'image-logo' => "'absolute-custom-logo?v=0'", 'image-login-background' => "'absolute-custom-background?v=0'", 'color-primary' => $this->defaults->getColorPrimary(), - 'color-primary-text' => '#ffffff' + 'color-primary-text' => '#ffffff', + 'image-login-plain' => 'false' ]; $this->assertEquals($expected, $this->template->getScssVariables()); |