ThemingDefaults append cacheBusterCounter to logo URL by default

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2017-04-08 20:48:57 -05:00
parent 5b4adf66e5
commit d83c8e0271
No known key found for this signature in database
GPG Key ID: 9CE5ED29E7FCD38A
2 changed files with 18 additions and 15 deletions

View 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
*/

View 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());
}
}