diff --git a/module/Core/test/Action/RedirectActionTest.php b/module/Core/test/Action/RedirectActionTest.php index 72408302..e3c4694a 100644 --- a/module/Core/test/Action/RedirectActionTest.php +++ b/module/Core/test/Action/RedirectActionTest.php @@ -85,10 +85,6 @@ class RedirectActionTest extends TestCase yield [['foobar' => 'notrack']]; yield [['foobar' => 'barfoo']]; 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 */ diff --git a/module/Core/test/ShortUrl/Helper/ShortUrlRedirectionBuilderTest.php b/module/Core/test/ShortUrl/Helper/ShortUrlRedirectionBuilderTest.php new file mode 100644 index 00000000..c64147c1 --- /dev/null +++ b/module/Core/test/ShortUrl/Helper/ShortUrlRedirectionBuilderTest.php @@ -0,0 +1,49 @@ +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', + ]; + } +}