Optimize chek if background is themed
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
691409cdec
commit
a0c0918ce2
|
@ -250,13 +250,6 @@ class Util {
|
|||
|
||||
public function isBackgroundThemed() {
|
||||
$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', '');
|
||||
|
||||
$backgroundExists = true;
|
||||
try {
|
||||
$this->appData->getFolder('images')->getFile('background');
|
||||
} catch (\Exception $e) {
|
||||
$backgroundExists = false;
|
||||
}
|
||||
return $backgroundLogo && $backgroundLogo !== 'backgroundColor' && $backgroundExists;
|
||||
return $backgroundLogo !== '' && $backgroundLogo !== 'backgroundColor';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,32 +216,19 @@ class UtilTest extends TestCase {
|
|||
|
||||
public function dataIsBackgroundThemed() {
|
||||
return [
|
||||
[false, false, false],
|
||||
['png', true, true],
|
||||
['backgroundColor', false, false],
|
||||
['', false],
|
||||
['png', true],
|
||||
['backgroundColor', false],
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @dataProvider dataIsBackgroundThemed
|
||||
*/
|
||||
public function testIsBackgroundThemed($backgroundMime, $fileFound, $expected) {
|
||||
public function testIsBackgroundThemed($backgroundMime, $expected) {
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('theming', 'backgroundMime', false)
|
||||
->with('theming', 'backgroundMime', '')
|
||||
->willReturn($backgroundMime);
|
||||
$folder = $this->createMock(ISimpleFolder::class);
|
||||
if ($fileFound) {
|
||||
$folder->expects($this->once())
|
||||
->method('getFile')
|
||||
->willReturn($this->createMock(ISimpleFile::class));
|
||||
} else {
|
||||
$folder->expects($this->once())
|
||||
->method('getFile')
|
||||
->willThrowException(new NotFoundException());
|
||||
}
|
||||
$this->appData->expects($this->once())
|
||||
->method('getFolder')
|
||||
->willReturn($folder);
|
||||
$this->assertEquals($expected, $this->util->isBackgroundThemed());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue