mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-21 22:53:52 -06:00
Added stricter types for mocks
This commit is contained in:
parent
aeafb244d9
commit
51f243995a
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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,12 +26,12 @@ 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(
|
||||
|
@ -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 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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -30,8 +30,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
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ use Shlinkio\Shlink\Rest\Middleware\CrossDomainMiddleware;
|
||||
class CrossDomainMiddlewareTest extends TestCase
|
||||
{
|
||||
private CrossDomainMiddleware $middleware;
|
||||
private MockObject $handler;
|
||||
private MockObject & RequestHandlerInterface $handler;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -17,9 +17,9 @@ use Shlinkio\Shlink\Rest\Middleware\Mercure\NotConfiguredMercureErrorHandler;
|
||||
class NotConfiguredMercureErrorHandlerTest extends TestCase
|
||||
{
|
||||
private NotConfiguredMercureErrorHandler $middleware;
|
||||
private MockObject $respFactory;
|
||||
private MockObject $logger;
|
||||
private MockObject $handler;
|
||||
private MockObject & ProblemDetailsResponseFactory $respFactory;
|
||||
private MockObject & LoggerInterface $logger;
|
||||
private MockObject & RequestHandlerInterface $handler;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ use Shlinkio\Shlink\Rest\Middleware\ShortUrl\CreateShortUrlContentNegotiationMid
|
||||
class CreateShortUrlContentNegotiationMiddlewareTest extends TestCase
|
||||
{
|
||||
private CreateShortUrlContentNegotiationMiddleware $middleware;
|
||||
private MockObject $requestHandler;
|
||||
private MockObject & RequestHandlerInterface $requestHandler;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ use Shlinkio\Shlink\Rest\Middleware\ShortUrl\DefaultShortCodesLengthMiddleware;
|
||||
class DefaultShortCodesLengthMiddlewareTest extends TestCase
|
||||
{
|
||||
private DefaultShortCodesLengthMiddleware $middleware;
|
||||
private MockObject $handler;
|
||||
private MockObject & RequestHandlerInterface $handler;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
@ -34,7 +34,7 @@ class DefaultShortCodesLengthMiddlewareTest extends TestCase
|
||||
$request = ServerRequestFactory::fromGlobals()->withParsedBody($body);
|
||||
$this->handler->expects($this->once())->method('handle')->with($this->callback(
|
||||
function (ServerRequestInterface $req) use ($expectedLength) {
|
||||
$parsedBody = $req->getParsedBody();
|
||||
$parsedBody = (array) $req->getParsedBody();
|
||||
Assert::assertArrayHasKey(ShortUrlInputFilter::SHORT_CODE_LENGTH, $parsedBody);
|
||||
Assert::assertEquals($expectedLength, $parsedBody[ShortUrlInputFilter::SHORT_CODE_LENGTH]);
|
||||
|
||||
|
@ -16,7 +16,7 @@ use Shlinkio\Shlink\Rest\Middleware\ShortUrl\DropDefaultDomainFromRequestMiddlew
|
||||
class DropDefaultDomainFromRequestMiddlewareTest extends TestCase
|
||||
{
|
||||
private DropDefaultDomainFromRequestMiddleware $middleware;
|
||||
private MockObject $next;
|
||||
private MockObject & RequestHandlerInterface $next;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -21,9 +21,9 @@ use Shlinkio\Shlink\Rest\Middleware\ShortUrl\OverrideDomainMiddleware;
|
||||
class OverrideDomainMiddlewareTest extends TestCase
|
||||
{
|
||||
private OverrideDomainMiddleware $middleware;
|
||||
private MockObject $domainService;
|
||||
private MockObject $apiKey;
|
||||
private MockObject $handler;
|
||||
private MockObject & DomainServiceInterface $domainService;
|
||||
private MockObject & ApiKey $apiKey;
|
||||
private MockObject & RequestHandlerInterface $handler;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -19,8 +19,8 @@ use Shlinkio\Shlink\Rest\Service\ApiKeyService;
|
||||
class ApiKeyServiceTest extends TestCase
|
||||
{
|
||||
private ApiKeyService $service;
|
||||
private MockObject $em;
|
||||
private MockObject $repo;
|
||||
private MockObject & EntityManager $em;
|
||||
private MockObject & EntityRepository $repo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
@ -50,10 +50,13 @@ class ApiKeyServiceTest extends TestCase
|
||||
|
||||
public function provideCreationDate(): iterable
|
||||
{
|
||||
$domain = Domain::withAuthority('');
|
||||
$domain->setId('123');
|
||||
|
||||
yield 'no expiration date or name' => [null, null, []];
|
||||
yield 'expiration date' => [Chronos::parse('2030-01-01'), null, []];
|
||||
yield 'roles' => [null, null, [
|
||||
RoleDefinition::forDomain(Domain::withAuthority('')->setId('123')),
|
||||
RoleDefinition::forDomain($domain),
|
||||
RoleDefinition::forAuthoredShortUrls(),
|
||||
]];
|
||||
yield 'single name' => [null, 'Alice', []];
|
||||
|
@ -1,6 +1,8 @@
|
||||
includes:
|
||||
- vendor/phpstan/phpstan-doctrine/extension.neon
|
||||
- vendor/phpstan/phpstan-symfony/extension.neon
|
||||
- vendor/phpstan/phpstan-phpunit/extension.neon
|
||||
- vendor/phpstan/phpstan-phpunit/rules.neon
|
||||
parameters:
|
||||
checkMissingIterableValueType: false
|
||||
checkGenericClassInNonGenericObjectType: false
|
||||
|
Loading…
Reference in New Issue
Block a user