From 4b4a859722aedb01742051428de18ccc792fb1a9 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 1 Feb 2021 23:08:30 +0100 Subject: [PATCH] Created ShortUrlStringifierTest --- .../Helper/ShortUrlStringifierTest.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 module/Core/test/ShortUrl/Helper/ShortUrlStringifierTest.php diff --git a/module/Core/test/ShortUrl/Helper/ShortUrlStringifierTest.php b/module/Core/test/ShortUrl/Helper/ShortUrlStringifierTest.php new file mode 100644 index 00000000..80cff5ed --- /dev/null +++ b/module/Core/test/ShortUrl/Helper/ShortUrlStringifierTest.php @@ -0,0 +1,55 @@ +stringify($shortUrl)); + } + + public function provideConfigAndShortUrls(): iterable + { + $shortUrlWithShortCode = fn (string $shortCode, ?string $domain = null) => ShortUrl::fromMeta( + ShortUrlMeta::fromRawData([ + 'longUrl' => '', + 'customSlug' => $shortCode, + 'domain' => $domain, + ]), + ); + + yield 'no config' => [[], $shortUrlWithShortCode('foo'), 'http:/foo']; + yield 'hostname in config' => [ + ['hostname' => 'example.com'], + $shortUrlWithShortCode('bar'), + 'http://example.com/bar', + ]; + yield 'full config' => [ + ['schema' => 'https', 'hostname' => 'foo.com'], + $shortUrlWithShortCode('baz'), + 'https://foo.com/baz', + ]; + yield 'custom domain' => [ + ['schema' => 'https', 'hostname' => 'foo.com'], + $shortUrlWithShortCode('baz', 'mydom.es'), + 'https://mydom.es/baz', + ]; + } +}