diff options
author | Joas Schilling <coding@schilljs.com> | 2025-05-20 22:28:10 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2025-05-20 23:41:45 +0200 |
commit | c75dd573d454a11e0bf77161e240c367adeca215 (patch) | |
tree | 85247213494bd700cbfa928b751cc45a3cc76423 | |
parent | 05492c21d87d0adbac5d5228ad57c742cc3980ff (diff) | |
download | nextcloud-server-backport/53005/stable30.tar.gz nextcloud-server-backport/53005/stable30.zip |
fix(theming): Instead of expecting a warning handle it properlybackport/53005/stable30
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | apps/theming/lib/IconBuilder.php | 15 | ||||
-rw-r--r-- | apps/theming/tests/IconBuilderTest.php | 10 |
2 files changed, 10 insertions, 15 deletions
diff --git a/apps/theming/lib/IconBuilder.php b/apps/theming/lib/IconBuilder.php index a2db2860b5d..d72da831a86 100644 --- a/apps/theming/lib/IconBuilder.php +++ b/apps/theming/lib/IconBuilder.php @@ -101,18 +101,17 @@ class IconBuilder { * Render app icon on themed background color * fallback to logo * - * @param $app string app name - * @param $size int size of the icon in px + * @param string $app app name + * @param int $size size of the icon in px * @return Imagick|false */ public function renderAppIcon($app, $size) { $appIcon = $this->util->getAppIcon($app); - if ($appIcon === false) { - return false; - } if ($appIcon instanceof ISimpleFile) { $appIconContent = $appIcon->getContent(); $mime = $appIcon->getMimeType(); + } elseif (!file_exists($appIcon)) { + return false; } else { $appIconContent = file_get_contents($appIcon); $mime = mime_content_type($appIcon); @@ -198,13 +197,13 @@ class IconBuilder { } /** - * @param $app string app name - * @param $image string relative path to svg file in app directory + * @param string $app app name + * @param string $image relative path to svg file in app directory * @return string|false content of a colorized svg file */ public function colorSvg($app, $image) { $imageFile = $this->util->getAppImage($app, $image); - if ($imageFile === false || $imageFile === '') { + if ($imageFile === false || $imageFile === '' || !file_exists($imageFile)) { return false; } $svg = file_get_contents($imageFile); diff --git a/apps/theming/tests/IconBuilderTest.php b/apps/theming/tests/IconBuilderTest.php index a2058e9dd40..ac1f9afb4e8 100644 --- a/apps/theming/tests/IconBuilderTest.php +++ b/apps/theming/tests/IconBuilderTest.php @@ -14,7 +14,6 @@ use OCA\Theming\Util; use OCP\App\IAppManager; use OCP\Files\NotFoundException; use OCP\IConfig; -use PHPUnit\Framework\Error\Warning; use Test\TestCase; class IconBuilderTest extends TestCase { @@ -165,8 +164,7 @@ class IconBuilderTest extends TestCase { public function testGetFaviconNotFound() { $this->checkImagick(); - $this->expectWarning(Warning::class); - $util = $this->getMockBuilder(Util::class)->disableOriginalConstructor()->getMock(); + $util = $this->createMock(Util::class); $iconBuilder = new IconBuilder($this->themingDefaults, $util, $this->imageManager); $this->imageManager->expects($this->once()) ->method('shouldReplaceIcons') @@ -179,8 +177,7 @@ class IconBuilderTest extends TestCase { public function testGetTouchIconNotFound() { $this->checkImagick(); - $this->expectWarning(Warning::class); - $util = $this->getMockBuilder(Util::class)->disableOriginalConstructor()->getMock(); + $util = $this->createMock(Util::class); $iconBuilder = new IconBuilder($this->themingDefaults, $util, $this->imageManager); $util->expects($this->once()) ->method('getAppIcon') @@ -190,8 +187,7 @@ class IconBuilderTest extends TestCase { public function testColorSvgNotFound() { $this->checkImagick(); - $this->expectWarning(Warning::class); - $util = $this->getMockBuilder(Util::class)->disableOriginalConstructor()->getMock(); + $util = $this->createMock(Util::class); $iconBuilder = new IconBuilder($this->themingDefaults, $util, $this->imageManager); $util->expects($this->once()) ->method('getAppImage') |