mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 09:43:13 +08:00
Add logic to dynamically resolve the long URL to redirect to based on requesting device
This commit is contained in:
38
module/Core/test-api/Action/RedirectTest.php
Normal file
38
module/Core/test-api/Action/RedirectTest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioApiTest\Shlink\Core\Action;
|
||||
|
||||
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
|
||||
|
||||
use const ShlinkioTest\Shlink\ANDROID_USER_AGENT;
|
||||
use const ShlinkioTest\Shlink\DESKTOP_USER_AGENT;
|
||||
use const ShlinkioTest\Shlink\IOS_USER_AGENT;
|
||||
|
||||
class RedirectTest extends ApiTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideUserAgents
|
||||
*/
|
||||
public function properRedirectHappensBasedOnUserAgent(?string $userAgent, string $expectedRedirect): void
|
||||
{
|
||||
$response = $this->callShortUrl('def456', $userAgent);
|
||||
self::assertEquals($expectedRedirect, $response->getHeaderLine('Location'));
|
||||
}
|
||||
|
||||
public function provideUserAgents(): iterable
|
||||
{
|
||||
yield 'android' => [ANDROID_USER_AGENT, 'https://blog.alejandrocelaya.com/android'];
|
||||
yield 'ios' => [IOS_USER_AGENT, 'https://blog.alejandrocelaya.com/ios'];
|
||||
yield 'desktop' => [
|
||||
DESKTOP_USER_AGENT,
|
||||
'https://blog.alejandrocelaya.com/2017/12/09/acmailer-7-0-the-most-important-release-in-a-long-time/',
|
||||
];
|
||||
yield 'unknown' => [
|
||||
null,
|
||||
'https://blog.alejandrocelaya.com/2017/12/09/acmailer-7-0-the-most-important-release-in-a-long-time/',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user