mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-23 21:27:44 +03:00
Merge pull request #1587 from acelaya-forks/feature/phpstan-phpunit
Feature/phpstan phpunit
This commit is contained in:
commit
598c0757be
111 changed files with 233 additions and 210 deletions
|
@ -67,6 +67,7 @@
|
|||
"openswoole/ide-helper": "~4.11.5",
|
||||
"phpstan/phpstan": "^1.8",
|
||||
"phpstan/phpstan-doctrine": "^1.3",
|
||||
"phpstan/phpstan-phpunit": "^1.1",
|
||||
"phpstan/phpstan-symfony": "^1.2",
|
||||
"phpunit/php-code-coverage": "^9.2",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
|
@ -108,7 +109,7 @@
|
|||
],
|
||||
"cs": "phpcs",
|
||||
"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": [
|
||||
"@parallel test:unit test:db",
|
||||
"@parallel test:api test:cli"
|
||||
|
|
|
@ -19,7 +19,7 @@ use function Functional\map;
|
|||
class RoleResolverTest extends TestCase
|
||||
{
|
||||
private RoleResolver $resolver;
|
||||
private MockObject $domainService;
|
||||
private MockObject & DomainServiceInterface $domainService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ class RoleResolverTest extends TestCase
|
|||
): void {
|
||||
$this->domainService->expects($this->exactly($expectedDomainCalls))->method('getOrCreate')->with(
|
||||
'example.com',
|
||||
)->willReturn(Domain::withAuthority('example.com')->setId('1'));
|
||||
)->willReturn($this->domainWithId(Domain::withAuthority('example.com')));
|
||||
|
||||
$result = $this->resolver->determineRoles($input);
|
||||
|
||||
|
@ -47,7 +47,7 @@ class RoleResolverTest extends TestCase
|
|||
|
||||
public function provideRoles(): iterable
|
||||
{
|
||||
$domain = Domain::withAuthority('example.com')->setId('1');
|
||||
$domain = $this->domainWithId(Domain::withAuthority('example.com'));
|
||||
$buildInput = function (array $definition): InputInterface {
|
||||
$input = $this->createStub(InputInterface::class);
|
||||
$input->method('getOption')->willReturnMap(
|
||||
|
@ -113,4 +113,10 @@ class RoleResolverTest extends TestCase
|
|||
|
||||
$this->resolver->determineRoles($input);
|
||||
}
|
||||
|
||||
private function domainWithId(Domain $domain): Domain
|
||||
{
|
||||
$domain->setId('1');
|
||||
return $domain;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,10 +13,7 @@ use Symfony\Component\Console\Tester\CommandTester;
|
|||
|
||||
trait CliTestUtilsTrait
|
||||
{
|
||||
/**
|
||||
* @return MockObject & Command
|
||||
*/
|
||||
private function createCommandMock(string $name): MockObject
|
||||
private function createCommandMock(string $name): MockObject & Command
|
||||
{
|
||||
$command = $this->createMock(Command::class);
|
||||
$command->method('getName')->willReturn($name);
|
||||
|
|
|
@ -17,7 +17,7 @@ class DisableKeyCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $apiKeyService;
|
||||
private MockObject & ApiKeyServiceInterface $apiKeyService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ class GenerateKeyCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $apiKeyService;
|
||||
private MockObject & ApiKeyServiceInterface $apiKeyService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ class ListKeysCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $apiKeyService;
|
||||
private MockObject & ApiKeyServiceInterface $apiKeyService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -86,12 +86,12 @@ class ListKeysCommandTest extends TestCase
|
|||
$apiKey1 = ApiKey::create(),
|
||||
$apiKey2 = $this->apiKeyWithRoles([RoleDefinition::forAuthoredShortUrls()]),
|
||||
$apiKey3 = $this->apiKeyWithRoles(
|
||||
[RoleDefinition::forDomain(Domain::withAuthority('example.com')->setId('1'))],
|
||||
[RoleDefinition::forDomain($this->domainWithId(Domain::withAuthority('example.com')))],
|
||||
),
|
||||
$apiKey4 = ApiKey::create(),
|
||||
$apiKey5 = $this->apiKeyWithRoles([
|
||||
RoleDefinition::forAuthoredShortUrls(),
|
||||
RoleDefinition::forDomain(Domain::withAuthority('example.com')->setId('1')),
|
||||
RoleDefinition::forDomain($this->domainWithId(Domain::withAuthority('example.com'))),
|
||||
]),
|
||||
$apiKey6 = ApiKey::create(),
|
||||
],
|
||||
|
@ -150,4 +150,10 @@ class ListKeysCommandTest extends TestCase
|
|||
|
||||
return $apiKey;
|
||||
}
|
||||
|
||||
private function domainWithId(Domain $domain): Domain
|
||||
{
|
||||
$domain->setId('1');
|
||||
return $domain;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ class CreateDatabaseCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $processHelper;
|
||||
private MockObject $regularConn;
|
||||
private MockObject $schemaManager;
|
||||
private MockObject $driver;
|
||||
private MockObject & ProcessRunnerInterface $processHelper;
|
||||
private MockObject & Connection $regularConn;
|
||||
private MockObject & AbstractSchemaManager $schemaManager;
|
||||
private MockObject & Driver $driver;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ class MigrateDatabaseCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $processHelper;
|
||||
private MockObject & ProcessRunnerInterface $processHelper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ class DomainRedirectsCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $domainService;
|
||||
private MockObject & DomainServiceInterface $domainService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -24,8 +24,8 @@ class GetDomainVisitsCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $visitsHelper;
|
||||
private MockObject $stringifier;
|
||||
private MockObject & VisitsStatsHelperInterface $visitsHelper;
|
||||
private MockObject & ShortUrlStringifierInterface $stringifier;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ class ListDomainsCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $domainService;
|
||||
private MockObject & DomainServiceInterface $domainService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
|
|||
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifierInterface;
|
||||
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 Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
|
@ -26,18 +26,21 @@ class CreateShortUrlCommandTest extends TestCase
|
|||
private const DEFAULT_DOMAIN = 'default.com';
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $urlShortener;
|
||||
private MockObject $stringifier;
|
||||
private MockObject & UrlShortenerInterface $urlShortener;
|
||||
private MockObject & ShortUrlStringifierInterface $stringifier;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->urlShortener = $this->createMock(UrlShortener::class);
|
||||
$this->urlShortener = $this->createMock(UrlShortenerInterface::class);
|
||||
$this->stringifier = $this->createMock(ShortUrlStringifierInterface::class);
|
||||
|
||||
$command = new CreateShortUrlCommand(
|
||||
$this->urlShortener,
|
||||
$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);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class DeleteShortUrlCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $service;
|
||||
private MockObject & DeleteShortUrlServiceInterface $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ class GetShortUrlVisitsCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $visitsHelper;
|
||||
private MockObject & VisitsStatsHelperInterface $visitsHelper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ class ListShortUrlsCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $shortUrlService;
|
||||
private MockObject & ShortUrlServiceInterface $shortUrlService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ class ResolveUrlCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $urlResolver;
|
||||
private MockObject & ShortUrlResolverInterface $urlResolver;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ class DeleteTagsCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $tagService;
|
||||
private MockObject & TagServiceInterface $tagService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -24,8 +24,8 @@ class GetTagVisitsCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $visitsHelper;
|
||||
private MockObject $stringifier;
|
||||
private MockObject & VisitsStatsHelperInterface $visitsHelper;
|
||||
private MockObject & ShortUrlStringifierInterface $stringifier;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ class ListTagsCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $tagService;
|
||||
private MockObject & TagServiceInterface $tagService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ class RenameTagCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $tagService;
|
||||
private MockObject & TagServiceInterface $tagService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ class DownloadGeoLiteDbCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $dbUpdater;
|
||||
private MockObject & GeolocationDbUpdaterInterface $dbUpdater;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -24,8 +24,8 @@ class GetNonOrphanVisitsCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $visitsHelper;
|
||||
private MockObject $stringifier;
|
||||
private MockObject & VisitsStatsHelperInterface $visitsHelper;
|
||||
private MockObject & ShortUrlStringifierInterface $stringifier;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ class GetOrphanVisitsCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $visitsHelper;
|
||||
private MockObject & VisitsStatsHelperInterface $visitsHelper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -14,12 +14,13 @@ use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
|
|||
use Shlinkio\Shlink\Core\Visit\Entity\Visit;
|
||||
use Shlinkio\Shlink\Core\Visit\Entity\VisitLocation;
|
||||
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\Model\Visitor;
|
||||
use Shlinkio\Shlink\IpGeolocation\Exception\WrongIpException;
|
||||
use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
||||
use ShlinkioTest\Shlink\CLI\CliTestUtilsTrait;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
@ -34,14 +35,14 @@ class LocateVisitsCommandTest extends TestCase
|
|||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject $visitService;
|
||||
private MockObject $visitToLocation;
|
||||
private MockObject $lock;
|
||||
private MockObject $downloadDbCommand;
|
||||
private MockObject & VisitLocatorInterface $visitService;
|
||||
private MockObject & VisitToLocationHelperInterface $visitToLocation;
|
||||
private MockObject & Lock\LockInterface $lock;
|
||||
private MockObject & Command $downloadDbCommand;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->visitService = $this->createMock(VisitLocator::class);
|
||||
$this->visitService = $this->createMock(VisitLocatorInterface::class);
|
||||
$this->visitToLocation = $this->createMock(VisitToLocationHelperInterface::class);
|
||||
|
||||
$locker = $this->createMock(Lock\LockFactory::class);
|
||||
|
|
|
@ -23,16 +23,14 @@ use function range;
|
|||
|
||||
class GeolocationDbUpdaterTest extends TestCase
|
||||
{
|
||||
private MockObject $dbUpdater;
|
||||
private MockObject $geoLiteDbReader;
|
||||
private MockObject $lock;
|
||||
private MockObject & DbUpdaterInterface $dbUpdater;
|
||||
private MockObject & Reader $geoLiteDbReader;
|
||||
private MockObject & Lock\LockInterface $lock;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->dbUpdater = $this->createMock(DbUpdaterInterface::class);
|
||||
$this->geoLiteDbReader = $this->createMock(Reader::class);
|
||||
$this->trackingOptions = new TrackingOptions();
|
||||
|
||||
$this->lock = $this->createMock(Lock\LockInterface::class);
|
||||
$this->lock->method('acquire')->with($this->isTrue())->willReturn(true);
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ use Symfony\Component\Process\Process;
|
|||
class ProcessRunnerTest extends TestCase
|
||||
{
|
||||
private ProcessRunner $runner;
|
||||
private MockObject $helper;
|
||||
private MockObject $formatter;
|
||||
private MockObject $process;
|
||||
private MockObject $output;
|
||||
private MockObject & ProcessHelper $helper;
|
||||
private MockObject & DebugFormatterHelper $formatter;
|
||||
private MockObject & Process $process;
|
||||
private MockObject & OutputInterface $output;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
class ShlinkTableTest extends TestCase
|
||||
{
|
||||
private ShlinkTable $shlinkTable;
|
||||
private MockObject $baseTable;
|
||||
private MockObject & Table $baseTable;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -22,6 +22,8 @@ class TagsPaginatorAdapterTest extends DatabaseTestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int<0, max> $offset
|
||||
* @param int<0, max> $length
|
||||
* @test
|
||||
* @dataProvider provideFilters
|
||||
*/
|
||||
|
|
|
@ -213,7 +213,6 @@ class VisitRepositoryTest extends DatabaseTestCase
|
|||
{
|
||||
$foo = 'foo';
|
||||
|
||||
/** @var ShortUrl $shortUrl */
|
||||
$this->createShortUrlsAndVisits(false, [$foo]);
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ use Shlinkio\Shlink\Core\Visit\RequestTrackerInterface;
|
|||
class PixelActionTest extends TestCase
|
||||
{
|
||||
private PixelAction $action;
|
||||
private MockObject $urlResolver;
|
||||
private MockObject $requestTracker;
|
||||
private MockObject & ShortUrlResolverInterface $urlResolver;
|
||||
private MockObject & RequestTrackerInterface $requestTracker;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ class QrCodeActionTest extends TestCase
|
|||
private const WHITE = 0xFFFFFF;
|
||||
private const BLACK = 0x0;
|
||||
|
||||
private MockObject $urlResolver;
|
||||
private MockObject & ShortUrlResolverInterface $urlResolver;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -115,8 +115,10 @@ class QrCodeActionTest extends TestCase
|
|||
$delegate = $this->createMock(RequestHandlerInterface::class);
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
|
@ -207,8 +209,9 @@ class QrCodeActionTest extends TestCase
|
|||
|
||||
$resp = $this->action($defaultOptions)->process($req, $delegate);
|
||||
$image = imagecreatefromstring($resp->getBody()->__toString());
|
||||
$color = imagecolorat($image, 1, 1);
|
||||
self::assertNotFalse($image);
|
||||
|
||||
$color = imagecolorat($image, 1, 1);
|
||||
self::assertEquals($color, $expectedColor);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ class RedirectActionTest extends TestCase
|
|||
private const LONG_URL = 'https://domain.com/foo/bar?some=thing';
|
||||
|
||||
private RedirectAction $action;
|
||||
private MockObject $urlResolver;
|
||||
private MockObject $requestTracker;
|
||||
private MockObject $redirectRespHelper;
|
||||
private MockObject & ShortUrlResolverInterface $urlResolver;
|
||||
private MockObject & RequestTrackerInterface $requestTracker;
|
||||
private MockObject & RedirectResponseHelperInterface $redirectRespHelper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ use Shlinkio\Shlink\Core\Crawling\CrawlingHelperInterface;
|
|||
class RobotsActionTest extends TestCase
|
||||
{
|
||||
private RobotsAction $action;
|
||||
private MockObject $helper;
|
||||
private MockObject & CrawlingHelperInterface $helper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@ use Shlinkio\Shlink\Core\Util\RedirectResponseHelperInterface;
|
|||
class NotFoundRedirectResolverTest extends TestCase
|
||||
{
|
||||
private NotFoundRedirectResolver $resolver;
|
||||
private MockObject $helper;
|
||||
private MockObject & RedirectResponseHelperInterface $helper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepositoryInterface;
|
|||
class CrawlingHelperTest extends TestCase
|
||||
{
|
||||
private CrawlingHelper $helper;
|
||||
private MockObject $em;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class DomainServiceTest extends TestCase
|
||||
{
|
||||
private DomainService $domainService;
|
||||
private MockObject $em;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -48,8 +48,10 @@ class DomainServiceTest extends TestCase
|
|||
{
|
||||
$default = DomainItem::forDefaultDomain('default.com', new EmptyNotFoundRedirectConfig());
|
||||
$adminApiKey = ApiKey::create();
|
||||
$domain = Domain::withAuthority('');
|
||||
$domain->setId('123');
|
||||
$domainSpecificApiKey = ApiKey::fromMeta(
|
||||
ApiKeyMeta::withRoles(RoleDefinition::forDomain(Domain::withAuthority('')->setId('123'))),
|
||||
ApiKeyMeta::withRoles(RoleDefinition::forDomain($domain)),
|
||||
);
|
||||
|
||||
yield 'empty list without API key' => [[], [$default], null];
|
||||
|
@ -147,7 +149,8 @@ class DomainServiceTest extends TestCase
|
|||
public function getOrCreateThrowsExceptionForApiKeysWithDomainRole(): void
|
||||
{
|
||||
$authority = 'example.com';
|
||||
$domain = Domain::withAuthority($authority)->setId('1');
|
||||
$domain = Domain::withAuthority($authority);
|
||||
$domain->setId('1');
|
||||
$apiKey = ApiKey::fromMeta(ApiKeyMeta::withRoles(RoleDefinition::forDomain($domain)));
|
||||
$repo = $this->createMock(DomainRepositoryInterface::class);
|
||||
$repo->method('findOneByAuthority')->with($authority, $apiKey)->willReturn(null);
|
||||
|
|
|
@ -22,9 +22,9 @@ class NotFoundRedirectHandlerTest extends TestCase
|
|||
{
|
||||
private NotFoundRedirectHandler $middleware;
|
||||
private NotFoundRedirectOptions $redirectOptions;
|
||||
private MockObject $resolver;
|
||||
private MockObject $domainService;
|
||||
private MockObject $next;
|
||||
private MockObject & NotFoundRedirectResolverInterface $resolver;
|
||||
private MockObject & DomainServiceInterface $domainService;
|
||||
private MockObject & RequestHandlerInterface $next;
|
||||
private ServerRequestInterface $req;
|
||||
|
||||
protected function setUp(): void
|
||||
|
|
|
@ -17,8 +17,8 @@ class NotFoundTrackerMiddlewareTest extends TestCase
|
|||
{
|
||||
private NotFoundTrackerMiddleware $middleware;
|
||||
private ServerRequestInterface $request;
|
||||
private MockObject $handler;
|
||||
private MockObject $requestTracker;
|
||||
private MockObject & RequestHandlerInterface $handler;
|
||||
private MockObject & RequestTrackerInterface $requestTracker;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ use Shlinkio\Shlink\Core\ErrorHandler\NotFoundTypeResolverMiddleware;
|
|||
class NotFoundTypeResolverMiddlewareTest extends TestCase
|
||||
{
|
||||
private NotFoundTypeResolverMiddleware $middleware;
|
||||
private MockObject $handler;
|
||||
private MockObject & RequestHandlerInterface $handler;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ use Shlinkio\Shlink\Core\EventDispatcher\CloseDbConnectionEventListenerDelegator
|
|||
class CloseDbConnectionEventListenerDelegatorTest extends TestCase
|
||||
{
|
||||
private CloseDbConnectionEventListenerDelegator $delegator;
|
||||
private MockObject $container;
|
||||
private MockObject & ContainerInterface $container;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ use Throwable;
|
|||
|
||||
class CloseDbConnectionEventListenerTest extends TestCase
|
||||
{
|
||||
private MockObject $em;
|
||||
private MockObject & ReopeningEntityManagerInterface $em;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -17,8 +17,8 @@ use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
|||
class LocateUnlocatedVisitsTest extends TestCase
|
||||
{
|
||||
private LocateUnlocatedVisits $listener;
|
||||
private MockObject $locator;
|
||||
private MockObject $visitToLocation;
|
||||
private MockObject & VisitLocatorInterface $locator;
|
||||
private MockObject & VisitToLocationHelperInterface $visitToLocation;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -26,11 +26,11 @@ use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface;
|
|||
class LocateVisitTest extends TestCase
|
||||
{
|
||||
private LocateVisit $locateVisit;
|
||||
private MockObject $ipLocationResolver;
|
||||
private MockObject $em;
|
||||
private MockObject $logger;
|
||||
private MockObject $eventDispatcher;
|
||||
private MockObject $dbUpdater;
|
||||
private MockObject & IpLocationResolverInterface $ipLocationResolver;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & LoggerInterface $logger;
|
||||
private MockObject & EventDispatcherInterface $eventDispatcher;
|
||||
private MockObject & DbUpdaterInterface $dbUpdater;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -19,10 +19,10 @@ use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
|
|||
class NotifyNewShortUrlToMercureTest extends TestCase
|
||||
{
|
||||
private NotifyNewShortUrlToMercure $listener;
|
||||
private MockObject $helper;
|
||||
private MockObject $updatesGenerator;
|
||||
private MockObject $em;
|
||||
private MockObject $logger;
|
||||
private MockObject & PublishingHelperInterface $helper;
|
||||
private MockObject & PublishingUpdatesGeneratorInterface $updatesGenerator;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & LoggerInterface $logger;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -22,10 +22,10 @@ use Shlinkio\Shlink\Core\Visit\Model\VisitType;
|
|||
class NotifyVisitToMercureTest extends TestCase
|
||||
{
|
||||
private NotifyVisitToMercure $listener;
|
||||
private MockObject $helper;
|
||||
private MockObject $updatesGenerator;
|
||||
private MockObject $em;
|
||||
private MockObject $logger;
|
||||
private MockObject & PublishingHelperInterface $helper;
|
||||
private MockObject & PublishingUpdatesGeneratorInterface $updatesGenerator;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & LoggerInterface $logger;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -30,9 +30,9 @@ use function Functional\contains;
|
|||
|
||||
class NotifyVisitToWebHooksTest extends TestCase
|
||||
{
|
||||
private MockObject $httpClient;
|
||||
private MockObject $em;
|
||||
private MockObject $logger;
|
||||
private MockObject & ClientInterface $httpClient;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & LoggerInterface $logger;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -23,10 +23,10 @@ use Throwable;
|
|||
|
||||
class NotifyNewShortUrlToRabbitMqTest extends TestCase
|
||||
{
|
||||
private MockObject $helper;
|
||||
private MockObject $updatesGenerator;
|
||||
private MockObject $em;
|
||||
private MockObject $logger;
|
||||
private MockObject & PublishingHelperInterface $helper;
|
||||
private MockObject & PublishingUpdatesGeneratorInterface $updatesGenerator;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & LoggerInterface $logger;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -31,10 +31,10 @@ use function Functional\noop;
|
|||
|
||||
class NotifyVisitToRabbitMqTest extends TestCase
|
||||
{
|
||||
private MockObject $helper;
|
||||
private MockObject $updatesGenerator;
|
||||
private MockObject $em;
|
||||
private MockObject $logger;
|
||||
private MockObject & PublishingHelperInterface $helper;
|
||||
private MockObject & PublishingUpdatesGeneratorInterface $updatesGenerator;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & LoggerInterface $logger;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -22,10 +22,10 @@ use Throwable;
|
|||
|
||||
class NotifyNewShortUrlToRedisTest extends TestCase
|
||||
{
|
||||
private MockObject $helper;
|
||||
private MockObject $updatesGenerator;
|
||||
private MockObject $em;
|
||||
private MockObject $logger;
|
||||
private MockObject & PublishingHelperInterface $helper;
|
||||
private MockObject & PublishingUpdatesGeneratorInterface $updatesGenerator;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & LoggerInterface $logger;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -22,10 +22,10 @@ use Throwable;
|
|||
|
||||
class NotifyVisitToRedisTest extends TestCase
|
||||
{
|
||||
private MockObject $helper;
|
||||
private MockObject $updatesGenerator;
|
||||
private MockObject $em;
|
||||
private MockObject $logger;
|
||||
private MockObject & PublishingHelperInterface $helper;
|
||||
private MockObject & PublishingUpdatesGeneratorInterface $updatesGenerator;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & LoggerInterface $logger;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -19,9 +19,9 @@ use function Functional\map;
|
|||
class UpdateGeoLiteDbTest extends TestCase
|
||||
{
|
||||
private UpdateGeoLiteDb $listener;
|
||||
private MockObject $dbUpdater;
|
||||
private MockObject $logger;
|
||||
private MockObject $eventDispatcher;
|
||||
private MockObject & GeolocationDbUpdaterInterface $dbUpdater;
|
||||
private MockObject & LoggerInterface $logger;
|
||||
private MockObject & EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -32,10 +32,10 @@ use function str_contains;
|
|||
class ImportedLinksProcessorTest extends TestCase
|
||||
{
|
||||
private ImportedLinksProcessor $processor;
|
||||
private MockObject $em;
|
||||
private MockObject $shortCodeHelper;
|
||||
private MockObject $repo;
|
||||
private MockObject $io;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & ShortCodeUniquenessHelperInterface $shortCodeHelper;
|
||||
private MockObject & ShortUrlRepositoryInterface $repo;
|
||||
private MockObject & StyleInterface $io;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -23,8 +23,8 @@ use function sprintf;
|
|||
|
||||
class DeleteShortUrlServiceTest extends TestCase
|
||||
{
|
||||
private MockObject $em;
|
||||
private MockObject $urlResolver;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & ShortUrlResolverInterface $urlResolver;
|
||||
private string $shortCode;
|
||||
|
||||
protected function setUp(): void
|
||||
|
|
|
@ -16,8 +16,8 @@ use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepository;
|
|||
class ShortCodeUniquenessHelperTest extends TestCase
|
||||
{
|
||||
private ShortCodeUniquenessHelper $helper;
|
||||
private MockObject $em;
|
||||
private MockObject $shortUrl;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & ShortUrl $shortUrl;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ use Shlinkio\Shlink\Core\Util\UrlValidatorInterface;
|
|||
class ShortUrlTitleResolutionHelperTest extends TestCase
|
||||
{
|
||||
private ShortUrlTitleResolutionHelper $helper;
|
||||
private MockObject $urlValidator;
|
||||
private MockObject & UrlValidatorInterface $urlValidator;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -30,11 +30,11 @@ use function str_starts_with;
|
|||
|
||||
class ExtraPathRedirectMiddlewareTest extends TestCase
|
||||
{
|
||||
private MockObject $resolver;
|
||||
private MockObject $requestTracker;
|
||||
private MockObject $redirectionBuilder;
|
||||
private MockObject $redirectResponseHelper;
|
||||
private MockObject $handler;
|
||||
private MockObject & ShortUrlResolverInterface $resolver;
|
||||
private MockObject & RequestTrackerInterface $requestTracker;
|
||||
private MockObject & ShortUrlRedirectionBuilderInterface $redirectionBuilder;
|
||||
private MockObject & RedirectResponseHelperInterface $redirectResponseHelper;
|
||||
private MockObject & RequestHandlerInterface $handler;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ use function Functional\const_function;
|
|||
|
||||
class TrimTrailingSlashMiddlewareTest extends TestCase
|
||||
{
|
||||
private MockObject $requestHandler;
|
||||
private MockObject & RequestHandlerInterface $requestHandler;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
|
||||
class ShortUrlRepositoryAdapterTest extends TestCase
|
||||
{
|
||||
private MockObject $repo;
|
||||
private MockObject & ShortUrlRepositoryInterface $repo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ use function count;
|
|||
class PersistenceShortUrlRelationResolverTest extends TestCase
|
||||
{
|
||||
private PersistenceShortUrlRelationResolver $resolver;
|
||||
private MockObject $em;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -28,8 +28,8 @@ class ShortUrlResolverTest extends TestCase
|
|||
use ApiKeyHelpersTrait;
|
||||
|
||||
private ShortUrlResolver $urlResolver;
|
||||
private MockObject $em;
|
||||
private MockObject $repo;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & ShortUrlRepositoryInterface $repo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -27,9 +27,9 @@ class ShortUrlServiceTest extends TestCase
|
|||
use ApiKeyHelpersTrait;
|
||||
|
||||
private ShortUrlService $service;
|
||||
private MockObject $em;
|
||||
private MockObject $urlResolver;
|
||||
private MockObject $titleResolutionHelper;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & ShortUrlResolverInterface $urlResolver;
|
||||
private MockObject & ShortUrlTitleResolutionHelperInterface $titleResolutionHelper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -21,9 +21,9 @@ use Shlinkio\Shlink\Core\ShortUrl\UrlShortener;
|
|||
class UrlShortenerTest extends TestCase
|
||||
{
|
||||
private UrlShortener $urlShortener;
|
||||
private MockObject $em;
|
||||
private MockObject $titleResolutionHelper;
|
||||
private MockObject $shortCodeHelper;
|
||||
private MockObject & EntityManager $em;
|
||||
private MockObject & ShortUrlTitleResolutionHelperInterface $titleResolutionHelper;
|
||||
private MockObject & ShortCodeUniquenessHelperInterface $shortCodeHelper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ use Shlinkio\Shlink\Core\Tag\Repository\TagRepositoryInterface;
|
|||
class TagsInfoPaginatorAdapterTest extends TestCase
|
||||
{
|
||||
private TagsInfoPaginatorAdapter $adapter;
|
||||
private MockObject $repo;
|
||||
private MockObject & TagRepositoryInterface $repo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ use Shlinkio\Shlink\Core\Tag\Repository\TagRepositoryInterface;
|
|||
class TagsPaginatorAdapterTest extends TestCase
|
||||
{
|
||||
private TagsPaginatorAdapter $adapter;
|
||||
private MockObject $repo;
|
||||
private MockObject & TagRepositoryInterface $repo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -27,8 +27,8 @@ class TagServiceTest extends TestCase
|
|||
use ApiKeyHelpersTrait;
|
||||
|
||||
private TagService $service;
|
||||
private MockObject $em;
|
||||
private MockObject $repo;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
private MockObject & TagRepository $repo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ use Shlinkio\Shlink\Core\Util\DoctrineBatchHelper;
|
|||
class DoctrineBatchHelperTest extends TestCase
|
||||
{
|
||||
private DoctrineBatchHelper $helper;
|
||||
private MockObject $em;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ use Shlinkio\Shlink\Core\Util\UrlValidator;
|
|||
|
||||
class UrlValidatorTest extends TestCase
|
||||
{
|
||||
private MockObject $httpClient;
|
||||
private MockObject & ClientInterface $httpClient;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ namespace ShlinkioTest\Shlink\Core\Visit\Geolocation;
|
|||
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
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\IpGeolocation\Model\Location;
|
||||
|
||||
use function array_shift;
|
||||
use function count;
|
||||
use function floor;
|
||||
use function func_get_args;
|
||||
use function Functional\map;
|
||||
use function range;
|
||||
use function sprintf;
|
||||
|
@ -30,8 +27,8 @@ use function sprintf;
|
|||
class VisitLocatorTest extends TestCase
|
||||
{
|
||||
private VisitLocator $visitService;
|
||||
private MockObject $em;
|
||||
private MockObject $repo;
|
||||
private MockObject & EntityManager $em;
|
||||
private MockObject & VisitRepositoryInterface $repo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -72,10 +69,6 @@ class VisitLocatorTest extends TestCase
|
|||
|
||||
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));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface;
|
|||
class VisitToLocationHelperTest extends TestCase
|
||||
{
|
||||
private VisitToLocationHelper $helper;
|
||||
private MockObject $ipLocationResolver;
|
||||
private MockObject & IpLocationResolverInterface $ipLocationResolver;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class NonOrphanVisitsPaginatorAdapterTest extends TestCase
|
||||
{
|
||||
private NonOrphanVisitsPaginatorAdapter $adapter;
|
||||
private MockObject $repo;
|
||||
private MockObject & VisitRepositoryInterface $repo;
|
||||
private VisitsParams $params;
|
||||
private ApiKey $apiKey;
|
||||
|
||||
|
@ -45,6 +45,8 @@ class NonOrphanVisitsPaginatorAdapterTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int<0, max> $limit
|
||||
* @param int<0, max> $offset
|
||||
* @test
|
||||
* @dataProvider provideLimitAndOffset
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@ use Shlinkio\Shlink\Core\Visit\Repository\VisitRepositoryInterface;
|
|||
class OrphanVisitsPaginatorAdapterTest extends TestCase
|
||||
{
|
||||
private OrphanVisitsPaginatorAdapter $adapter;
|
||||
private MockObject $repo;
|
||||
private MockObject & VisitRepositoryInterface $repo;
|
||||
private VisitsParams $params;
|
||||
|
||||
protected function setUp(): void
|
||||
|
@ -41,6 +41,8 @@ class OrphanVisitsPaginatorAdapterTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int<0, max> $limit
|
||||
* @param int<0, max> $offset
|
||||
* @test
|
||||
* @dataProvider provideLimitAndOffset
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
|
||||
class ShortUrlVisitsPaginatorAdapterTest extends TestCase
|
||||
{
|
||||
private MockObject $repo;
|
||||
private MockObject & VisitRepositoryInterface $repo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
|
||||
class VisitsForTagPaginatorAdapterTest extends TestCase
|
||||
{
|
||||
private MockObject $repo;
|
||||
private MockObject & VisitRepositoryInterface $repo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -23,8 +23,8 @@ class RequestTrackerTest extends TestCase
|
|||
private const LONG_URL = 'https://domain.com/foo/bar?some=thing';
|
||||
|
||||
private RequestTracker $requestTracker;
|
||||
private MockObject $notFoundType;
|
||||
private MockObject $visitsTracker;
|
||||
private MockObject & VisitsTrackerInterface $visitsTracker;
|
||||
private MockObject & NotFoundType $notFoundType;
|
||||
private ServerRequestInterface $request;
|
||||
|
||||
protected function setUp(): void
|
||||
|
|
|
@ -38,7 +38,7 @@ class VisitsStatsHelperTest extends TestCase
|
|||
use ApiKeyHelpersTrait;
|
||||
|
||||
private VisitsStatsHelper $helper;
|
||||
private MockObject $em;
|
||||
private MockObject & EntityManagerInterface $em;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -17,8 +17,8 @@ use Shlinkio\Shlink\Core\Visit\VisitsTracker;
|
|||
|
||||
class VisitsTrackerTest extends TestCase
|
||||
{
|
||||
private MockObject $em;
|
||||
private MockObject $eventDispatcher;
|
||||
private MockObject & EntityManager $em;
|
||||
private MockObject & EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -62,13 +62,13 @@ class EditShortUrlTest extends ApiTestCase
|
|||
]];
|
||||
}
|
||||
|
||||
private function findShortUrlMetaByShortCode(string $shortCode): ?array
|
||||
private function findShortUrlMetaByShortCode(string $shortCode): array
|
||||
{
|
||||
$matchingShortUrl = $this->getJsonResponsePayload(
|
||||
$this->callApiWithKey(self::METHOD_GET, '/short-urls/' . $shortCode),
|
||||
);
|
||||
|
||||
return $matchingShortUrl['meta'] ?? null;
|
||||
return $matchingShortUrl['meta'] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,7 @@ class ShortUrlsFixture extends AbstractFixture implements DependentFixtureInterf
|
|||
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$relationResolver = new PersistenceShortUrlRelationResolver($manager);
|
||||
$relationResolver = new PersistenceShortUrlRelationResolver($manager); // @phpstan-ignore-line
|
||||
|
||||
/** @var ApiKey $authorApiKey */
|
||||
$authorApiKey = $this->getReference('author_api_key');
|
||||
|
|
|
@ -21,7 +21,7 @@ use function array_key_exists;
|
|||
class DomainRedirectsActionTest extends TestCase
|
||||
{
|
||||
private DomainRedirectsAction $action;
|
||||
private MockObject $domainService;
|
||||
private MockObject & DomainServiceInterface $domainService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class ListDomainsActionTest extends TestCase
|
||||
{
|
||||
private ListDomainsAction $action;
|
||||
private MockObject $domainService;
|
||||
private MockObject & DomainServiceInterface $domainService;
|
||||
private NotFoundRedirectOptions $options;
|
||||
|
||||
protected function setUp(): void
|
||||
|
|
|
@ -19,7 +19,7 @@ use Shlinkio\Shlink\Rest\Action\HealthAction;
|
|||
class HealthActionTest extends TestCase
|
||||
{
|
||||
private HealthAction $action;
|
||||
private MockObject $conn;
|
||||
private MockObject & Connection $conn;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ use Shlinkio\Shlink\Rest\Exception\MercureException;
|
|||
|
||||
class MercureInfoActionTest extends TestCase
|
||||
{
|
||||
private MockObject $provider;
|
||||
private MockObject & JwtProviderInterface $provider;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -22,8 +22,8 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class CreateShortUrlActionTest extends TestCase
|
||||
{
|
||||
private CreateShortUrlAction $action;
|
||||
private MockObject $urlShortener;
|
||||
private MockObject $transformer;
|
||||
private MockObject & UrlShortener $urlShortener;
|
||||
private MockObject & DataTransformerInterface $transformer;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class DeleteShortUrlActionTest extends TestCase
|
||||
{
|
||||
private DeleteShortUrlAction $action;
|
||||
private MockObject $service;
|
||||
private MockObject & DeleteShortUrlServiceInterface $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class EditShortUrlActionTest extends TestCase
|
||||
{
|
||||
private EditShortUrlAction $action;
|
||||
private MockObject $shortUrlService;
|
||||
private MockObject & ShortUrlServiceInterface $shortUrlService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class ListShortUrlsActionTest extends TestCase
|
||||
{
|
||||
private ListShortUrlsAction $action;
|
||||
private MockObject $service;
|
||||
private MockObject & ShortUrlService $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class ResolveShortUrlActionTest extends TestCase
|
||||
{
|
||||
private ResolveShortUrlAction $action;
|
||||
private MockObject $urlResolver;
|
||||
private MockObject & ShortUrlResolverInterface $urlResolver;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class SingleStepCreateShortUrlActionTest extends TestCase
|
||||
{
|
||||
private SingleStepCreateShortUrlAction $action;
|
||||
private MockObject $urlShortener;
|
||||
private MockObject & UrlShortenerInterface $urlShortener;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class DeleteTagsActionTest extends TestCase
|
||||
{
|
||||
private DeleteTagsAction $action;
|
||||
private MockObject $tagService;
|
||||
private MockObject & TagServiceInterface $tagService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ use function count;
|
|||
class ListTagsActionTest extends TestCase
|
||||
{
|
||||
private ListTagsAction $action;
|
||||
private MockObject $tagService;
|
||||
private MockObject & TagServiceInterface $tagService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ use function count;
|
|||
class TagsStatsActionTest extends TestCase
|
||||
{
|
||||
private TagsStatsAction $action;
|
||||
private MockObject $tagService;
|
||||
private MockObject & TagServiceInterface $tagService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class UpdateTagActionTest extends TestCase
|
||||
{
|
||||
private UpdateTagAction $action;
|
||||
private MockObject $tagService;
|
||||
private MockObject & TagServiceInterface $tagService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class DomainVisitsActionTest extends TestCase
|
||||
{
|
||||
private DomainVisitsAction $action;
|
||||
private MockObject $visitsHelper;
|
||||
private MockObject & VisitsStatsHelperInterface $visitsHelper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class GlobalVisitsActionTest extends TestCase
|
||||
{
|
||||
private GlobalVisitsAction $action;
|
||||
private MockObject $helper;
|
||||
private MockObject & VisitsStatsHelperInterface $helper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class NonOrphanVisitsActionTest extends TestCase
|
||||
{
|
||||
private NonOrphanVisitsAction $action;
|
||||
private MockObject $visitsHelper;
|
||||
private MockObject & VisitsStatsHelperInterface $visitsHelper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -22,8 +22,8 @@ use function count;
|
|||
class OrphanVisitsActionTest extends TestCase
|
||||
{
|
||||
private OrphanVisitsAction $action;
|
||||
private MockObject $visitsHelper;
|
||||
private MockObject $orphanVisitTransformer;
|
||||
private MockObject & VisitsStatsHelperInterface $visitsHelper;
|
||||
private MockObject & DataTransformerInterface $orphanVisitTransformer;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class ShortUrlVisitsActionTest extends TestCase
|
||||
{
|
||||
private ShortUrlVisitsAction $action;
|
||||
private MockObject $visitsHelper;
|
||||
private MockObject & VisitsStatsHelperInterface $visitsHelper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class TagVisitsActionTest extends TestCase
|
||||
{
|
||||
private TagVisitsAction $action;
|
||||
private MockObject $visitsHelper;
|
||||
private MockObject & VisitsStatsHelperInterface $visitsHelper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
class InitialApiKeyDelegatorTest extends TestCase
|
||||
{
|
||||
private InitialApiKeyDelegator $delegator;
|
||||
private MockObject $container;
|
||||
private MockObject & ContainerInterface $container;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue