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

@@ -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')]