Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions apps/theming/lib/IconBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,17 @@ public function getTouchIcon($app) {
* 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);
Expand Down Expand Up @@ -187,13 +186,13 @@ public function renderAppIcon($app, $size) {
}

/**
* @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);
Expand Down
10 changes: 3 additions & 7 deletions apps/theming/tests/IconBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\ServerVersion;
use PHPUnit\Framework\Error\Warning;
use Test\TestCase;

class IconBuilderTest extends TestCase {
Expand Down Expand Up @@ -165,8 +164,7 @@ public function testGetFavicon($app, $color, $file): void {

public function testGetFaviconNotFound(): void {
$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')
Expand All @@ -179,8 +177,7 @@ public function testGetFaviconNotFound(): void {

public function testGetTouchIconNotFound(): void {
$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')
Expand All @@ -190,8 +187,7 @@ public function testGetTouchIconNotFound(): void {

public function testColorSvgNotFound(): void {
$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')
Expand Down
Loading