mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-24 13:49:03 +03:00
Added tests for new QR code format
This commit is contained in:
parent
55d9f2a4a1
commit
4b7184ac85
1 changed files with 26 additions and 0 deletions
|
@ -81,4 +81,30 @@ class QrCodeActionTest extends TestCase
|
|||
$this->assertEquals(200, $resp->getStatusCode());
|
||||
$delegate->handle(Argument::any())->shouldHaveBeenCalledTimes(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideQueries
|
||||
*/
|
||||
public function imageIsReturnedWithExpectedContentTypeBasedOnProvidedFormat(
|
||||
array $query,
|
||||
string $expectedContentType
|
||||
): void {
|
||||
$code = 'abc123';
|
||||
$this->urlResolver->resolveEnabledShortUrl(new ShortUrlIdentifier($code, ''))->willReturn(new ShortUrl(''));
|
||||
$delegate = $this->prophesize(RequestHandlerInterface::class);
|
||||
$req = (new ServerRequest())->withAttribute('shortCode', $code)->withQueryParams($query);
|
||||
|
||||
$resp = $this->action->process($req, $delegate->reveal());
|
||||
|
||||
$this->assertEquals($expectedContentType, $resp->getHeaderLine('Content-Type'));
|
||||
}
|
||||
|
||||
public function provideQueries(): iterable
|
||||
{
|
||||
yield 'no format' => [[], 'image/png'];
|
||||
yield 'png format' => [['format' => 'png'], 'image/png'];
|
||||
yield 'svg format' => [['format' => 'svg'], 'image/svg+xml'];
|
||||
yield 'unsupported format' => [['format' => 'jpg'], 'image/png'];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue