mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Update to PHP coding standard 2.4.0
This commit is contained in:
@@ -190,7 +190,7 @@ class QrCodeActionTest extends TestCase
|
||||
#[Test, DataProvider('provideRoundBlockSize')]
|
||||
public function imageCanRemoveExtraMarginWhenBlockRoundIsDisabled(
|
||||
QrCodeOptions $defaultOptions,
|
||||
?string $roundBlockSize,
|
||||
string|null $roundBlockSize,
|
||||
int $expectedColor,
|
||||
): void {
|
||||
$code = 'abc123';
|
||||
@@ -234,7 +234,7 @@ class QrCodeActionTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideColors')]
|
||||
public function properColorsAreUsed(?string $queryColor, ?string $optionsColor, int $expectedColor): void
|
||||
public function properColorsAreUsed(string|null $queryColor, string|null $optionsColor, int $expectedColor): void
|
||||
{
|
||||
$code = 'abc123';
|
||||
$req = ServerRequestFactory::fromGlobals()
|
||||
@@ -320,7 +320,7 @@ class QrCodeActionTest extends TestCase
|
||||
yield 'only enabled short URLs' => [false];
|
||||
}
|
||||
|
||||
public function action(?QrCodeOptions $options = null): QrCodeAction
|
||||
public function action(QrCodeOptions|null $options = null): QrCodeAction
|
||||
{
|
||||
return new QrCodeAction(
|
||||
$this->urlResolver,
|
||||
|
||||
@@ -23,14 +23,14 @@ class ShortUrlMethodsProcessorTest extends TestCase
|
||||
#[Test, DataProvider('provideConfigs')]
|
||||
public function onlyFirstRouteIdentifiedAsRedirectIsEditedWithProperAllowedMethods(
|
||||
array $config,
|
||||
?array $expectedRoutes,
|
||||
array|null $expectedRoutes,
|
||||
): void {
|
||||
self::assertEquals($expectedRoutes, ($this->processor)($config)['routes'] ?? null);
|
||||
}
|
||||
|
||||
public static function provideConfigs(): iterable
|
||||
{
|
||||
$buildConfigWithStatus = static fn (int $status, ?array $expectedAllowedMethods) => [[
|
||||
$buildConfigWithStatus = static fn (int $status, array|null $expectedAllowedMethods) => [[
|
||||
'routes' => [
|
||||
['name' => 'foo'],
|
||||
['name' => 'bar'],
|
||||
|
||||
@@ -33,7 +33,7 @@ class DomainServiceTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideExcludedDomains')]
|
||||
public function listDomainsDelegatesIntoRepository(array $domains, array $expectedResult, ?ApiKey $apiKey): void
|
||||
public function listDomainsDelegatesIntoRepository(array $domains, array $expectedResult, ApiKey|null $apiKey): void
|
||||
{
|
||||
$repo = $this->createMock(DomainRepository::class);
|
||||
$repo->expects($this->once())->method('findDomains')->with($apiKey)->willReturn($domains);
|
||||
@@ -124,7 +124,7 @@ class DomainServiceTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideFoundDomains')]
|
||||
public function getOrCreateAlwaysPersistsDomain(?Domain $foundDomain, ?ApiKey $apiKey): void
|
||||
public function getOrCreateAlwaysPersistsDomain(Domain|null $foundDomain, ApiKey|null $apiKey): void
|
||||
{
|
||||
$authority = 'example.com';
|
||||
$repo = $this->createMock(DomainRepository::class);
|
||||
@@ -161,8 +161,10 @@ class DomainServiceTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideFoundDomains')]
|
||||
public function configureNotFoundRedirectsConfiguresFetchedDomain(?Domain $foundDomain, ?ApiKey $apiKey): void
|
||||
{
|
||||
public function configureNotFoundRedirectsConfiguresFetchedDomain(
|
||||
Domain|null $foundDomain,
|
||||
ApiKey|null $apiKey,
|
||||
): void {
|
||||
$authority = 'example.com';
|
||||
$repo = $this->createMock(DomainRepository::class);
|
||||
$repo->method('findOneByAuthority')->with($authority, $apiKey)->willReturn($foundDomain);
|
||||
|
||||
@@ -155,7 +155,7 @@ class LocateVisitTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideIpAddresses')]
|
||||
public function locatableVisitsResolveToLocation(Visit $visit, ?string $originalIpAddress): void
|
||||
public function locatableVisitsResolveToLocation(Visit $visit, string|null $originalIpAddress): void
|
||||
{
|
||||
$ipAddr = $originalIpAddress ?? $visit->remoteAddr;
|
||||
$location = new Location('', '', '', '', 0.0, 0.0, '');
|
||||
|
||||
@@ -57,7 +57,7 @@ class SendVisitToMatomoTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideOriginalIpAddress')]
|
||||
public function visitIsSentWhenItExists(?string $originalIpAddress): void
|
||||
public function visitIsSentWhenItExists(string|null $originalIpAddress): void
|
||||
{
|
||||
$visitId = '123';
|
||||
$visit = Visit::forBasePath(Visitor::emptyInstance());
|
||||
|
||||
@@ -41,7 +41,7 @@ class PublishingUpdatesGeneratorTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideMethod')]
|
||||
public function visitIsProperlySerializedIntoUpdate(string $method, string $expectedTopic, ?string $title): void
|
||||
public function visitIsProperlySerializedIntoUpdate(string $method, string $expectedTopic, string|null $title): void
|
||||
{
|
||||
$shortUrl = ShortUrl::create(ShortUrlCreation::fromRawData([
|
||||
'customSlug' => 'foo',
|
||||
|
||||
@@ -179,7 +179,7 @@ class NotifyVisitToRabbitMqTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
private function listener(?RabbitMqOptions $options = null): NotifyVisitToRabbitMq
|
||||
private function listener(RabbitMqOptions|null $options = null): NotifyVisitToRabbitMq
|
||||
{
|
||||
return new NotifyVisitToRabbitMq(
|
||||
$this->helper,
|
||||
|
||||
@@ -77,7 +77,7 @@ class UpdateGeoLiteDbTest extends TestCase
|
||||
int $total,
|
||||
int $downloaded,
|
||||
bool $oldDbExists,
|
||||
?string $expectedMessage,
|
||||
string|null $expectedMessage,
|
||||
): void {
|
||||
$this->dbUpdater->expects($this->once())->method('checkDbUpdate')->withAnyParameters()->willReturnCallback(
|
||||
function ($_, callable $secondCallback) use ($total, $downloaded, $oldDbExists): GeolocationResult {
|
||||
|
||||
@@ -12,7 +12,7 @@ use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException;
|
||||
class NonUniqueSlugExceptionTest extends TestCase
|
||||
{
|
||||
#[Test, DataProvider('provideMessages')]
|
||||
public function properlyCreatesExceptionFromSlug(string $expectedMessage, string $slug, ?string $domain): void
|
||||
public function properlyCreatesExceptionFromSlug(string $expectedMessage, string $slug, string|null $domain): void
|
||||
{
|
||||
$expectedAdditional = ['customSlug' => $slug];
|
||||
if ($domain !== null) {
|
||||
|
||||
@@ -16,7 +16,7 @@ class ShortUrlNotFoundExceptionTest extends TestCase
|
||||
public function properlyCreatesExceptionFromNotFoundShortCode(
|
||||
string $expectedMessage,
|
||||
string $shortCode,
|
||||
?string $domain,
|
||||
string|null $domain,
|
||||
): void {
|
||||
$expectedAdditional = ['shortCode' => $shortCode];
|
||||
if ($domain !== null) {
|
||||
|
||||
@@ -20,7 +20,7 @@ use function print_r;
|
||||
class ValidationExceptionTest extends TestCase
|
||||
{
|
||||
#[Test, DataProvider('provideExceptions')]
|
||||
public function createsExceptionFromInputFilter(?Throwable $prev): void
|
||||
public function createsExceptionFromInputFilter(Throwable|null $prev): void
|
||||
{
|
||||
$invalidData = [
|
||||
'foo' => 'bar',
|
||||
|
||||
@@ -127,7 +127,7 @@ class ImportedLinksProcessorTest extends TestCase
|
||||
|
||||
$this->em->method('getRepository')->with(ShortUrl::class)->willReturn($this->repo);
|
||||
$this->repo->expects($this->exactly(count($urls)))->method('findOneByImportedUrl')->willReturnCallback(
|
||||
fn (ImportedShlinkUrl $url): ?ShortUrl => contains(
|
||||
fn (ImportedShlinkUrl $url): ShortUrl|null => contains(
|
||||
$url->longUrl,
|
||||
['https://foo', 'https://baz2', 'https://baz3'],
|
||||
) ? ShortUrl::fromImport($url, true) : null,
|
||||
@@ -175,7 +175,7 @@ class ImportedLinksProcessorTest extends TestCase
|
||||
ImportedShlinkUrl $importedUrl,
|
||||
string $expectedOutput,
|
||||
int $amountOfPersistedVisits,
|
||||
?ShortUrl $foundShortUrl,
|
||||
ShortUrl|null $foundShortUrl,
|
||||
): void {
|
||||
$this->em->method('getRepository')->with(ShortUrl::class)->willReturn($this->repo);
|
||||
$this->repo->expects($this->once())->method('findOneByImportedUrl')->willReturn($foundShortUrl);
|
||||
@@ -232,7 +232,7 @@ class ImportedLinksProcessorTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideFoundShortUrls')]
|
||||
public function visitsArePersistedWithProperShortUrl(ShortUrl $originalShortUrl, ?ShortUrl $foundShortUrl): void
|
||||
public function visitsArePersistedWithProperShortUrl(ShortUrl $originalShortUrl, ShortUrl|null $foundShortUrl): void
|
||||
{
|
||||
$this->em->method('getRepository')->with(ShortUrl::class)->willReturn($this->repo);
|
||||
$this->repo->expects($this->once())->method('findOneByImportedUrl')->willReturn($originalShortUrl);
|
||||
@@ -273,7 +273,7 @@ class ImportedLinksProcessorTest extends TestCase
|
||||
public function properAmountOfOrphanVisitsIsImported(
|
||||
bool $importOrphanVisits,
|
||||
iterable $visits,
|
||||
?Visit $lastOrphanVisit,
|
||||
Visit|null $lastOrphanVisit,
|
||||
int $expectedImportedVisits,
|
||||
): void {
|
||||
$this->io->expects($this->exactly($importOrphanVisits ? 2 : 1))->method('title');
|
||||
|
||||
@@ -43,7 +43,7 @@ class MatomoTrackerBuilderTest extends TestCase
|
||||
self::assertEquals(MatomoTrackerBuilder::MATOMO_DEFAULT_TIMEOUT, $tracker->getRequestConnectTimeout());
|
||||
}
|
||||
|
||||
private function builder(?MatomoOptions $options = null): MatomoTrackerBuilder
|
||||
private function builder(MatomoOptions|null $options = null): MatomoTrackerBuilder
|
||||
{
|
||||
$options ??= new MatomoOptions(enabled: true, baseUrl: 'base_url', siteId: 5, apiToken: 'api_token');
|
||||
return new MatomoTrackerBuilder($options);
|
||||
|
||||
@@ -43,7 +43,7 @@ class MatomoVisitSenderTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideTrackerMethods')]
|
||||
public function visitIsSentToMatomo(Visit $visit, ?string $originalIpAddress, array $invokedMethods): void
|
||||
public function visitIsSentToMatomo(Visit $visit, string|null $originalIpAddress, array $invokedMethods): void
|
||||
{
|
||||
$tracker = $this->createMock(MatomoTracker::class);
|
||||
$tracker->expects($this->once())->method('setUrl')->willReturn($tracker);
|
||||
|
||||
@@ -42,7 +42,7 @@ class RedirectConditionTest extends TestCase
|
||||
#[TestWith(['en-UK', 'en', true], 'only lang')]
|
||||
#[TestWith(['es-AR', 'en', false], 'different only lang')]
|
||||
#[TestWith(['fr', 'fr-FR', false], 'less restrictive matching locale')]
|
||||
public function matchesLanguage(?string $acceptLanguage, string $value, bool $expected): void
|
||||
public function matchesLanguage(string|null $acceptLanguage, string $value, bool $expected): void
|
||||
{
|
||||
$request = ServerRequestFactory::fromGlobals();
|
||||
if ($acceptLanguage !== null) {
|
||||
@@ -62,7 +62,7 @@ class RedirectConditionTest extends TestCase
|
||||
#[TestWith([IOS_USER_AGENT, DeviceType::IOS, true])]
|
||||
#[TestWith([IOS_USER_AGENT, DeviceType::ANDROID, false])]
|
||||
#[TestWith([DESKTOP_USER_AGENT, DeviceType::IOS, false])]
|
||||
public function matchesDevice(?string $userAgent, DeviceType $value, bool $expected): void
|
||||
public function matchesDevice(string|null $userAgent, DeviceType $value, bool $expected): void
|
||||
{
|
||||
$request = ServerRequestFactory::fromGlobals();
|
||||
if ($userAgent !== null) {
|
||||
@@ -82,7 +82,7 @@ class RedirectConditionTest extends TestCase
|
||||
#[TestWith(['1.2.3.4', '192.168.1.0/24', false], 'no CIDR block match')]
|
||||
#[TestWith(['192.168.1.35', '192.168.1.*', true], 'wildcard pattern match')]
|
||||
#[TestWith(['1.2.3.4', '192.168.1.*', false], 'no wildcard pattern match')]
|
||||
public function matchesRemoteIpAddress(?string $remoteIp, string $ipToMatch, bool $expected): void
|
||||
public function matchesRemoteIpAddress(string|null $remoteIp, string $ipToMatch, bool $expected): void
|
||||
{
|
||||
$request = ServerRequestFactory::fromGlobals();
|
||||
if ($remoteIp !== null) {
|
||||
|
||||
@@ -36,7 +36,7 @@ class ShortUrlRedirectionResolverTest extends TestCase
|
||||
#[Test, DataProvider('provideData')]
|
||||
public function resolveLongUrlReturnsExpectedValue(
|
||||
ServerRequestInterface $request,
|
||||
?RedirectCondition $condition,
|
||||
RedirectCondition|null $condition,
|
||||
string $expectedUrl,
|
||||
): void {
|
||||
$shortUrl = ShortUrl::create(ShortUrlCreation::fromRawData([
|
||||
|
||||
@@ -75,7 +75,7 @@ class ShortUrlTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideLengths')]
|
||||
public function shortCodesHaveExpectedLength(?int $length, int $expectedLength): void
|
||||
public function shortCodesHaveExpectedLength(int|null $length, int $expectedLength): void
|
||||
{
|
||||
$shortUrl = ShortUrl::create(ShortUrlCreation::fromRawData(
|
||||
[ShortUrlInputFilter::SHORT_CODE_LENGTH => $length, 'longUrl' => 'https://longUrl'],
|
||||
@@ -94,7 +94,7 @@ class ShortUrlTest extends TestCase
|
||||
#[TestWith([null, '', 5])]
|
||||
#[TestWith(['foo bar/', 'foo-bar-', 13])]
|
||||
public function shortCodesHaveExpectedPrefix(
|
||||
?string $pathPrefix,
|
||||
string|null $pathPrefix,
|
||||
string $expectedPrefix,
|
||||
int $expectedShortCodeLength,
|
||||
): void {
|
||||
|
||||
@@ -32,7 +32,7 @@ class ShortCodeUniquenessHelperTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideDomains')]
|
||||
public function shortCodeIsRegeneratedIfAlreadyInUse(?Domain $domain, ?string $expectedAuthority): void
|
||||
public function shortCodeIsRegeneratedIfAlreadyInUse(Domain|null $domain, string|null $expectedAuthority): void
|
||||
{
|
||||
$callIndex = 0;
|
||||
$expectedCalls = 3;
|
||||
|
||||
@@ -35,8 +35,8 @@ class ShortUrlRedirectionBuilderTest extends TestCase
|
||||
public function buildShortUrlRedirectBuildsExpectedUrl(
|
||||
string $expectedUrl,
|
||||
ServerRequestInterface $request,
|
||||
?string $extraPath,
|
||||
?bool $forwardQuery,
|
||||
string|null $extraPath,
|
||||
bool|null $forwardQuery,
|
||||
): void {
|
||||
$shortUrl = ShortUrl::create(ShortUrlCreation::fromRawData([
|
||||
'longUrl' => 'https://example.com/foo/bar?some=thing',
|
||||
|
||||
@@ -32,7 +32,7 @@ class ShortUrlStringifierTest extends TestCase
|
||||
|
||||
public static function provideConfigAndShortUrls(): iterable
|
||||
{
|
||||
$shortUrlWithShortCode = fn (string $shortCode, ?string $domain = null) => ShortUrl::create(
|
||||
$shortUrlWithShortCode = fn (string $shortCode, string|null $domain = null) => ShortUrl::create(
|
||||
ShortUrlCreation::fromRawData([
|
||||
'longUrl' => 'https://longUrl',
|
||||
'customSlug' => $shortCode,
|
||||
|
||||
@@ -70,7 +70,7 @@ class ExtraPathRedirectMiddlewareTest extends TestCase
|
||||
public static function provideNonRedirectingRequests(): iterable
|
||||
{
|
||||
$baseReq = ServerRequestFactory::fromGlobals();
|
||||
$buildReq = static fn (?NotFoundType $type): ServerRequestInterface =>
|
||||
$buildReq = static fn (NotFoundType|null $type): ServerRequestInterface =>
|
||||
$baseReq->withAttribute(NotFoundType::class, $type);
|
||||
|
||||
yield 'disabled option' => [false, false, $buildReq(NotFoundType::fromRequest($baseReq, '/foo/bar'))];
|
||||
@@ -127,7 +127,7 @@ class ExtraPathRedirectMiddlewareTest extends TestCase
|
||||
public function visitIsTrackedAndRedirectIsReturnedWhenShortUrlIsFoundAfterExpectedAmountOfIterations(
|
||||
bool $multiSegmentEnabled,
|
||||
int $expectedResolveCalls,
|
||||
?string $expectedExtraPath,
|
||||
string|null $expectedExtraPath,
|
||||
): void {
|
||||
$options = new UrlShortenerOptions(appendExtraPath: true, multiSegmentSlugsEnabled: $multiSegmentEnabled);
|
||||
|
||||
@@ -170,7 +170,7 @@ class ExtraPathRedirectMiddlewareTest extends TestCase
|
||||
yield [true, 3, null];
|
||||
}
|
||||
|
||||
private function middleware(?UrlShortenerOptions $options = null): ExtraPathRedirectMiddleware
|
||||
private function middleware(UrlShortenerOptions|null $options = null): ExtraPathRedirectMiddleware
|
||||
{
|
||||
return new ExtraPathRedirectMiddleware(
|
||||
$this->resolver,
|
||||
|
||||
@@ -147,7 +147,7 @@ class ShortUrlCreationTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideTitles')]
|
||||
public function titleIsCroppedIfTooLong(?string $title, ?string $expectedTitle): void
|
||||
public function titleIsCroppedIfTooLong(string|null $title, string|null $expectedTitle): void
|
||||
{
|
||||
$creation = ShortUrlCreation::fromRawData([
|
||||
'title' => $title,
|
||||
@@ -170,7 +170,7 @@ class ShortUrlCreationTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideDomains')]
|
||||
public function emptyDomainIsDiscarded(?string $domain, ?string $expectedDomain): void
|
||||
public function emptyDomainIsDiscarded(string|null $domain, string|null $expectedDomain): void
|
||||
{
|
||||
$creation = ShortUrlCreation::fromRawData([
|
||||
'domain' => $domain,
|
||||
|
||||
@@ -28,11 +28,11 @@ class ShortUrlRepositoryAdapterTest extends TestCase
|
||||
|
||||
#[Test, DataProvider('provideFilteringArgs')]
|
||||
public function getItemsFallsBackToFindList(
|
||||
?string $searchTerm = null,
|
||||
string|null $searchTerm = null,
|
||||
array $tags = [],
|
||||
?string $startDate = null,
|
||||
?string $endDate = null,
|
||||
?string $orderBy = null,
|
||||
string|null $startDate = null,
|
||||
string|null $endDate = null,
|
||||
string|null $orderBy = null,
|
||||
): void {
|
||||
$params = ShortUrlsParams::fromRawData([
|
||||
'searchTerm' => $searchTerm,
|
||||
@@ -54,10 +54,10 @@ class ShortUrlRepositoryAdapterTest extends TestCase
|
||||
|
||||
#[Test, DataProvider('provideFilteringArgs')]
|
||||
public function countFallsBackToCountList(
|
||||
?string $searchTerm = null,
|
||||
string|null $searchTerm = null,
|
||||
array $tags = [],
|
||||
?string $startDate = null,
|
||||
?string $endDate = null,
|
||||
string|null $startDate = null,
|
||||
string|null $endDate = null,
|
||||
): void {
|
||||
$params = ShortUrlsParams::fromRawData([
|
||||
'searchTerm' => $searchTerm,
|
||||
|
||||
@@ -33,7 +33,7 @@ class PersistenceShortUrlRelationResolverTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideDomainsThatEmpty')]
|
||||
public function returnsEmptyInSomeCases(?string $domain): void
|
||||
public function returnsEmptyInSomeCases(string|null $domain): void
|
||||
{
|
||||
$this->em->expects($this->never())->method('getRepository')->with(Domain::class);
|
||||
self::assertNull($this->resolver->resolveDomain($domain));
|
||||
@@ -46,7 +46,7 @@ class PersistenceShortUrlRelationResolverTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideFoundDomains')]
|
||||
public function findsOrCreatesDomainWhenValueIsProvided(?Domain $foundDomain, string $authority): void
|
||||
public function findsOrCreatesDomainWhenValueIsProvided(Domain|null $foundDomain, string $authority): void
|
||||
{
|
||||
$repo = $this->createMock(DomainRepository::class);
|
||||
$repo->expects($this->once())->method('findOneBy')->with(['authority' => $authority])->willReturn($foundDomain);
|
||||
@@ -79,7 +79,7 @@ class PersistenceShortUrlRelationResolverTest extends TestCase
|
||||
$tagRepo = $this->createMock(TagRepository::class);
|
||||
$tagRepo->expects($this->exactly($expectedLookedOutTags))->method('findOneBy')->with(
|
||||
$this->isType('array'),
|
||||
)->willReturnCallback(function (array $criteria): ?Tag {
|
||||
)->willReturnCallback(function (array $criteria): Tag|null {
|
||||
['name' => $name] = $criteria;
|
||||
return $name === 'foo' ? new Tag($name) : null;
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ class SimpleShortUrlRelationResolverTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideDomains')]
|
||||
public function resolvesExpectedDomain(?string $domain): void
|
||||
public function resolvesExpectedDomain(string|null $domain): void
|
||||
{
|
||||
$result = $this->resolver->resolveDomain($domain);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class ShortUrlListServiceTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProviderExternal(ApiKeyDataProviders::class, 'adminApiKeysProvider')]
|
||||
public function listedUrlsAreReturnedFromEntityManager(?ApiKey $apiKey): void
|
||||
public function listedUrlsAreReturnedFromEntityManager(ApiKey|null $apiKey): void
|
||||
{
|
||||
$list = [
|
||||
ShortUrl::createFake(),
|
||||
|
||||
@@ -42,7 +42,7 @@ class ShortUrlResolverTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProviderExternal(ApiKeyDataProviders::class, 'adminApiKeysProvider')]
|
||||
public function shortCodeIsProperlyParsed(?ApiKey $apiKey): void
|
||||
public function shortCodeIsProperlyParsed(ApiKey|null $apiKey): void
|
||||
{
|
||||
$shortUrl = ShortUrl::withLongUrl('https://expected_url');
|
||||
$shortCode = $shortUrl->getShortCode();
|
||||
@@ -59,7 +59,7 @@ class ShortUrlResolverTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProviderExternal(ApiKeyDataProviders::class, 'adminApiKeysProvider')]
|
||||
public function exceptionIsThrownIfShortCodeIsNotFound(?ApiKey $apiKey): void
|
||||
public function exceptionIsThrownIfShortCodeIsNotFound(ApiKey|null $apiKey): void
|
||||
{
|
||||
$shortCode = 'abc123';
|
||||
$identifier = ShortUrlIdentifier::fromShortCodeAndDomain($shortCode);
|
||||
|
||||
@@ -48,7 +48,7 @@ class ShortUrlServiceTest extends TestCase
|
||||
public function updateShortUrlUpdatesProvidedData(
|
||||
InvocationOrder $expectedValidateCalls,
|
||||
ShortUrlEdition $shortUrlEdit,
|
||||
?ApiKey $apiKey,
|
||||
ApiKey|null $apiKey,
|
||||
): void {
|
||||
$originalLongUrl = 'https://originalLongUrl';
|
||||
$shortUrl = ShortUrl::withLongUrl($originalLongUrl);
|
||||
|
||||
@@ -55,7 +55,7 @@ class TagServiceTest extends TestCase
|
||||
|
||||
#[Test, DataProvider('provideApiKeysAndSearchTerm')]
|
||||
public function tagsInfoDelegatesOnRepository(
|
||||
?ApiKey $apiKey,
|
||||
ApiKey|null $apiKey,
|
||||
TagsParams $params,
|
||||
TagsListFiltering $expectedFiltering,
|
||||
int $countCalls,
|
||||
@@ -101,7 +101,7 @@ class TagServiceTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProviderExternal(ApiKeyDataProviders::class, 'adminApiKeysProvider')]
|
||||
public function deleteTagsDelegatesOnRepository(?ApiKey $apiKey): void
|
||||
public function deleteTagsDelegatesOnRepository(ApiKey|null $apiKey): void
|
||||
{
|
||||
$this->repo->expects($this->once())->method('deleteByName')->with(['foo', 'bar'])->willReturn(4);
|
||||
$this->service->deleteTags(['foo', 'bar'], $apiKey);
|
||||
@@ -122,7 +122,7 @@ class TagServiceTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProviderExternal(ApiKeyDataProviders::class, 'adminApiKeysProvider')]
|
||||
public function renameInvalidTagThrowsException(?ApiKey $apiKey): void
|
||||
public function renameInvalidTagThrowsException(ApiKey|null $apiKey): void
|
||||
{
|
||||
$this->repo->expects($this->once())->method('findOneBy')->willReturn(null);
|
||||
$this->expectException(TagNotFoundException::class);
|
||||
@@ -152,7 +152,7 @@ class TagServiceTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProviderExternal(ApiKeyDataProviders::class, 'adminApiKeysProvider')]
|
||||
public function renameTagToAnExistingNameThrowsException(?ApiKey $apiKey): void
|
||||
public function renameTagToAnExistingNameThrowsException(ApiKey|null $apiKey): void
|
||||
{
|
||||
$this->repo->expects($this->once())->method('findOneBy')->willReturn(new Tag('foo'));
|
||||
$this->repo->expects($this->once())->method('count')->willReturn(1);
|
||||
|
||||
@@ -18,7 +18,7 @@ class RedirectResponseHelperTest extends TestCase
|
||||
int $configuredStatus,
|
||||
int $configuredLifetime,
|
||||
int $expectedStatus,
|
||||
?string $expectedCacheControl,
|
||||
string|null $expectedCacheControl,
|
||||
): void {
|
||||
$options = new RedirectOptions($configuredStatus, $configuredLifetime);
|
||||
|
||||
@@ -46,7 +46,7 @@ class RedirectResponseHelperTest extends TestCase
|
||||
yield 'status 308 with negative expiration' => [308, -20, 308, 'private,max-age=30'];
|
||||
}
|
||||
|
||||
private function helper(?RedirectOptions $options = null): RedirectResponseHelper
|
||||
private function helper(RedirectOptions|null $options = null): RedirectResponseHelper
|
||||
{
|
||||
return new RedirectResponseHelper($options ?? new RedirectOptions());
|
||||
}
|
||||
|
||||
@@ -103,8 +103,11 @@ class VisitTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideAddresses')]
|
||||
public function addressIsAnonymizedWhenRequested(bool $anonymize, ?string $address, ?string $expectedAddress): void
|
||||
{
|
||||
public function addressIsAnonymizedWhenRequested(
|
||||
bool $anonymize,
|
||||
string|null $address,
|
||||
string|null $expectedAddress,
|
||||
): void {
|
||||
$visit = Visit::forValidShortUrl(
|
||||
ShortUrl::createFake(),
|
||||
new Visitor('Chrome', 'some site', $address, ''),
|
||||
|
||||
@@ -58,7 +58,7 @@ class ShortUrlVisitsPaginatorAdapterTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
private function createAdapter(?ApiKey $apiKey): ShortUrlVisitsPaginatorAdapter
|
||||
private function createAdapter(ApiKey|null $apiKey): ShortUrlVisitsPaginatorAdapter
|
||||
{
|
||||
return new ShortUrlVisitsPaginatorAdapter(
|
||||
$this->repo,
|
||||
|
||||
@@ -57,7 +57,7 @@ class VisitsForTagPaginatorAdapterTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
private function createAdapter(?ApiKey $apiKey): TagVisitsPaginatorAdapter
|
||||
private function createAdapter(ApiKey|null $apiKey): TagVisitsPaginatorAdapter
|
||||
{
|
||||
return new TagVisitsPaginatorAdapter($this->repo, 'foo', VisitsParams::fromRawData([]), $apiKey);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideCounts')]
|
||||
public function returnsExpectedVisitsStats(int $expectedCount, ?ApiKey $apiKey): void
|
||||
public function returnsExpectedVisitsStats(int $expectedCount, ApiKey|null $apiKey): void
|
||||
{
|
||||
$callCount = 0;
|
||||
$visitsCountRepo = $this->createMock(ShortUrlVisitsCountRepository::class);
|
||||
@@ -94,7 +94,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProviderExternal(ApiKeyDataProviders::class, 'adminApiKeysProvider')]
|
||||
public function infoReturnsVisitsForCertainShortCode(?ApiKey $apiKey): void
|
||||
public function infoReturnsVisitsForCertainShortCode(ApiKey|null $apiKey): void
|
||||
{
|
||||
$shortCode = '123ABC';
|
||||
$identifier = ShortUrlIdentifier::fromShortCodeAndDomain($shortCode);
|
||||
@@ -157,7 +157,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProviderExternal(ApiKeyDataProviders::class, 'adminApiKeysProvider')]
|
||||
public function visitsForTagAreReturnedAsExpected(?ApiKey $apiKey): void
|
||||
public function visitsForTagAreReturnedAsExpected(ApiKey|null $apiKey): void
|
||||
{
|
||||
$tag = 'foo';
|
||||
$repo = $this->createMock(TagRepository::class);
|
||||
@@ -198,7 +198,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProviderExternal(ApiKeyDataProviders::class, 'adminApiKeysProvider')]
|
||||
public function visitsForNonDefaultDomainAreReturnedAsExpected(?ApiKey $apiKey): void
|
||||
public function visitsForNonDefaultDomainAreReturnedAsExpected(ApiKey|null $apiKey): void
|
||||
{
|
||||
$domain = 'foo.com';
|
||||
$repo = $this->createMock(DomainRepository::class);
|
||||
@@ -229,7 +229,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProviderExternal(ApiKeyDataProviders::class, 'adminApiKeysProvider')]
|
||||
public function visitsForDefaultDomainAreReturnedAsExpected(?ApiKey $apiKey): void
|
||||
public function visitsForDefaultDomainAreReturnedAsExpected(ApiKey|null $apiKey): void
|
||||
{
|
||||
$repo = $this->createMock(DomainRepository::class);
|
||||
$repo->expects($this->never())->method('domainExists');
|
||||
|
||||
@@ -79,7 +79,7 @@ class VisitsTrackerTest extends TestCase
|
||||
yield 'trackRegularNotFoundVisit' => ['trackRegularNotFoundVisit'];
|
||||
}
|
||||
|
||||
private function visitsTracker(?TrackingOptions $options = null): VisitsTracker
|
||||
private function visitsTracker(TrackingOptions|null $options = null): VisitsTracker
|
||||
{
|
||||
return new VisitsTracker($this->em, $this->eventDispatcher, $options ?? new TrackingOptions());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user