diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-11-23 15:48:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-23 15:48:57 +0100 |
commit | 5d88686b184ad9aca7c68d2a1a37da0dcef8fc97 (patch) | |
tree | 3ab7fde1c5ef0b16796e59db19bad6d685f022b8 | |
parent | a3cff5abbedb4ee3823786e6d62ec767c50db192 (diff) | |
parent | a0c0918ce24f7bb7ea3fc58b0ca0f677ab0c3384 (diff) | |
download | nextcloud-server-5d88686b184ad9aca7c68d2a1a37da0dcef8fc97.tar.gz nextcloud-server-5d88686b184ad9aca7c68d2a1a37da0dcef8fc97.zip |
Merge pull request #24310 from nextcloud/perf/noid/theming-capabilities
Optimize check if background is themed
-rw-r--r-- | apps/theming/lib/Util.php | 9 | ||||
-rw-r--r-- | apps/theming/tests/UtilTest.php | 23 |
2 files changed, 6 insertions, 26 deletions
diff --git a/apps/theming/lib/Util.php b/apps/theming/lib/Util.php index e757d100a1b..57a90b026e8 100644 --- a/apps/theming/lib/Util.php +++ b/apps/theming/lib/Util.php @@ -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'; } } diff --git a/apps/theming/tests/UtilTest.php b/apps/theming/tests/UtilTest.php index 10013e7d61c..d6fe318cbca 100644 --- a/apps/theming/tests/UtilTest.php +++ b/apps/theming/tests/UtilTest.php @@ -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()); } } |