mirror of
https://github.com/nextcloud/server.git
synced 2026-05-19 08:25:56 -04:00
fix(theming): Instead of expecting a warning handle it properly
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
05492c21d8
commit
c75dd573d4
2 changed files with 10 additions and 15 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue