mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Created ShortUrlRedirectBuilder test
This commit is contained in:
parent
d4cad337fc
commit
fe5460e0c5
@ -85,10 +85,6 @@ class RedirectActionTest extends TestCase
|
|||||||
yield [['foobar' => 'notrack']];
|
yield [['foobar' => 'notrack']];
|
||||||
yield [['foobar' => 'barfoo']];
|
yield [['foobar' => 'barfoo']];
|
||||||
yield [['foobar' => null]];
|
yield [['foobar' => null]];
|
||||||
// yield ['http://domain.com/foo/bar?some=thing&else', ['else' => null]];
|
|
||||||
// yield ['http://domain.com/foo/bar?some=thing&foo=bar', ['foo' => 'bar']];
|
|
||||||
// yield ['http://domain.com/foo/bar?some=overwritten&foo=bar', ['foo' => 'bar', 'some' => 'overwritten']];
|
|
||||||
// yield ['http://domain.com/foo/bar?some=overwritten', ['foobar' => 'notrack', 'some' => 'overwritten']];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace ShlinkioTest\Shlink\Core\ShortUrl\Helper;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||||
|
use Shlinkio\Shlink\Core\Options\TrackingOptions;
|
||||||
|
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlRedirectionBuilder;
|
||||||
|
|
||||||
|
class ShortUrlRedirectionBuilderTest extends TestCase
|
||||||
|
{
|
||||||
|
private ShortUrlRedirectionBuilder $redirectionBuilder;
|
||||||
|
private TrackingOptions $trackingOptions;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
$this->trackingOptions = new TrackingOptions(['disable_track_param' => 'foobar']);
|
||||||
|
$this->redirectionBuilder = new ShortUrlRedirectionBuilder($this->trackingOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @dataProvider provideData
|
||||||
|
*/
|
||||||
|
public function buildShortUrlRedirectBuildsExpectedUrl(string $expectedUrl, array $query, ?string $extraPath): void
|
||||||
|
{
|
||||||
|
$shortUrl = ShortUrl::withLongUrl('https://domain.com/foo/bar?some=thing');
|
||||||
|
$result = $this->redirectionBuilder->buildShortUrlRedirect($shortUrl, $query, $extraPath);
|
||||||
|
|
||||||
|
self::assertEquals($expectedUrl, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideData(): iterable
|
||||||
|
{
|
||||||
|
yield ['https://domain.com/foo/bar?some=thing', [], null];
|
||||||
|
yield ['https://domain.com/foo/bar?some=thing&else', ['else' => null], null];
|
||||||
|
yield ['https://domain.com/foo/bar?some=thing&foo=bar', ['foo' => 'bar'], null];
|
||||||
|
yield ['https://domain.com/foo/bar?some=overwritten&foo=bar', ['foo' => 'bar', 'some' => 'overwritten'], null];
|
||||||
|
yield ['https://domain.com/foo/bar?some=overwritten', ['foobar' => 'notrack', 'some' => 'overwritten'], null];
|
||||||
|
yield ['https://domain.com/foo/bar/something/else-baz?some=thing', [], '/something/else-baz'];
|
||||||
|
yield [
|
||||||
|
'https://domain.com/foo/bar/something/else-baz?some=thing&hello=world',
|
||||||
|
['hello' => 'world'],
|
||||||
|
'/something/else-baz',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user