Fixed all phpstan inspections on tests

This commit is contained in:
Alejandro Celaya
2022-10-24 20:11:25 +02:00
parent 1650499a38
commit 85e18a4754
10 changed files with 36 additions and 19 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -37,7 +37,10 @@ class CreateShortUrlCommandTest extends TestCase
$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);
}

View File

@@ -31,8 +31,6 @@ class GeolocationDbUpdaterTest extends TestCase
{
$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);
}