Merge pull request #1587 from acelaya-forks/feature/phpstan-phpunit

Feature/phpstan phpunit
This commit is contained in:
Alejandro Celaya 2022-10-24 20:34:11 +02:00 committed by GitHub
commit 598c0757be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
111 changed files with 233 additions and 210 deletions

View file

@ -67,6 +67,7 @@
"openswoole/ide-helper": "~4.11.5", "openswoole/ide-helper": "~4.11.5",
"phpstan/phpstan": "^1.8", "phpstan/phpstan": "^1.8",
"phpstan/phpstan-doctrine": "^1.3", "phpstan/phpstan-doctrine": "^1.3",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-symfony": "^1.2", "phpstan/phpstan-symfony": "^1.2",
"phpunit/php-code-coverage": "^9.2", "phpunit/php-code-coverage": "^9.2",
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.5",
@ -108,7 +109,7 @@
], ],
"cs": "phpcs", "cs": "phpcs",
"cs:fix": "phpcbf", "cs:fix": "phpcbf",
"stan": "APP_ENV=test php vendor/bin/phpstan analyse module/*/src module/*/config config docker/config data/migrations --level=8", "stan": "APP_ENV=test php vendor/bin/phpstan analyse module/*/src module/*/test* module/*/config config docker/config data/migrations --level=8",
"test": [ "test": [
"@parallel test:unit test:db", "@parallel test:unit test:db",
"@parallel test:api test:cli" "@parallel test:api test:cli"

View file

@ -19,7 +19,7 @@ use function Functional\map;
class RoleResolverTest extends TestCase class RoleResolverTest extends TestCase
{ {
private RoleResolver $resolver; private RoleResolver $resolver;
private MockObject $domainService; private MockObject & DomainServiceInterface $domainService;
protected function setUp(): void protected function setUp(): void
{ {
@ -38,7 +38,7 @@ class RoleResolverTest extends TestCase
): void { ): void {
$this->domainService->expects($this->exactly($expectedDomainCalls))->method('getOrCreate')->with( $this->domainService->expects($this->exactly($expectedDomainCalls))->method('getOrCreate')->with(
'example.com', 'example.com',
)->willReturn(Domain::withAuthority('example.com')->setId('1')); )->willReturn($this->domainWithId(Domain::withAuthority('example.com')));
$result = $this->resolver->determineRoles($input); $result = $this->resolver->determineRoles($input);
@ -47,7 +47,7 @@ class RoleResolverTest extends TestCase
public function provideRoles(): iterable public function provideRoles(): iterable
{ {
$domain = Domain::withAuthority('example.com')->setId('1'); $domain = $this->domainWithId(Domain::withAuthority('example.com'));
$buildInput = function (array $definition): InputInterface { $buildInput = function (array $definition): InputInterface {
$input = $this->createStub(InputInterface::class); $input = $this->createStub(InputInterface::class);
$input->method('getOption')->willReturnMap( $input->method('getOption')->willReturnMap(
@ -113,4 +113,10 @@ class RoleResolverTest extends TestCase
$this->resolver->determineRoles($input); $this->resolver->determineRoles($input);
} }
private function domainWithId(Domain $domain): Domain
{
$domain->setId('1');
return $domain;
}
} }

View file

@ -13,10 +13,7 @@ use Symfony\Component\Console\Tester\CommandTester;
trait CliTestUtilsTrait trait CliTestUtilsTrait
{ {
/** private function createCommandMock(string $name): MockObject & Command
* @return MockObject & Command
*/
private function createCommandMock(string $name): MockObject
{ {
$command = $this->createMock(Command::class); $command = $this->createMock(Command::class);
$command->method('getName')->willReturn($name); $command->method('getName')->willReturn($name);

View file

@ -17,7 +17,7 @@ class DisableKeyCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $apiKeyService; private MockObject & ApiKeyServiceInterface $apiKeyService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -20,7 +20,7 @@ class GenerateKeyCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $apiKeyService; private MockObject & ApiKeyServiceInterface $apiKeyService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -21,7 +21,7 @@ class ListKeysCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $apiKeyService; private MockObject & ApiKeyServiceInterface $apiKeyService;
protected function setUp(): void protected function setUp(): void
{ {
@ -86,12 +86,12 @@ class ListKeysCommandTest extends TestCase
$apiKey1 = ApiKey::create(), $apiKey1 = ApiKey::create(),
$apiKey2 = $this->apiKeyWithRoles([RoleDefinition::forAuthoredShortUrls()]), $apiKey2 = $this->apiKeyWithRoles([RoleDefinition::forAuthoredShortUrls()]),
$apiKey3 = $this->apiKeyWithRoles( $apiKey3 = $this->apiKeyWithRoles(
[RoleDefinition::forDomain(Domain::withAuthority('example.com')->setId('1'))], [RoleDefinition::forDomain($this->domainWithId(Domain::withAuthority('example.com')))],
), ),
$apiKey4 = ApiKey::create(), $apiKey4 = ApiKey::create(),
$apiKey5 = $this->apiKeyWithRoles([ $apiKey5 = $this->apiKeyWithRoles([
RoleDefinition::forAuthoredShortUrls(), RoleDefinition::forAuthoredShortUrls(),
RoleDefinition::forDomain(Domain::withAuthority('example.com')->setId('1')), RoleDefinition::forDomain($this->domainWithId(Domain::withAuthority('example.com'))),
]), ]),
$apiKey6 = ApiKey::create(), $apiKey6 = ApiKey::create(),
], ],
@ -150,4 +150,10 @@ class ListKeysCommandTest extends TestCase
return $apiKey; return $apiKey;
} }
private function domainWithId(Domain $domain): Domain
{
$domain->setId('1');
return $domain;
}
} }

View file

@ -27,10 +27,10 @@ class CreateDatabaseCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $processHelper; private MockObject & ProcessRunnerInterface $processHelper;
private MockObject $regularConn; private MockObject & Connection $regularConn;
private MockObject $schemaManager; private MockObject & AbstractSchemaManager $schemaManager;
private MockObject $driver; private MockObject & Driver $driver;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -20,7 +20,7 @@ class MigrateDatabaseCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $processHelper; private MockObject & ProcessRunnerInterface $processHelper;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -22,7 +22,7 @@ class DomainRedirectsCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $domainService; private MockObject & DomainServiceInterface $domainService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -24,8 +24,8 @@ class GetDomainVisitsCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $visitsHelper; private MockObject & VisitsStatsHelperInterface $visitsHelper;
private MockObject $stringifier; private MockObject & ShortUrlStringifierInterface $stringifier;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -21,7 +21,7 @@ class ListDomainsCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $domainService; private MockObject & DomainServiceInterface $domainService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -15,7 +15,7 @@ use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl; use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifierInterface; use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifierInterface;
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlCreation; use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlCreation;
use Shlinkio\Shlink\Core\ShortUrl\UrlShortener; use Shlinkio\Shlink\Core\ShortUrl\UrlShortenerInterface;
use ShlinkioTest\Shlink\CLI\CliTestUtilsTrait; use ShlinkioTest\Shlink\CLI\CliTestUtilsTrait;
use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Console\Tester\CommandTester;
@ -26,18 +26,21 @@ class CreateShortUrlCommandTest extends TestCase
private const DEFAULT_DOMAIN = 'default.com'; private const DEFAULT_DOMAIN = 'default.com';
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $urlShortener; private MockObject & UrlShortenerInterface $urlShortener;
private MockObject $stringifier; private MockObject & ShortUrlStringifierInterface $stringifier;
protected function setUp(): void protected function setUp(): void
{ {
$this->urlShortener = $this->createMock(UrlShortener::class); $this->urlShortener = $this->createMock(UrlShortenerInterface::class);
$this->stringifier = $this->createMock(ShortUrlStringifierInterface::class); $this->stringifier = $this->createMock(ShortUrlStringifierInterface::class);
$command = new CreateShortUrlCommand( $command = new CreateShortUrlCommand(
$this->urlShortener, $this->urlShortener,
$this->stringifier, $this->stringifier,
new UrlShortenerOptions(domain: ['hostname' => self::DEFAULT_DOMAIN], defaultShortCodesLength: 5), new UrlShortenerOptions(
domain: ['hostname' => self::DEFAULT_DOMAIN, 'schema' => ''],
defaultShortCodesLength: 5,
),
); );
$this->commandTester = $this->testerForCommand($command); $this->commandTester = $this->testerForCommand($command);
} }

View file

@ -22,7 +22,7 @@ class DeleteShortUrlCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $service; private MockObject & DeleteShortUrlServiceInterface $service;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -30,7 +30,7 @@ class GetShortUrlVisitsCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $visitsHelper; private MockObject & VisitsStatsHelperInterface $visitsHelper;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -30,7 +30,7 @@ class ListShortUrlsCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $shortUrlService; private MockObject & ShortUrlServiceInterface $shortUrlService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -23,7 +23,7 @@ class ResolveUrlCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $urlResolver; private MockObject & ShortUrlResolverInterface $urlResolver;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -16,7 +16,7 @@ class DeleteTagsCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $tagService; private MockObject & TagServiceInterface $tagService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -24,8 +24,8 @@ class GetTagVisitsCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $visitsHelper; private MockObject & VisitsStatsHelperInterface $visitsHelper;
private MockObject $stringifier; private MockObject & ShortUrlStringifierInterface $stringifier;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -19,7 +19,7 @@ class ListTagsCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $tagService; private MockObject & TagServiceInterface $tagService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -19,7 +19,7 @@ class RenameTagCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $tagService; private MockObject & TagServiceInterface $tagService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -21,7 +21,7 @@ class DownloadGeoLiteDbCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $dbUpdater; private MockObject & GeolocationDbUpdaterInterface $dbUpdater;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -24,8 +24,8 @@ class GetNonOrphanVisitsCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $visitsHelper; private MockObject & VisitsStatsHelperInterface $visitsHelper;
private MockObject $stringifier; private MockObject & ShortUrlStringifierInterface $stringifier;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -22,7 +22,7 @@ class GetOrphanVisitsCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $visitsHelper; private MockObject & VisitsStatsHelperInterface $visitsHelper;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -14,12 +14,13 @@ use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
use Shlinkio\Shlink\Core\Visit\Entity\Visit; use Shlinkio\Shlink\Core\Visit\Entity\Visit;
use Shlinkio\Shlink\Core\Visit\Entity\VisitLocation; use Shlinkio\Shlink\Core\Visit\Entity\VisitLocation;
use Shlinkio\Shlink\Core\Visit\Geolocation\VisitGeolocationHelperInterface; use Shlinkio\Shlink\Core\Visit\Geolocation\VisitGeolocationHelperInterface;
use Shlinkio\Shlink\Core\Visit\Geolocation\VisitLocator; use Shlinkio\Shlink\Core\Visit\Geolocation\VisitLocatorInterface;
use Shlinkio\Shlink\Core\Visit\Geolocation\VisitToLocationHelperInterface; use Shlinkio\Shlink\Core\Visit\Geolocation\VisitToLocationHelperInterface;
use Shlinkio\Shlink\Core\Visit\Model\Visitor; use Shlinkio\Shlink\Core\Visit\Model\Visitor;
use Shlinkio\Shlink\IpGeolocation\Exception\WrongIpException; use Shlinkio\Shlink\IpGeolocation\Exception\WrongIpException;
use Shlinkio\Shlink\IpGeolocation\Model\Location; use Shlinkio\Shlink\IpGeolocation\Model\Location;
use ShlinkioTest\Shlink\CLI\CliTestUtilsTrait; use ShlinkioTest\Shlink\CLI\CliTestUtilsTrait;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Console\Tester\CommandTester;
@ -34,14 +35,14 @@ class LocateVisitsCommandTest extends TestCase
use CliTestUtilsTrait; use CliTestUtilsTrait;
private CommandTester $commandTester; private CommandTester $commandTester;
private MockObject $visitService; private MockObject & VisitLocatorInterface $visitService;
private MockObject $visitToLocation; private MockObject & VisitToLocationHelperInterface $visitToLocation;
private MockObject $lock; private MockObject & Lock\LockInterface $lock;
private MockObject $downloadDbCommand; private MockObject & Command $downloadDbCommand;
protected function setUp(): void protected function setUp(): void
{ {
$this->visitService = $this->createMock(VisitLocator::class); $this->visitService = $this->createMock(VisitLocatorInterface::class);
$this->visitToLocation = $this->createMock(VisitToLocationHelperInterface::class); $this->visitToLocation = $this->createMock(VisitToLocationHelperInterface::class);
$locker = $this->createMock(Lock\LockFactory::class); $locker = $this->createMock(Lock\LockFactory::class);

View file

@ -23,16 +23,14 @@ use function range;
class GeolocationDbUpdaterTest extends TestCase class GeolocationDbUpdaterTest extends TestCase
{ {
private MockObject $dbUpdater; private MockObject & DbUpdaterInterface $dbUpdater;
private MockObject $geoLiteDbReader; private MockObject & Reader $geoLiteDbReader;
private MockObject $lock; private MockObject & Lock\LockInterface $lock;
protected function setUp(): void protected function setUp(): void
{ {
$this->dbUpdater = $this->createMock(DbUpdaterInterface::class); $this->dbUpdater = $this->createMock(DbUpdaterInterface::class);
$this->geoLiteDbReader = $this->createMock(Reader::class); $this->geoLiteDbReader = $this->createMock(Reader::class);
$this->trackingOptions = new TrackingOptions();
$this->lock = $this->createMock(Lock\LockInterface::class); $this->lock = $this->createMock(Lock\LockInterface::class);
$this->lock->method('acquire')->with($this->isTrue())->willReturn(true); $this->lock->method('acquire')->with($this->isTrue())->willReturn(true);
} }

View file

@ -16,10 +16,10 @@ use Symfony\Component\Process\Process;
class ProcessRunnerTest extends TestCase class ProcessRunnerTest extends TestCase
{ {
private ProcessRunner $runner; private ProcessRunner $runner;
private MockObject $helper; private MockObject & ProcessHelper $helper;
private MockObject $formatter; private MockObject & DebugFormatterHelper $formatter;
private MockObject $process; private MockObject & Process $process;
private MockObject $output; private MockObject & OutputInterface $output;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -15,7 +15,7 @@ use Symfony\Component\Console\Output\OutputInterface;
class ShlinkTableTest extends TestCase class ShlinkTableTest extends TestCase
{ {
private ShlinkTable $shlinkTable; private ShlinkTable $shlinkTable;
private MockObject $baseTable; private MockObject & Table $baseTable;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -22,6 +22,8 @@ class TagsPaginatorAdapterTest extends DatabaseTestCase
} }
/** /**
* @param int<0, max> $offset
* @param int<0, max> $length
* @test * @test
* @dataProvider provideFilters * @dataProvider provideFilters
*/ */

View file

@ -213,7 +213,6 @@ class VisitRepositoryTest extends DatabaseTestCase
{ {
$foo = 'foo'; $foo = 'foo';
/** @var ShortUrl $shortUrl */
$this->createShortUrlsAndVisits(false, [$foo]); $this->createShortUrlsAndVisits(false, [$foo]);
$this->getEntityManager()->flush(); $this->getEntityManager()->flush();

View file

@ -18,8 +18,8 @@ use Shlinkio\Shlink\Core\Visit\RequestTrackerInterface;
class PixelActionTest extends TestCase class PixelActionTest extends TestCase
{ {
private PixelAction $action; private PixelAction $action;
private MockObject $urlResolver; private MockObject & ShortUrlResolverInterface $urlResolver;
private MockObject $requestTracker; private MockObject & RequestTrackerInterface $requestTracker;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -30,7 +30,7 @@ class QrCodeActionTest extends TestCase
private const WHITE = 0xFFFFFF; private const WHITE = 0xFFFFFF;
private const BLACK = 0x0; private const BLACK = 0x0;
private MockObject $urlResolver; private MockObject & ShortUrlResolverInterface $urlResolver;
protected function setUp(): void protected function setUp(): void
{ {
@ -115,8 +115,10 @@ class QrCodeActionTest extends TestCase
$delegate = $this->createMock(RequestHandlerInterface::class); $delegate = $this->createMock(RequestHandlerInterface::class);
$resp = $this->action($defaultOptions)->process($req->withAttribute('shortCode', $code), $delegate); $resp = $this->action($defaultOptions)->process($req->withAttribute('shortCode', $code), $delegate);
[$size] = getimagesizefromstring($resp->getBody()->__toString()); $result = getimagesizefromstring($resp->getBody()->__toString());
self::assertNotFalse($result);
[$size] = $result;
self::assertEquals($expectedSize, $size); self::assertEquals($expectedSize, $size);
} }
@ -207,8 +209,9 @@ class QrCodeActionTest extends TestCase
$resp = $this->action($defaultOptions)->process($req, $delegate); $resp = $this->action($defaultOptions)->process($req, $delegate);
$image = imagecreatefromstring($resp->getBody()->__toString()); $image = imagecreatefromstring($resp->getBody()->__toString());
$color = imagecolorat($image, 1, 1); self::assertNotFalse($image);
$color = imagecolorat($image, 1, 1);
self::assertEquals($color, $expectedColor); self::assertEquals($color, $expectedColor);
} }

View file

@ -23,9 +23,9 @@ class RedirectActionTest extends TestCase
private const LONG_URL = 'https://domain.com/foo/bar?some=thing'; private const LONG_URL = 'https://domain.com/foo/bar?some=thing';
private RedirectAction $action; private RedirectAction $action;
private MockObject $urlResolver; private MockObject & ShortUrlResolverInterface $urlResolver;
private MockObject $requestTracker; private MockObject & RequestTrackerInterface $requestTracker;
private MockObject $redirectRespHelper; private MockObject & RedirectResponseHelperInterface $redirectRespHelper;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -13,7 +13,7 @@ use Shlinkio\Shlink\Core\Crawling\CrawlingHelperInterface;
class RobotsActionTest extends TestCase class RobotsActionTest extends TestCase
{ {
private RobotsAction $action; private RobotsAction $action;
private MockObject $helper; private MockObject & CrawlingHelperInterface $helper;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -24,7 +24,7 @@ use Shlinkio\Shlink\Core\Util\RedirectResponseHelperInterface;
class NotFoundRedirectResolverTest extends TestCase class NotFoundRedirectResolverTest extends TestCase
{ {
private NotFoundRedirectResolver $resolver; private NotFoundRedirectResolver $resolver;
private MockObject $helper; private MockObject & RedirectResponseHelperInterface $helper;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -14,7 +14,7 @@ use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepositoryInterface;
class CrawlingHelperTest extends TestCase class CrawlingHelperTest extends TestCase
{ {
private CrawlingHelper $helper; private CrawlingHelper $helper;
private MockObject $em; private MockObject & EntityManagerInterface $em;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -21,7 +21,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class DomainServiceTest extends TestCase class DomainServiceTest extends TestCase
{ {
private DomainService $domainService; private DomainService $domainService;
private MockObject $em; private MockObject & EntityManagerInterface $em;
protected function setUp(): void protected function setUp(): void
{ {
@ -48,8 +48,10 @@ class DomainServiceTest extends TestCase
{ {
$default = DomainItem::forDefaultDomain('default.com', new EmptyNotFoundRedirectConfig()); $default = DomainItem::forDefaultDomain('default.com', new EmptyNotFoundRedirectConfig());
$adminApiKey = ApiKey::create(); $adminApiKey = ApiKey::create();
$domain = Domain::withAuthority('');
$domain->setId('123');
$domainSpecificApiKey = ApiKey::fromMeta( $domainSpecificApiKey = ApiKey::fromMeta(
ApiKeyMeta::withRoles(RoleDefinition::forDomain(Domain::withAuthority('')->setId('123'))), ApiKeyMeta::withRoles(RoleDefinition::forDomain($domain)),
); );
yield 'empty list without API key' => [[], [$default], null]; yield 'empty list without API key' => [[], [$default], null];
@ -147,7 +149,8 @@ class DomainServiceTest extends TestCase
public function getOrCreateThrowsExceptionForApiKeysWithDomainRole(): void public function getOrCreateThrowsExceptionForApiKeysWithDomainRole(): void
{ {
$authority = 'example.com'; $authority = 'example.com';
$domain = Domain::withAuthority($authority)->setId('1'); $domain = Domain::withAuthority($authority);
$domain->setId('1');
$apiKey = ApiKey::fromMeta(ApiKeyMeta::withRoles(RoleDefinition::forDomain($domain))); $apiKey = ApiKey::fromMeta(ApiKeyMeta::withRoles(RoleDefinition::forDomain($domain)));
$repo = $this->createMock(DomainRepositoryInterface::class); $repo = $this->createMock(DomainRepositoryInterface::class);
$repo->method('findOneByAuthority')->with($authority, $apiKey)->willReturn(null); $repo->method('findOneByAuthority')->with($authority, $apiKey)->willReturn(null);

View file

@ -22,9 +22,9 @@ class NotFoundRedirectHandlerTest extends TestCase
{ {
private NotFoundRedirectHandler $middleware; private NotFoundRedirectHandler $middleware;
private NotFoundRedirectOptions $redirectOptions; private NotFoundRedirectOptions $redirectOptions;
private MockObject $resolver; private MockObject & NotFoundRedirectResolverInterface $resolver;
private MockObject $domainService; private MockObject & DomainServiceInterface $domainService;
private MockObject $next; private MockObject & RequestHandlerInterface $next;
private ServerRequestInterface $req; private ServerRequestInterface $req;
protected function setUp(): void protected function setUp(): void

View file

@ -17,8 +17,8 @@ class NotFoundTrackerMiddlewareTest extends TestCase
{ {
private NotFoundTrackerMiddleware $middleware; private NotFoundTrackerMiddleware $middleware;
private ServerRequestInterface $request; private ServerRequestInterface $request;
private MockObject $handler; private MockObject & RequestHandlerInterface $handler;
private MockObject $requestTracker; private MockObject & RequestTrackerInterface $requestTracker;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -17,7 +17,7 @@ use Shlinkio\Shlink\Core\ErrorHandler\NotFoundTypeResolverMiddleware;
class NotFoundTypeResolverMiddlewareTest extends TestCase class NotFoundTypeResolverMiddlewareTest extends TestCase
{ {
private NotFoundTypeResolverMiddleware $middleware; private NotFoundTypeResolverMiddleware $middleware;
private MockObject $handler; private MockObject & RequestHandlerInterface $handler;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -13,7 +13,7 @@ use Shlinkio\Shlink\Core\EventDispatcher\CloseDbConnectionEventListenerDelegator
class CloseDbConnectionEventListenerDelegatorTest extends TestCase class CloseDbConnectionEventListenerDelegatorTest extends TestCase
{ {
private CloseDbConnectionEventListenerDelegator $delegator; private CloseDbConnectionEventListenerDelegator $delegator;
private MockObject $container; private MockObject & ContainerInterface $container;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -15,7 +15,7 @@ use Throwable;
class CloseDbConnectionEventListenerTest extends TestCase class CloseDbConnectionEventListenerTest extends TestCase
{ {
private MockObject $em; private MockObject & ReopeningEntityManagerInterface $em;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -17,8 +17,8 @@ use Shlinkio\Shlink\IpGeolocation\Model\Location;
class LocateUnlocatedVisitsTest extends TestCase class LocateUnlocatedVisitsTest extends TestCase
{ {
private LocateUnlocatedVisits $listener; private LocateUnlocatedVisits $listener;
private MockObject $locator; private MockObject & VisitLocatorInterface $locator;
private MockObject $visitToLocation; private MockObject & VisitToLocationHelperInterface $visitToLocation;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -26,11 +26,11 @@ use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface;
class LocateVisitTest extends TestCase class LocateVisitTest extends TestCase
{ {
private LocateVisit $locateVisit; private LocateVisit $locateVisit;
private MockObject $ipLocationResolver; private MockObject & IpLocationResolverInterface $ipLocationResolver;
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $logger; private MockObject & LoggerInterface $logger;
private MockObject $eventDispatcher; private MockObject & EventDispatcherInterface $eventDispatcher;
private MockObject $dbUpdater; private MockObject & DbUpdaterInterface $dbUpdater;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -19,10 +19,10 @@ use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
class NotifyNewShortUrlToMercureTest extends TestCase class NotifyNewShortUrlToMercureTest extends TestCase
{ {
private NotifyNewShortUrlToMercure $listener; private NotifyNewShortUrlToMercure $listener;
private MockObject $helper; private MockObject & PublishingHelperInterface $helper;
private MockObject $updatesGenerator; private MockObject & PublishingUpdatesGeneratorInterface $updatesGenerator;
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $logger; private MockObject & LoggerInterface $logger;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -22,10 +22,10 @@ use Shlinkio\Shlink\Core\Visit\Model\VisitType;
class NotifyVisitToMercureTest extends TestCase class NotifyVisitToMercureTest extends TestCase
{ {
private NotifyVisitToMercure $listener; private NotifyVisitToMercure $listener;
private MockObject $helper; private MockObject & PublishingHelperInterface $helper;
private MockObject $updatesGenerator; private MockObject & PublishingUpdatesGeneratorInterface $updatesGenerator;
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $logger; private MockObject & LoggerInterface $logger;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -30,9 +30,9 @@ use function Functional\contains;
class NotifyVisitToWebHooksTest extends TestCase class NotifyVisitToWebHooksTest extends TestCase
{ {
private MockObject $httpClient; private MockObject & ClientInterface $httpClient;
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $logger; private MockObject & LoggerInterface $logger;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -23,10 +23,10 @@ use Throwable;
class NotifyNewShortUrlToRabbitMqTest extends TestCase class NotifyNewShortUrlToRabbitMqTest extends TestCase
{ {
private MockObject $helper; private MockObject & PublishingHelperInterface $helper;
private MockObject $updatesGenerator; private MockObject & PublishingUpdatesGeneratorInterface $updatesGenerator;
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $logger; private MockObject & LoggerInterface $logger;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -31,10 +31,10 @@ use function Functional\noop;
class NotifyVisitToRabbitMqTest extends TestCase class NotifyVisitToRabbitMqTest extends TestCase
{ {
private MockObject $helper; private MockObject & PublishingHelperInterface $helper;
private MockObject $updatesGenerator; private MockObject & PublishingUpdatesGeneratorInterface $updatesGenerator;
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $logger; private MockObject & LoggerInterface $logger;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -22,10 +22,10 @@ use Throwable;
class NotifyNewShortUrlToRedisTest extends TestCase class NotifyNewShortUrlToRedisTest extends TestCase
{ {
private MockObject $helper; private MockObject & PublishingHelperInterface $helper;
private MockObject $updatesGenerator; private MockObject & PublishingUpdatesGeneratorInterface $updatesGenerator;
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $logger; private MockObject & LoggerInterface $logger;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -22,10 +22,10 @@ use Throwable;
class NotifyVisitToRedisTest extends TestCase class NotifyVisitToRedisTest extends TestCase
{ {
private MockObject $helper; private MockObject & PublishingHelperInterface $helper;
private MockObject $updatesGenerator; private MockObject & PublishingUpdatesGeneratorInterface $updatesGenerator;
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $logger; private MockObject & LoggerInterface $logger;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -19,9 +19,9 @@ use function Functional\map;
class UpdateGeoLiteDbTest extends TestCase class UpdateGeoLiteDbTest extends TestCase
{ {
private UpdateGeoLiteDb $listener; private UpdateGeoLiteDb $listener;
private MockObject $dbUpdater; private MockObject & GeolocationDbUpdaterInterface $dbUpdater;
private MockObject $logger; private MockObject & LoggerInterface $logger;
private MockObject $eventDispatcher; private MockObject & EventDispatcherInterface $eventDispatcher;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -32,10 +32,10 @@ use function str_contains;
class ImportedLinksProcessorTest extends TestCase class ImportedLinksProcessorTest extends TestCase
{ {
private ImportedLinksProcessor $processor; private ImportedLinksProcessor $processor;
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $shortCodeHelper; private MockObject & ShortCodeUniquenessHelperInterface $shortCodeHelper;
private MockObject $repo; private MockObject & ShortUrlRepositoryInterface $repo;
private MockObject $io; private MockObject & StyleInterface $io;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -23,8 +23,8 @@ use function sprintf;
class DeleteShortUrlServiceTest extends TestCase class DeleteShortUrlServiceTest extends TestCase
{ {
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $urlResolver; private MockObject & ShortUrlResolverInterface $urlResolver;
private string $shortCode; private string $shortCode;
protected function setUp(): void protected function setUp(): void

View file

@ -16,8 +16,8 @@ use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepository;
class ShortCodeUniquenessHelperTest extends TestCase class ShortCodeUniquenessHelperTest extends TestCase
{ {
private ShortCodeUniquenessHelper $helper; private ShortCodeUniquenessHelper $helper;
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $shortUrl; private MockObject & ShortUrl $shortUrl;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -13,7 +13,7 @@ use Shlinkio\Shlink\Core\Util\UrlValidatorInterface;
class ShortUrlTitleResolutionHelperTest extends TestCase class ShortUrlTitleResolutionHelperTest extends TestCase
{ {
private ShortUrlTitleResolutionHelper $helper; private ShortUrlTitleResolutionHelper $helper;
private MockObject $urlValidator; private MockObject & UrlValidatorInterface $urlValidator;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -30,11 +30,11 @@ use function str_starts_with;
class ExtraPathRedirectMiddlewareTest extends TestCase class ExtraPathRedirectMiddlewareTest extends TestCase
{ {
private MockObject $resolver; private MockObject & ShortUrlResolverInterface $resolver;
private MockObject $requestTracker; private MockObject & RequestTrackerInterface $requestTracker;
private MockObject $redirectionBuilder; private MockObject & ShortUrlRedirectionBuilderInterface $redirectionBuilder;
private MockObject $redirectResponseHelper; private MockObject & RedirectResponseHelperInterface $redirectResponseHelper;
private MockObject $handler; private MockObject & RequestHandlerInterface $handler;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -19,7 +19,7 @@ use function Functional\const_function;
class TrimTrailingSlashMiddlewareTest extends TestCase class TrimTrailingSlashMiddlewareTest extends TestCase
{ {
private MockObject $requestHandler; private MockObject & RequestHandlerInterface $requestHandler;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -17,7 +17,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class ShortUrlRepositoryAdapterTest extends TestCase class ShortUrlRepositoryAdapterTest extends TestCase
{ {
private MockObject $repo; private MockObject & ShortUrlRepositoryInterface $repo;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -19,7 +19,7 @@ use function count;
class PersistenceShortUrlRelationResolverTest extends TestCase class PersistenceShortUrlRelationResolverTest extends TestCase
{ {
private PersistenceShortUrlRelationResolver $resolver; private PersistenceShortUrlRelationResolver $resolver;
private MockObject $em; private MockObject & EntityManagerInterface $em;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -28,8 +28,8 @@ class ShortUrlResolverTest extends TestCase
use ApiKeyHelpersTrait; use ApiKeyHelpersTrait;
private ShortUrlResolver $urlResolver; private ShortUrlResolver $urlResolver;
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $repo; private MockObject & ShortUrlRepositoryInterface $repo;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -27,9 +27,9 @@ class ShortUrlServiceTest extends TestCase
use ApiKeyHelpersTrait; use ApiKeyHelpersTrait;
private ShortUrlService $service; private ShortUrlService $service;
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $urlResolver; private MockObject & ShortUrlResolverInterface $urlResolver;
private MockObject $titleResolutionHelper; private MockObject & ShortUrlTitleResolutionHelperInterface $titleResolutionHelper;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -21,9 +21,9 @@ use Shlinkio\Shlink\Core\ShortUrl\UrlShortener;
class UrlShortenerTest extends TestCase class UrlShortenerTest extends TestCase
{ {
private UrlShortener $urlShortener; private UrlShortener $urlShortener;
private MockObject $em; private MockObject & EntityManager $em;
private MockObject $titleResolutionHelper; private MockObject & ShortUrlTitleResolutionHelperInterface $titleResolutionHelper;
private MockObject $shortCodeHelper; private MockObject & ShortCodeUniquenessHelperInterface $shortCodeHelper;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -13,7 +13,7 @@ use Shlinkio\Shlink\Core\Tag\Repository\TagRepositoryInterface;
class TagsInfoPaginatorAdapterTest extends TestCase class TagsInfoPaginatorAdapterTest extends TestCase
{ {
private TagsInfoPaginatorAdapter $adapter; private TagsInfoPaginatorAdapter $adapter;
private MockObject $repo; private MockObject & TagRepositoryInterface $repo;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -13,7 +13,7 @@ use Shlinkio\Shlink\Core\Tag\Repository\TagRepositoryInterface;
class TagsPaginatorAdapterTest extends TestCase class TagsPaginatorAdapterTest extends TestCase
{ {
private TagsPaginatorAdapter $adapter; private TagsPaginatorAdapter $adapter;
private MockObject $repo; private MockObject & TagRepositoryInterface $repo;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -27,8 +27,8 @@ class TagServiceTest extends TestCase
use ApiKeyHelpersTrait; use ApiKeyHelpersTrait;
private TagService $service; private TagService $service;
private MockObject $em; private MockObject & EntityManagerInterface $em;
private MockObject $repo; private MockObject & TagRepository $repo;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -13,7 +13,7 @@ use Shlinkio\Shlink\Core\Util\DoctrineBatchHelper;
class DoctrineBatchHelperTest extends TestCase class DoctrineBatchHelperTest extends TestCase
{ {
private DoctrineBatchHelper $helper; private DoctrineBatchHelper $helper;
private MockObject $em; private MockObject & EntityManagerInterface $em;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -20,7 +20,7 @@ use Shlinkio\Shlink\Core\Util\UrlValidator;
class UrlValidatorTest extends TestCase class UrlValidatorTest extends TestCase
{ {
private MockObject $httpClient; private MockObject & ClientInterface $httpClient;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -6,7 +6,6 @@ namespace ShlinkioTest\Shlink\Core\Visit\Geolocation;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Exception; use Exception;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\Exception\IpCannotBeLocatedException; use Shlinkio\Shlink\Core\Exception\IpCannotBeLocatedException;
@ -19,10 +18,8 @@ use Shlinkio\Shlink\Core\Visit\Model\Visitor;
use Shlinkio\Shlink\Core\Visit\Repository\VisitRepositoryInterface; use Shlinkio\Shlink\Core\Visit\Repository\VisitRepositoryInterface;
use Shlinkio\Shlink\IpGeolocation\Model\Location; use Shlinkio\Shlink\IpGeolocation\Model\Location;
use function array_shift;
use function count; use function count;
use function floor; use function floor;
use function func_get_args;
use function Functional\map; use function Functional\map;
use function range; use function range;
use function sprintf; use function sprintf;
@ -30,8 +27,8 @@ use function sprintf;
class VisitLocatorTest extends TestCase class VisitLocatorTest extends TestCase
{ {
private VisitLocator $visitService; private VisitLocator $visitService;
private MockObject $em; private MockObject & EntityManager $em;
private MockObject $repo; private MockObject & VisitRepositoryInterface $repo;
protected function setUp(): void protected function setUp(): void
{ {
@ -72,10 +69,6 @@ class VisitLocatorTest extends TestCase
public function onVisitLocated(VisitLocation $visitLocation, Visit $visit): void public function onVisitLocated(VisitLocation $visitLocation, Visit $visit): void
{ {
$args = func_get_args();
Assert::assertInstanceOf(VisitLocation::class, array_shift($args));
Assert::assertInstanceOf(Visit::class, array_shift($args));
} }
}); });
} }

View file

@ -17,7 +17,7 @@ use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface;
class VisitToLocationHelperTest extends TestCase class VisitToLocationHelperTest extends TestCase
{ {
private VisitToLocationHelper $helper; private VisitToLocationHelper $helper;
private MockObject $ipLocationResolver; private MockObject & IpLocationResolverInterface $ipLocationResolver;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -18,7 +18,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class NonOrphanVisitsPaginatorAdapterTest extends TestCase class NonOrphanVisitsPaginatorAdapterTest extends TestCase
{ {
private NonOrphanVisitsPaginatorAdapter $adapter; private NonOrphanVisitsPaginatorAdapter $adapter;
private MockObject $repo; private MockObject & VisitRepositoryInterface $repo;
private VisitsParams $params; private VisitsParams $params;
private ApiKey $apiKey; private ApiKey $apiKey;
@ -45,6 +45,8 @@ class NonOrphanVisitsPaginatorAdapterTest extends TestCase
} }
/** /**
* @param int<0, max> $limit
* @param int<0, max> $offset
* @test * @test
* @dataProvider provideLimitAndOffset * @dataProvider provideLimitAndOffset
*/ */

View file

@ -17,7 +17,7 @@ use Shlinkio\Shlink\Core\Visit\Repository\VisitRepositoryInterface;
class OrphanVisitsPaginatorAdapterTest extends TestCase class OrphanVisitsPaginatorAdapterTest extends TestCase
{ {
private OrphanVisitsPaginatorAdapter $adapter; private OrphanVisitsPaginatorAdapter $adapter;
private MockObject $repo; private MockObject & VisitRepositoryInterface $repo;
private VisitsParams $params; private VisitsParams $params;
protected function setUp(): void protected function setUp(): void
@ -41,6 +41,8 @@ class OrphanVisitsPaginatorAdapterTest extends TestCase
} }
/** /**
* @param int<0, max> $limit
* @param int<0, max> $offset
* @test * @test
* @dataProvider provideLimitAndOffset * @dataProvider provideLimitAndOffset
*/ */

View file

@ -17,7 +17,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class ShortUrlVisitsPaginatorAdapterTest extends TestCase class ShortUrlVisitsPaginatorAdapterTest extends TestCase
{ {
private MockObject $repo; private MockObject & VisitRepositoryInterface $repo;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -16,7 +16,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class VisitsForTagPaginatorAdapterTest extends TestCase class VisitsForTagPaginatorAdapterTest extends TestCase
{ {
private MockObject $repo; private MockObject & VisitRepositoryInterface $repo;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -23,8 +23,8 @@ class RequestTrackerTest extends TestCase
private const LONG_URL = 'https://domain.com/foo/bar?some=thing'; private const LONG_URL = 'https://domain.com/foo/bar?some=thing';
private RequestTracker $requestTracker; private RequestTracker $requestTracker;
private MockObject $notFoundType; private MockObject & VisitsTrackerInterface $visitsTracker;
private MockObject $visitsTracker; private MockObject & NotFoundType $notFoundType;
private ServerRequestInterface $request; private ServerRequestInterface $request;
protected function setUp(): void protected function setUp(): void

View file

@ -38,7 +38,7 @@ class VisitsStatsHelperTest extends TestCase
use ApiKeyHelpersTrait; use ApiKeyHelpersTrait;
private VisitsStatsHelper $helper; private VisitsStatsHelper $helper;
private MockObject $em; private MockObject & EntityManagerInterface $em;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -17,8 +17,8 @@ use Shlinkio\Shlink\Core\Visit\VisitsTracker;
class VisitsTrackerTest extends TestCase class VisitsTrackerTest extends TestCase
{ {
private MockObject $em; private MockObject & EntityManager $em;
private MockObject $eventDispatcher; private MockObject & EventDispatcherInterface $eventDispatcher;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -363,7 +363,7 @@ class CreateShortUrlTest extends ApiTestCase
} }
/** /**
* @return array{int $statusCode, array $payload} * @return array{int, array}
*/ */
private function createShortUrl(array $body = [], string $apiKey = 'valid_api_key', string $version = '2'): array private function createShortUrl(array $body = [], string $apiKey = 'valid_api_key', string $version = '2'): array
{ {

View file

@ -62,13 +62,13 @@ class EditShortUrlTest extends ApiTestCase
]]; ]];
} }
private function findShortUrlMetaByShortCode(string $shortCode): ?array private function findShortUrlMetaByShortCode(string $shortCode): array
{ {
$matchingShortUrl = $this->getJsonResponsePayload( $matchingShortUrl = $this->getJsonResponsePayload(
$this->callApiWithKey(self::METHOD_GET, '/short-urls/' . $shortCode), $this->callApiWithKey(self::METHOD_GET, '/short-urls/' . $shortCode),
); );
return $matchingShortUrl['meta'] ?? null; return $matchingShortUrl['meta'] ?? [];
} }
/** /**

View file

@ -23,7 +23,7 @@ class ShortUrlsFixture extends AbstractFixture implements DependentFixtureInterf
public function load(ObjectManager $manager): void public function load(ObjectManager $manager): void
{ {
$relationResolver = new PersistenceShortUrlRelationResolver($manager); $relationResolver = new PersistenceShortUrlRelationResolver($manager); // @phpstan-ignore-line
/** @var ApiKey $authorApiKey */ /** @var ApiKey $authorApiKey */
$authorApiKey = $this->getReference('author_api_key'); $authorApiKey = $this->getReference('author_api_key');

View file

@ -21,7 +21,7 @@ use function array_key_exists;
class DomainRedirectsActionTest extends TestCase class DomainRedirectsActionTest extends TestCase
{ {
private DomainRedirectsAction $action; private DomainRedirectsAction $action;
private MockObject $domainService; private MockObject & DomainServiceInterface $domainService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -19,7 +19,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class ListDomainsActionTest extends TestCase class ListDomainsActionTest extends TestCase
{ {
private ListDomainsAction $action; private ListDomainsAction $action;
private MockObject $domainService; private MockObject & DomainServiceInterface $domainService;
private NotFoundRedirectOptions $options; private NotFoundRedirectOptions $options;
protected function setUp(): void protected function setUp(): void

View file

@ -19,7 +19,7 @@ use Shlinkio\Shlink\Rest\Action\HealthAction;
class HealthActionTest extends TestCase class HealthActionTest extends TestCase
{ {
private HealthAction $action; private HealthAction $action;
private MockObject $conn; private MockObject & Connection $conn;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -15,7 +15,7 @@ use Shlinkio\Shlink\Rest\Exception\MercureException;
class MercureInfoActionTest extends TestCase class MercureInfoActionTest extends TestCase
{ {
private MockObject $provider; private MockObject & JwtProviderInterface $provider;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -22,8 +22,8 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class CreateShortUrlActionTest extends TestCase class CreateShortUrlActionTest extends TestCase
{ {
private CreateShortUrlAction $action; private CreateShortUrlAction $action;
private MockObject $urlShortener; private MockObject & UrlShortener $urlShortener;
private MockObject $transformer; private MockObject & DataTransformerInterface $transformer;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -14,7 +14,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class DeleteShortUrlActionTest extends TestCase class DeleteShortUrlActionTest extends TestCase
{ {
private DeleteShortUrlAction $action; private DeleteShortUrlAction $action;
private MockObject $service; private MockObject & DeleteShortUrlServiceInterface $service;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -18,7 +18,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class EditShortUrlActionTest extends TestCase class EditShortUrlActionTest extends TestCase
{ {
private EditShortUrlAction $action; private EditShortUrlAction $action;
private MockObject $shortUrlService; private MockObject & ShortUrlServiceInterface $shortUrlService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -21,7 +21,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class ListShortUrlsActionTest extends TestCase class ListShortUrlsActionTest extends TestCase
{ {
private ListShortUrlsAction $action; private ListShortUrlsAction $action;
private MockObject $service; private MockObject & ShortUrlService $service;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -18,7 +18,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class ResolveShortUrlActionTest extends TestCase class ResolveShortUrlActionTest extends TestCase
{ {
private ResolveShortUrlAction $action; private ResolveShortUrlAction $action;
private MockObject $urlResolver; private MockObject & ShortUrlResolverInterface $urlResolver;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -18,7 +18,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class SingleStepCreateShortUrlActionTest extends TestCase class SingleStepCreateShortUrlActionTest extends TestCase
{ {
private SingleStepCreateShortUrlAction $action; private SingleStepCreateShortUrlAction $action;
private MockObject $urlShortener; private MockObject & UrlShortenerInterface $urlShortener;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -14,7 +14,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class DeleteTagsActionTest extends TestCase class DeleteTagsActionTest extends TestCase
{ {
private DeleteTagsAction $action; private DeleteTagsAction $action;
private MockObject $tagService; private MockObject & TagServiceInterface $tagService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -22,7 +22,7 @@ use function count;
class ListTagsActionTest extends TestCase class ListTagsActionTest extends TestCase
{ {
private ListTagsAction $action; private ListTagsAction $action;
private MockObject $tagService; private MockObject & TagServiceInterface $tagService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -21,7 +21,7 @@ use function count;
class TagsStatsActionTest extends TestCase class TagsStatsActionTest extends TestCase
{ {
private TagsStatsAction $action; private TagsStatsAction $action;
private MockObject $tagService; private MockObject & TagServiceInterface $tagService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -18,7 +18,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class UpdateTagActionTest extends TestCase class UpdateTagActionTest extends TestCase
{ {
private UpdateTagAction $action; private UpdateTagAction $action;
private MockObject $tagService; private MockObject & TagServiceInterface $tagService;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -17,7 +17,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class DomainVisitsActionTest extends TestCase class DomainVisitsActionTest extends TestCase
{ {
private DomainVisitsAction $action; private DomainVisitsAction $action;
private MockObject $visitsHelper; private MockObject & VisitsStatsHelperInterface $visitsHelper;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -16,7 +16,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class GlobalVisitsActionTest extends TestCase class GlobalVisitsActionTest extends TestCase
{ {
private GlobalVisitsAction $action; private GlobalVisitsAction $action;
private MockObject $helper; private MockObject & VisitsStatsHelperInterface $helper;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -18,7 +18,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class NonOrphanVisitsActionTest extends TestCase class NonOrphanVisitsActionTest extends TestCase
{ {
private NonOrphanVisitsAction $action; private NonOrphanVisitsAction $action;
private MockObject $visitsHelper; private MockObject & VisitsStatsHelperInterface $visitsHelper;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -22,8 +22,8 @@ use function count;
class OrphanVisitsActionTest extends TestCase class OrphanVisitsActionTest extends TestCase
{ {
private OrphanVisitsAction $action; private OrphanVisitsAction $action;
private MockObject $visitsHelper; private MockObject & VisitsStatsHelperInterface $visitsHelper;
private MockObject $orphanVisitTransformer; private MockObject & DataTransformerInterface $orphanVisitTransformer;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -21,7 +21,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class ShortUrlVisitsActionTest extends TestCase class ShortUrlVisitsActionTest extends TestCase
{ {
private ShortUrlVisitsAction $action; private ShortUrlVisitsAction $action;
private MockObject $visitsHelper; private MockObject & VisitsStatsHelperInterface $visitsHelper;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -17,7 +17,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class TagVisitsActionTest extends TestCase class TagVisitsActionTest extends TestCase
{ {
private TagVisitsAction $action; private TagVisitsAction $action;
private MockObject $visitsHelper; private MockObject & VisitsStatsHelperInterface $visitsHelper;
protected function setUp(): void protected function setUp(): void
{ {

View file

@ -17,7 +17,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class InitialApiKeyDelegatorTest extends TestCase class InitialApiKeyDelegatorTest extends TestCase
{ {
private InitialApiKeyDelegator $delegator; private InitialApiKeyDelegator $delegator;
private MockObject $container; private MockObject & ContainerInterface $container;
protected function setUp(): void protected function setUp(): void
{ {

Some files were not shown because too many files have changed in this diff Show more