]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix tests for theming backgroundColor
authorJulius Härtl <jus@bitgrid.net>
Mon, 1 May 2017 08:42:19 +0000 (10:42 +0200)
committerJulius Härtl <jus@bitgrid.net>
Mon, 8 May 2017 08:16:30 +0000 (10:16 +0200)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
apps/theming/lib/Controller/ThemingController.php
apps/theming/tests/Controller/ThemingControllerTest.php
apps/theming/tests/ThemingDefaultsTest.php

index 1b3420f3cb71d143f525100e2033afbaccc82c35..225673079a3f6aa04b0d83c92a0dd3eff000a8fe 100644 (file)
@@ -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(
index f22c317d73d6101fe007ab2d54c03df5432e4239..cbdb86d03587e7c18537aa539ddcb5ed278c2b90 100644 (file)
@@ -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([
index 7535eddb4f02028e7d3bcb69c6eeef6f8e1a3e83..e3acab78bb70bb0615c63b7be269d0c0afff8ea0 100644 (file)
@@ -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());