mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-24 18:00:17 -06:00
Add test for QrCodeAction with logo URL
This commit is contained in:
parent
689343d1c9
commit
23e9ed93bb
@ -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",
|
||||
|
@ -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,
|
||||
|
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user