diff --git a/composer.json b/composer.json index 173c0eb1..8f9b86a6 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "shlinkio/shlink-config": "dev-main#a43b380 as 3.0", "shlinkio/shlink-event-dispatcher": "dev-main#aa9023c as 4.0", "shlinkio/shlink-importer": "dev-main#65a9a30 as 5.3", - "shlinkio/shlink-installer": "dev-develop#b314455 as 9.0", + "shlinkio/shlink-installer": "dev-develop#41e433c as 9.0", "shlinkio/shlink-ip-geolocation": "dev-main#a807668 as 3.5", "shlinkio/shlink-json": "^1.1", "spiral/roadrunner": "^2023.3", diff --git a/config/autoload/installer.global.php b/config/autoload/installer.global.php index a3b477af..753bdb9a 100644 --- a/config/autoload/installer.global.php +++ b/config/autoload/installer.global.php @@ -59,6 +59,9 @@ return [ Option\QrCode\DefaultFormatConfigOption::class, Option\QrCode\DefaultErrorCorrectionConfigOption::class, Option\QrCode\DefaultRoundBlockSizeConfigOption::class, + Option\QrCode\DefaultColorConfigOption::class, + Option\QrCode\DefaultBgColorConfigOption::class, + Option\QrCode\DefaultLogoUrlConfigOption::class, Option\QrCode\EnabledForDisabledShortUrlsConfigOption::class, Option\RabbitMq\RabbitMqEnabledConfigOption::class, Option\RabbitMq\RabbitMqHostConfigOption::class, diff --git a/module/Core/test/Action/QrCodeActionTest.php b/module/Core/test/Action/QrCodeActionTest.php index 63f26b3f..08564bf9 100644 --- a/module/Core/test/Action/QrCodeActionTest.php +++ b/module/Core/test/Action/QrCodeActionTest.php @@ -293,6 +293,27 @@ class QrCodeActionTest extends TestCase ); } + #[Test] + public function logoIsAddedToQrCodeIfOptionIsDefined(): void + { + $logoUrl = 'https://avatars.githubusercontent.com/u/20341790?v=4'; // Shlink logo + $code = 'abc123'; + $req = ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $code); + + $this->urlResolver->method('resolveEnabledShortUrl')->with( + ShortUrlIdentifier::fromShortCodeAndDomain($code), + )->willReturn(ShortUrl::withLongUrl('https://shlink.io')); + $handler = $this->createMock(RequestHandlerInterface::class); + + $resp = $this->action(new QrCodeOptions(size: 250, logoUrl: $logoUrl))->process($req, $handler); + $image = imagecreatefromstring($resp->getBody()->__toString()); + self::assertNotFalse($image); + + // At around 100x100 px we can already find the logo, which has Shlink's brand color + $resultingColor = imagecolorat($image, 100, 100); + self::assertEquals(hexdec('4696E5'), $resultingColor); + } + public static function provideEnabled(): iterable { yield 'always enabled' => [true];