]> source.dussan.org Git - nextcloud-server.git/commitdiff
ThemingDefaults append cacheBusterCounter to logo URL by default 4256/head
authorMorris Jobke <hey@morrisjobke.de>
Sun, 9 Apr 2017 01:48:57 +0000 (20:48 -0500)
committerMorris Jobke <hey@morrisjobke.de>
Mon, 10 Apr 2017 02:43:09 +0000 (21:43 -0500)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
apps/theming/lib/ThemingDefaults.php
apps/theming/tests/ThemingDefaultsTest.php

index d4dc56d3ba9000ae00071a286f6d7676a727ffee..073410da2c3d2ed1e12a0d55ef48e8141b2bfc69 100644 (file)
@@ -138,11 +138,13 @@ class ThemingDefaults extends \OC_Defaults {
                        $logoExists = false;
                }
 
+               $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
+
                if(!$logo || !$logoExists) {
-                       return $this->urlGenerator->imagePath('core','logo.svg');
+                       return $this->urlGenerator->imagePath('core','logo.svg') . '?v=' . $cacheBusterCounter;
                }
 
-               return $this->urlGenerator->linkToRoute('theming.Theming.getLogo');
+               return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter;
        }
 
        /**
@@ -190,15 +192,6 @@ class ThemingDefaults extends \OC_Defaults {
                return $value;
        }
 
-       /**
-        * Gets the current cache buster count
-        *
-        * @return string
-        */
-       public function getCacheBusterCounter() {
-               return $this->config->getAppValue('theming', 'cachebuster', '0');
-       }
-
        /**
         * Increases the cache buster key
         */
index 986b2f342674e2e3765c36e01e788fbf59f0516f..ad8f86f1c1396be4005b29134bc04b45ad074ac0 100644 (file)
@@ -417,25 +417,35 @@ class ThemingDefaultsTest extends TestCase {
 
        public function testGetLogoDefault() {
                $this->config
-                       ->expects($this->once())
+                       ->expects($this->at(0))
                        ->method('getAppValue')
                        ->with('theming', 'logoMime')
                        ->willReturn('');
+               $this->config
+                       ->expects($this->at(1))
+                       ->method('getAppValue')
+                       ->with('theming', 'cachebuster', '0')
+                       ->willReturn('0');
                $this->appData
                        ->expects($this->once())
                        ->method('getFolder')
                        ->with('images')
                        ->willThrowException(new \Exception());
-               $expected = $this->urlGenerator->imagePath('core','logo.svg');
+               $expected = $this->urlGenerator->imagePath('core','logo.svg') . '?v=0';
                $this->assertEquals($expected, $this->template->getLogo());
        }
 
        public function testGetLogoCustom() {
                $this->config
-                       ->expects($this->once())
+                       ->expects($this->at(0))
                        ->method('getAppValue')
                        ->with('theming', 'logoMime')
                        ->willReturn('image/svg+xml');
+               $this->config
+                       ->expects($this->at(1))
+                       ->method('getAppValue')
+                       ->with('theming', 'cachebuster', '0')
+                       ->willReturn('0');
                $simpleFolder = $this->createMock(ISimpleFolder::class);
                $this->appData
                        ->expects($this->once())
@@ -447,7 +457,7 @@ class ThemingDefaultsTest extends TestCase {
                        ->method('getFile')
                        ->with('logo')
                        ->willReturn('');
-               $expected = $this->urlGenerator->linkToRoute('theming.Theming.getLogo');
+               $expected = $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=0';
                $this->assertEquals($expected, $this->template->getLogo());
        }
 }