Browse Source

ThemingDefaults append cacheBusterCounter to logo URL by default

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
tags/v12.0.0beta1
Morris Jobke 7 years ago
parent
commit
d83c8e0271
No account linked to committer's email address
2 changed files with 18 additions and 15 deletions
  1. 4
    11
      apps/theming/lib/ThemingDefaults.php
  2. 14
    4
      apps/theming/tests/ThemingDefaultsTest.php

+ 4
- 11
apps/theming/lib/ThemingDefaults.php View File

$logoExists = false; $logoExists = false;
} }


$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');

if(!$logo || !$logoExists) { 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;
} }


/** /**
return $value; 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 * Increases the cache buster key
*/ */

+ 14
- 4
apps/theming/tests/ThemingDefaultsTest.php View File



public function testGetLogoDefault() { public function testGetLogoDefault() {
$this->config $this->config
->expects($this->once())
->expects($this->at(0))
->method('getAppValue') ->method('getAppValue')
->with('theming', 'logoMime') ->with('theming', 'logoMime')
->willReturn(''); ->willReturn('');
$this->config
->expects($this->at(1))
->method('getAppValue')
->with('theming', 'cachebuster', '0')
->willReturn('0');
$this->appData $this->appData
->expects($this->once()) ->expects($this->once())
->method('getFolder') ->method('getFolder')
->with('images') ->with('images')
->willThrowException(new \Exception()); ->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()); $this->assertEquals($expected, $this->template->getLogo());
} }


public function testGetLogoCustom() { public function testGetLogoCustom() {
$this->config $this->config
->expects($this->once())
->expects($this->at(0))
->method('getAppValue') ->method('getAppValue')
->with('theming', 'logoMime') ->with('theming', 'logoMime')
->willReturn('image/svg+xml'); ->willReturn('image/svg+xml');
$this->config
->expects($this->at(1))
->method('getAppValue')
->with('theming', 'cachebuster', '0')
->willReturn('0');
$simpleFolder = $this->createMock(ISimpleFolder::class); $simpleFolder = $this->createMock(ISimpleFolder::class);
$this->appData $this->appData
->expects($this->once()) ->expects($this->once())
->method('getFile') ->method('getFile')
->with('logo') ->with('logo')
->willReturn(''); ->willReturn('');
$expected = $this->urlGenerator->linkToRoute('theming.Theming.getLogo');
$expected = $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=0';
$this->assertEquals($expected, $this->template->getLogo()); $this->assertEquals($expected, $this->template->getLogo());
} }
} }

Loading…
Cancel
Save