Remove dependencies on url_shortener raw config

This commit is contained in:
Alejandro Celaya 2024-10-20 12:52:00 +02:00
parent b991b1699e
commit c8e5196aab
26 changed files with 83 additions and 84 deletions

View file

@ -19,8 +19,6 @@ use function sprintf;
return (static function (): array {
$dropDomainMiddleware = Middleware\ShortUrl\DropDefaultDomainFromRequestMiddleware::class;
$overrideDomainMiddleware = Middleware\ShortUrl\OverrideDomainMiddleware::class;
// TODO This should be based on config, not the env var
$shortUrlRouteSuffix = EnvVars::SHORT_URL_TRAILING_SLASH->loadFromEnv() ? '[/]' : '';
return [

View file

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
use Shlinkio\Shlink\Core\Config\EnvVars;
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlMode;
use const Shlinkio\Shlink\MIN_SHORT_CODES_LENGTH;
return (static function (): array {
$shortCodesLength = max(
(int) EnvVars::DEFAULT_SHORT_CODES_LENGTH->loadFromEnv(),
MIN_SHORT_CODES_LENGTH,
);
$modeFromEnv = EnvVars::SHORT_URL_MODE->loadFromEnv();
$mode = ShortUrlMode::tryFrom($modeFromEnv) ?? ShortUrlMode::STRICT;
return [
'url_shortener' => [
'domain' => [ // TODO Refactor this structure to url_shortener.schema and url_shortener.default_domain
'schema' => ((bool) EnvVars::IS_HTTPS_ENABLED->loadFromEnv()) ? 'https' : 'http',
'hostname' => EnvVars::DEFAULT_DOMAIN->loadFromEnv(),
],
'default_short_codes_length' => $shortCodesLength,
'auto_resolve_titles' => (bool) EnvVars::AUTO_RESOLVE_TITLES->loadFromEnv(),
'append_extra_path' => (bool) EnvVars::REDIRECT_APPEND_EXTRA_PATH->loadFromEnv(),
'multi_segment_slugs_enabled' => (bool) EnvVars::MULTI_SEGMENT_SLUGS_ENABLED->loadFromEnv(),
'trailing_slash_enabled' => (bool) EnvVars::SHORT_URL_TRAILING_SLASH->loadFromEnv(),
'mode' => $mode,
],
];
})();

View file

@ -88,7 +88,7 @@ return [
TrackingOptions::class,
],
Util\ProcessRunner::class => [SymfonyCli\Helper\ProcessHelper::class],
ApiKey\RoleResolver::class => [DomainService::class, 'config.url_shortener.domain.hostname'],
ApiKey\RoleResolver::class => [DomainService::class, UrlShortenerOptions::class],
Command\ShortUrl\CreateShortUrlCommand::class => [
ShortUrl\UrlShortener::class,

View file

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\ApiKey;
use Shlinkio\Shlink\CLI\Exception\InvalidRoleConfigException;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\Domain\DomainServiceInterface;
use Shlinkio\Shlink\Rest\ApiKey\Model\RoleDefinition;
use Shlinkio\Shlink\Rest\ApiKey\Role;
@ -12,11 +13,11 @@ use Symfony\Component\Console\Input\InputInterface;
use function is_string;
class RoleResolver implements RoleResolverInterface
readonly class RoleResolver implements RoleResolverInterface
{
public function __construct(
private readonly DomainServiceInterface $domainService,
private readonly string $defaultDomain,
private DomainServiceInterface $domainService,
private UrlShortenerOptions $urlShortenerOptions,
) {
}
@ -39,7 +40,7 @@ class RoleResolver implements RoleResolverInterface
private function resolveRoleForAuthority(string $domainAuthority): RoleDefinition
{
if ($domainAuthority === $this->defaultDomain) {
if ($domainAuthority === $this->urlShortenerOptions->defaultDomain()) {
throw InvalidRoleConfigException::forDomainOnlyWithDefaultDomain();
}

View file

@ -10,6 +10,7 @@ use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\CLI\ApiKey\RoleResolver;
use Shlinkio\Shlink\CLI\Exception\InvalidRoleConfigException;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\Domain\DomainServiceInterface;
use Shlinkio\Shlink\Core\Domain\Entity\Domain;
use Shlinkio\Shlink\Rest\ApiKey\Model\RoleDefinition;
@ -24,7 +25,10 @@ class RoleResolverTest extends TestCase
protected function setUp(): void
{
$this->domainService = $this->createMock(DomainServiceInterface::class);
$this->resolver = new RoleResolver($this->domainService, 'default.com');
$this->resolver = new RoleResolver(
$this->domainService,
new UrlShortenerOptions(domain: ['hostname' => 'default.com']),
);
}
#[Test, DataProvider('provideRoles')]

View file

@ -37,7 +37,7 @@ class ListShortUrlsCommandTest extends TestCase
{
$this->shortUrlService = $this->createMock(ShortUrlListServiceInterface::class);
$command = new ListShortUrlsCommand($this->shortUrlService, new ShortUrlDataTransformer(
new ShortUrlStringifier([]),
new ShortUrlStringifier(),
));
$this->commandTester = CliTestUtils::testerForCommand($command);
}

View file

@ -167,7 +167,7 @@ return [
ShortUrl\ShortUrlResolver::class,
],
ShortUrl\Helper\ShortCodeUniquenessHelper::class => ['em', Config\Options\UrlShortenerOptions::class],
Domain\DomainService::class => ['em', 'config.url_shortener.domain.hostname'],
Domain\DomainService::class => ['em', Config\Options\UrlShortenerOptions::class],
Util\DoctrineBatchHelper::class => ['em'],
Util\RedirectResponseHelper::class => [Config\Options\RedirectOptions::class],
@ -197,7 +197,10 @@ return [
Config\Options\UrlShortenerOptions::class,
Lock\LockFactory::class,
],
ShortUrl\Helper\ShortUrlStringifier::class => ['config.url_shortener.domain', 'config.router.base_path'],
ShortUrl\Helper\ShortUrlStringifier::class => [
Config\Options\UrlShortenerOptions::class,
'config.router.base_path',
],
ShortUrl\Helper\ShortUrlTitleResolutionHelper::class => [
'httpClient',
Config\Options\UrlShortenerOptions::class,

View file

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\Config\PostProcessor;
use Shlinkio\Shlink\Core\Config\EnvVars;
use function array_map;
use function str_replace;
@ -14,7 +16,7 @@ class MultiSegmentSlugProcessor
public function __invoke(array $config): array
{
$multiSegmentEnabled = $config['url_shortener']['multi_segment_slugs_enabled'] ?? false;
$multiSegmentEnabled = (bool) EnvVars::MULTI_SEGMENT_SLUGS_ENABLED->loadFromEnv();
if (! $multiSegmentEnabled) {
return $config;
}

View file

@ -7,6 +7,7 @@ namespace Shlinkio\Shlink\Core\Domain;
use Doctrine\ORM\EntityManagerInterface;
use Shlinkio\Shlink\Core\Config\EmptyNotFoundRedirectConfig;
use Shlinkio\Shlink\Core\Config\NotFoundRedirects;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\Domain\Entity\Domain;
use Shlinkio\Shlink\Core\Domain\Model\DomainItem;
use Shlinkio\Shlink\Core\Domain\Repository\DomainRepositoryInterface;
@ -16,9 +17,9 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
use function array_map;
class DomainService implements DomainServiceInterface
readonly class DomainService implements DomainServiceInterface
{
public function __construct(private readonly EntityManagerInterface $em, private readonly string $defaultDomain)
public function __construct(private EntityManagerInterface $em, private UrlShortenerOptions $urlShortenerOptions)
{
}
@ -35,7 +36,10 @@ class DomainService implements DomainServiceInterface
}
return [
DomainItem::forDefaultDomain($this->defaultDomain, $default ?? new EmptyNotFoundRedirectConfig()),
DomainItem::forDefaultDomain(
$this->urlShortenerOptions->defaultDomain(),
$default ?? new EmptyNotFoundRedirectConfig(),
),
...$mappedDomains,
];
}
@ -52,7 +56,7 @@ class DomainService implements DomainServiceInterface
$restOfDomains = [];
foreach ($allDomains as $domain) {
if ($domain->authority === $this->defaultDomain) {
if ($domain->authority === $this->urlShortenerOptions->defaultDomain()) {
$defaultDomain = $domain;
} else {
$restOfDomains[] = $domain;

View file

@ -5,22 +5,23 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\ShortUrl\Helper;
use Laminas\Diactoros\Uri;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
use function sprintf;
class ShortUrlStringifier implements ShortUrlStringifierInterface
readonly class ShortUrlStringifier implements ShortUrlStringifierInterface
{
/**
* @param array{schema?: string, hostname?: string} $domainConfig
*/
public function __construct(private readonly array $domainConfig, private readonly string $basePath = '')
{
public function __construct(
private UrlShortenerOptions $urlShortenerOptions = new UrlShortenerOptions(),
private string $basePath = '',
) {
}
public function stringify(ShortUrl $shortUrl): string
{
$uriWithoutShortCode = (new Uri())->withScheme($this->domainConfig['schema'] ?? 'http')
$domainConfig = $this->urlShortenerOptions->domain;
$uriWithoutShortCode = (new Uri())->withScheme($domainConfig['schema'] ?? 'http')
->withHost($this->resolveDomain($shortUrl))
->withPath($this->basePath)
->__toString();
@ -31,6 +32,7 @@ class ShortUrlStringifier implements ShortUrlStringifierInterface
private function resolveDomain(ShortUrl $shortUrl): string
{
return $shortUrl->getDomain()?->authority ?? $this->domainConfig['hostname'] ?? '';
$domainConfig = $this->urlShortenerOptions->domain;
return $shortUrl->getDomain()?->authority ?? $domainConfig['hostname'] ?? '';
}
}

View file

@ -17,6 +17,7 @@ use Psr\Log\NullLogger;
use Shlinkio\Shlink\Common\Response\QrCodeResponse;
use Shlinkio\Shlink\Core\Action\QrCodeAction;
use Shlinkio\Shlink\Core\Config\Options\QrCodeOptions;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\Exception\ShortUrlNotFoundException;
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifier;
@ -324,7 +325,7 @@ class QrCodeActionTest extends TestCase
{
return new QrCodeAction(
$this->urlResolver,
new ShortUrlStringifier(['domain' => 's.test']),
new ShortUrlStringifier(),
new NullLogger(),
$options ?? new QrCodeOptions(enabledForDisabledShortUrls: false),
);

View file

@ -11,6 +11,7 @@ use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\Config\EmptyNotFoundRedirectConfig;
use Shlinkio\Shlink\Core\Config\NotFoundRedirects;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\Domain\DomainService;
use Shlinkio\Shlink\Core\Domain\Entity\Domain;
use Shlinkio\Shlink\Core\Domain\Model\DomainItem;
@ -28,7 +29,10 @@ class DomainServiceTest extends TestCase
protected function setUp(): void
{
$this->em = $this->createMock(EntityManagerInterface::class);
$this->domainService = new DomainService($this->em, 'default.com');
$this->domainService = new DomainService(
$this->em,
new UrlShortenerOptions(domain: ['hostname' => 'default.com']),
);
}
#[Test, DataProvider('provideExcludedDomains')]

View file

@ -31,7 +31,7 @@ class PublishingUpdatesGeneratorTest extends TestCase
Chronos::setTestNow($this->now);
$this->generator = new PublishingUpdatesGenerator(
new ShortUrlDataTransformer(new ShortUrlStringifier([])),
new ShortUrlDataTransformer(new ShortUrlStringifier()),
);
}

View file

@ -11,6 +11,7 @@ use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Common\Util\DateRange;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\Matomo\MatomoTrackerBuilderInterface;
use Shlinkio\Shlink\Core\Matomo\MatomoVisitSender;
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
@ -36,7 +37,7 @@ class MatomoVisitSenderTest extends TestCase
$this->visitSender = new MatomoVisitSender(
$this->trackerBuilder,
new ShortUrlStringifier(['hostname' => 's2.test']),
new ShortUrlStringifier(new UrlShortenerOptions(domain: ['hostname' => 's2.test'])),
$this->visitIterationRepository,
);
}

View file

@ -7,6 +7,7 @@ namespace ShlinkioTest\Shlink\Core\ShortUrl\Helper;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifier;
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlCreation;
@ -15,12 +16,12 @@ class ShortUrlStringifierTest extends TestCase
{
#[Test, DataProvider('provideConfigAndShortUrls')]
public function generatesExpectedOutputBasedOnConfigAndShortUrl(
array $config,
array $domainConfig,
string $basePath,
ShortUrl $shortUrl,
string $expected,
): void {
$stringifier = new ShortUrlStringifier($config, $basePath);
$stringifier = new ShortUrlStringifier(new UrlShortenerOptions($domainConfig), $basePath);
self::assertEquals($expected, $stringifier->stringify($shortUrl));
}

View file

@ -21,7 +21,7 @@ class ShortUrlDataTransformerTest extends TestCase
protected function setUp(): void
{
$this->transformer = new ShortUrlDataTransformer(new ShortUrlStringifier([]));
$this->transformer = new ShortUrlDataTransformer(new ShortUrlStringifier());
}
#[Test, DataProvider('provideShortUrls')]

View file

@ -86,7 +86,7 @@ return [
Action\Visit\TagVisitsAction::class => [Visit\VisitsStatsHelper::class],
Action\Visit\DomainVisitsAction::class => [
Visit\VisitsStatsHelper::class,
'config.url_shortener.domain.hostname',
Config\Options\UrlShortenerOptions::class,
],
Action\Visit\GlobalVisitsAction::class => [Visit\VisitsStatsHelper::class],
Action\Visit\OrphanVisitsAction::class => [Visit\VisitsStatsHelper::class],
@ -113,10 +113,10 @@ return [
],
Middleware\CrossDomainMiddleware::class => ['config.cors'],
Middleware\ShortUrl\DropDefaultDomainFromRequestMiddleware::class => ['config.url_shortener.domain.hostname'],
Middleware\ShortUrl\DefaultShortCodesLengthMiddleware::class => [
'config.url_shortener.default_short_codes_length',
Middleware\ShortUrl\DropDefaultDomainFromRequestMiddleware::class => [
Config\Options\UrlShortenerOptions::class,
],
Middleware\ShortUrl\DefaultShortCodesLengthMiddleware::class => [Config\Options\UrlShortenerOptions::class],
Middleware\ShortUrl\OverrideDomainMiddleware::class => [DomainService::class],
Middleware\Mercure\NotConfiguredMercureErrorHandler::class => [
ProblemDetailsResponseFactory::class,

View file

@ -8,6 +8,7 @@ use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Shlinkio\Shlink\Common\Paginator\Util\PagerfantaUtils;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\Visit\Model\VisitsParams;
use Shlinkio\Shlink\Core\Visit\VisitsStatsHelperInterface;
use Shlinkio\Shlink\Rest\Action\AbstractRestAction;
@ -20,7 +21,7 @@ class DomainVisitsAction extends AbstractRestAction
public function __construct(
private readonly VisitsStatsHelperInterface $visitsHelper,
private readonly string $defaultDomain,
private readonly UrlShortenerOptions $urlShortenerOptions,
) {
}
@ -37,7 +38,7 @@ class DomainVisitsAction extends AbstractRestAction
private function resolveDomainParam(Request $request): string
{
$domainParam = $request->getAttribute('domain', '');
if ($domainParam === $this->defaultDomain) {
if ($domainParam === $this->urlShortenerOptions->defaultDomain()) {
return 'DEFAULT';
}

View file

@ -8,11 +8,12 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\ShortUrl\Model\Validation\ShortUrlInputFilter;
class DefaultShortCodesLengthMiddleware implements MiddlewareInterface
readonly class DefaultShortCodesLengthMiddleware implements MiddlewareInterface
{
public function __construct(private int $defaultShortCodesLength)
public function __construct(private UrlShortenerOptions $urlShortenerOptions)
{
}
@ -21,7 +22,7 @@ class DefaultShortCodesLengthMiddleware implements MiddlewareInterface
/** @var array $body */
$body = $request->getParsedBody();
if (! isset($body[ShortUrlInputFilter::SHORT_CODE_LENGTH])) {
$body[ShortUrlInputFilter::SHORT_CODE_LENGTH] = $this->defaultShortCodesLength;
$body[ShortUrlInputFilter::SHORT_CODE_LENGTH] = $this->urlShortenerOptions->defaultShortCodesLength;
}
return $handler->handle($request->withParsedBody($body));

View file

@ -8,10 +8,11 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
class DropDefaultDomainFromRequestMiddleware implements MiddlewareInterface
readonly class DropDefaultDomainFromRequestMiddleware implements MiddlewareInterface
{
public function __construct(private readonly string $defaultDomain)
public function __construct(private UrlShortenerOptions $urlShortenerOptions)
{
}
@ -27,7 +28,7 @@ class DropDefaultDomainFromRequestMiddleware implements MiddlewareInterface
private function sanitizeDomainFromPayload(array $payload): array
{
if (isset($payload['domain']) && $payload['domain'] === $this->defaultDomain) {
if (isset($payload['domain']) && $payload['domain'] === $this->urlShortenerOptions->defaultDomain()) {
unset($payload['domain']);
}

View file

@ -25,7 +25,7 @@ class EditShortUrlActionTest extends TestCase
{
$this->shortUrlService = $this->createMock(ShortUrlServiceInterface::class);
$this->action = new EditShortUrlAction($this->shortUrlService, new ShortUrlDataTransformer(
new ShortUrlStringifier([]),
new ShortUrlStringifier(),
));
}

View file

@ -13,6 +13,7 @@ use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Common\Paginator\Paginator;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifier;
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlsParams;
use Shlinkio\Shlink\Core\ShortUrl\ShortUrlListServiceInterface;
@ -30,10 +31,10 @@ class ListShortUrlsActionTest extends TestCase
$this->service = $this->createMock(ShortUrlListServiceInterface::class);
$this->action = new ListShortUrlsAction($this->service, new ShortUrlDataTransformer(
new ShortUrlStringifier([
new ShortUrlStringifier(new UrlShortenerOptions(domain: [
'hostname' => 's.test',
'schema' => 'https',
]),
])),
));
}

View file

@ -25,7 +25,7 @@ class ResolveShortUrlActionTest extends TestCase
{
$this->urlResolver = $this->createMock(ShortUrlResolverInterface::class);
$this->action = new ResolveShortUrlAction($this->urlResolver, new ShortUrlDataTransformer(
new ShortUrlStringifier([]),
new ShortUrlStringifier(),
));
}

View file

@ -11,6 +11,7 @@ use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Common\Paginator\Paginator;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\Visit\Model\VisitsParams;
use Shlinkio\Shlink\Core\Visit\VisitsStatsHelperInterface;
use Shlinkio\Shlink\Rest\Action\Visit\DomainVisitsAction;
@ -24,7 +25,10 @@ class DomainVisitsActionTest extends TestCase
protected function setUp(): void
{
$this->visitsHelper = $this->createMock(VisitsStatsHelperInterface::class);
$this->action = new DomainVisitsAction($this->visitsHelper, 'the_default.com');
$this->action = new DomainVisitsAction(
$this->visitsHelper,
new UrlShortenerOptions(domain: ['hostname' => 'the_default.com']),
);
}
#[Test, DataProvider('provideDomainAuthorities')]

View file

@ -13,6 +13,7 @@ use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\ShortUrl\Model\Validation\ShortUrlInputFilter;
use Shlinkio\Shlink\Rest\Middleware\ShortUrl\DefaultShortCodesLengthMiddleware;
@ -24,7 +25,7 @@ class DefaultShortCodesLengthMiddlewareTest extends TestCase
protected function setUp(): void
{
$this->handler = $this->createMock(RequestHandlerInterface::class);
$this->middleware = new DefaultShortCodesLengthMiddleware(8);
$this->middleware = new DefaultShortCodesLengthMiddleware(new UrlShortenerOptions(defaultShortCodesLength: 8));
}
#[Test, DataProvider('provideBodies')]

View file

@ -13,6 +13,7 @@ use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Rest\Middleware\ShortUrl\DropDefaultDomainFromRequestMiddleware;
class DropDefaultDomainFromRequestMiddlewareTest extends TestCase
@ -23,7 +24,9 @@ class DropDefaultDomainFromRequestMiddlewareTest extends TestCase
protected function setUp(): void
{
$this->next = $this->createMock(RequestHandlerInterface::class);
$this->middleware = new DropDefaultDomainFromRequestMiddleware('s.test');
$this->middleware = new DropDefaultDomainFromRequestMiddleware(
new UrlShortenerOptions(domain: ['hostname' => 's.test']),
);
}
#[Test, DataProvider('provideQueryParams')]