From 5560d932fb14c6dbe360eab42841b7685214940e Mon Sep 17 00:00:00 2001 From: Simon L Date: Fri, 12 Jun 2026 17:05:35 +0200 Subject: [PATCH] fix(theming): preserve uploaded favicon and touch icon add some unit tests for favicon and touchicon Assisted-by: ClaudeCode:claude-opus-4-8 Signed-off-by: Simon L. --- .../tests/Controller/IconControllerTest.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php index 018947d4a67e9..aaa0a389a5655 100644 --- a/apps/theming/tests/Controller/IconControllerTest.php +++ b/apps/theming/tests/Controller/IconControllerTest.php @@ -166,6 +166,42 @@ public function testGetTouchIconDefault(): void { $this->assertEquals($expected, $this->iconController->getTouchIcon()); } + public function testGetFaviconUploaded(): void { + // a custom favicon was uploaded, so it must be served as-is and the + // app-specific generation path must not overwrite it + $file = $this->iconFileMock('favicon.ico', 'filecontent'); + $this->imageManager->expects($this->once()) + ->method('getImage') + ->with('favicon', false) + ->willReturn($file); + $this->imageManager->expects($this->never()) + ->method('getCachedImage'); + $this->iconBuilder->expects($this->never()) + ->method('getFavicon'); + + $expected = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']); + $expected->cacheFor(86400); + $this->assertEquals($expected, $this->iconController->getFavicon()); + } + + public function testGetTouchIconUploaded(): void { + // a custom favicon was uploaded, so it must be served as-is and the + // app-specific generation path must not overwrite it + $file = $this->iconFileMock('favicon.png', 'filecontent'); + $this->imageManager->expects($this->once()) + ->method('getImage') + ->with('favicon') + ->willReturn($file); + $this->imageManager->expects($this->never()) + ->method('getCachedImage'); + $this->iconBuilder->expects($this->never()) + ->method('getTouchIcon'); + + $expected = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']); + $expected->cacheFor(86400); + $this->assertEquals($expected, $this->iconController->getTouchIcon()); + } + public function testGetTouchIconFail(): void { $this->imageManager->expects($this->once()) ->method('getImage')