Merge pull request #853 from dlondero/phpunit-static-assertions

PHPUnit static assertions
This commit is contained in:
Alejandro Celaya 2020-10-04 09:44:18 +02:00 committed by GitHub
commit c7f15b77fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 568 additions and 568 deletions

View file

@ -37,7 +37,7 @@ class DisableKeyCommandTest extends TestCase
]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('API key "abcd1234" properly disabled', $output);
self::assertStringContainsString('API key "abcd1234" properly disabled', $output);
}
/** @test */
@ -52,7 +52,7 @@ class DisableKeyCommandTest extends TestCase
]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString($expectedMessage, $output);
self::assertStringContainsString($expectedMessage, $output);
$disable->shouldHaveBeenCalledOnce();
}
}

View file

@ -36,7 +36,7 @@ class GenerateKeyCommandTest extends TestCase
$this->commandTester->execute([]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('Generated API key: ', $output);
self::assertStringContainsString('Generated API key: ', $output);
$create->shouldHaveBeenCalledOnce();
}

View file

@ -38,11 +38,11 @@ class ListKeysCommandTest extends TestCase
$this->commandTester->execute([]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('Key', $output);
$this->assertStringContainsString('Is enabled', $output);
$this->assertStringContainsString(' +++ ', $output);
$this->assertStringNotContainsString(' --- ', $output);
$this->assertStringContainsString('Expiration date', $output);
self::assertStringContainsString('Key', $output);
self::assertStringContainsString('Is enabled', $output);
self::assertStringContainsString(' +++ ', $output);
self::assertStringNotContainsString(' --- ', $output);
self::assertStringContainsString('Expiration date', $output);
}
/** @test */
@ -58,10 +58,10 @@ class ListKeysCommandTest extends TestCase
]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('Key', $output);
$this->assertStringNotContainsString('Is enabled', $output);
$this->assertStringNotContainsString(' +++ ', $output);
$this->assertStringNotContainsString(' --- ', $output);
$this->assertStringContainsString('Expiration date', $output);
self::assertStringContainsString('Key', $output);
self::assertStringNotContainsString('Is enabled', $output);
self::assertStringNotContainsString(' +++ ', $output);
self::assertStringNotContainsString(' --- ', $output);
self::assertStringContainsString('Expiration date', $output);
}
}

View file

@ -77,7 +77,7 @@ class CreateDatabaseCommandTest extends TestCase
$this->commandTester->execute([]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('Database already exists. Run "db:migrate" command', $output);
self::assertStringContainsString('Database already exists. Run "db:migrate" command', $output);
$getDatabase->shouldHaveBeenCalledOnce();
$listDatabases->shouldHaveBeenCalledOnce();
$createDatabase->shouldNotHaveBeenCalled();
@ -121,8 +121,8 @@ class CreateDatabaseCommandTest extends TestCase
$this->commandTester->execute([]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('Creating database tables...', $output);
$this->assertStringContainsString('Database properly created!', $output);
self::assertStringContainsString('Creating database tables...', $output);
self::assertStringContainsString('Database properly created!', $output);
$getDatabase->shouldHaveBeenCalledOnce();
$listDatabases->shouldHaveBeenCalledOnce();
$createDatabase->shouldNotHaveBeenCalled();

View file

@ -60,8 +60,8 @@ class MigrateDatabaseCommandTest extends TestCase
$this->commandTester->execute([]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('Migrating database...', $output);
$this->assertStringContainsString('Database properly migrated!', $output);
self::assertStringContainsString('Migrating database...', $output);
self::assertStringContainsString('Database properly migrated!', $output);
$runCommand->shouldHaveBeenCalledOnce();
}
}

View file

@ -47,7 +47,7 @@ class DeleteShortUrlCommandTest extends TestCase
$this->commandTester->execute(['shortCode' => $shortCode]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString(
self::assertStringContainsString(
sprintf('Short URL with short code "%s" successfully deleted.', $shortCode),
$output,
);
@ -66,7 +66,7 @@ class DeleteShortUrlCommandTest extends TestCase
$this->commandTester->execute(['shortCode' => $shortCode]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString(sprintf('No URL found with short code "%s"', $shortCode), $output);
self::assertStringContainsString(sprintf('No URL found with short code "%s"', $shortCode), $output);
$deleteByShortCode->shouldHaveBeenCalledOnce();
}
@ -95,11 +95,11 @@ class DeleteShortUrlCommandTest extends TestCase
$this->commandTester->execute(['shortCode' => $shortCode]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString(sprintf(
self::assertStringContainsString(sprintf(
'Impossible to delete short URL with short code "%s" since it has more than "10" visits.',
$shortCode,
), $output);
$this->assertStringContainsString($expectedMessage, $output);
self::assertStringContainsString($expectedMessage, $output);
$deleteByShortCode->shouldHaveBeenCalledTimes($expectedDeleteCalls);
}
@ -122,11 +122,11 @@ class DeleteShortUrlCommandTest extends TestCase
$this->commandTester->execute(['shortCode' => $shortCode]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString(sprintf(
self::assertStringContainsString(sprintf(
'Impossible to delete short URL with short code "%s" since it has more than "10" visits.',
$shortCode,
), $output);
$this->assertStringContainsString('Short URL was not deleted.', $output);
self::assertStringContainsString('Short URL was not deleted.', $output);
$deleteByShortCode->shouldHaveBeenCalledOnce();
}
}

View file

@ -49,8 +49,8 @@ class GenerateShortUrlCommandTest extends TestCase
]);
$output = $this->commandTester->getDisplay();
$this->assertEquals(ExitCodes::EXIT_SUCCESS, $this->commandTester->getStatusCode());
$this->assertStringContainsString($shortUrl->toString(self::DOMAIN_CONFIG), $output);
self::assertEquals(ExitCodes::EXIT_SUCCESS, $this->commandTester->getStatusCode());
self::assertStringContainsString($shortUrl->toString(self::DOMAIN_CONFIG), $output);
$urlToShortCode->shouldHaveBeenCalledOnce();
}
@ -64,8 +64,8 @@ class GenerateShortUrlCommandTest extends TestCase
$this->commandTester->execute(['longUrl' => $url]);
$output = $this->commandTester->getDisplay();
$this->assertEquals(ExitCodes::EXIT_FAILURE, $this->commandTester->getStatusCode());
$this->assertStringContainsString('Provided URL http://domain.com/invalid is invalid.', $output);
self::assertEquals(ExitCodes::EXIT_FAILURE, $this->commandTester->getStatusCode());
self::assertStringContainsString('Provided URL http://domain.com/invalid is invalid.', $output);
}
/** @test */
@ -78,8 +78,8 @@ class GenerateShortUrlCommandTest extends TestCase
$this->commandTester->execute(['longUrl' => 'http://domain.com/invalid', '--customSlug' => 'my-slug']);
$output = $this->commandTester->getDisplay();
$this->assertEquals(ExitCodes::EXIT_FAILURE, $this->commandTester->getStatusCode());
$this->assertStringContainsString('Provided slug "my-slug" is already in use', $output);
self::assertEquals(ExitCodes::EXIT_FAILURE, $this->commandTester->getStatusCode());
self::assertStringContainsString('Provided slug "my-slug" is already in use', $output);
$urlToShortCode->shouldHaveBeenCalledOnce();
}
@ -102,8 +102,8 @@ class GenerateShortUrlCommandTest extends TestCase
]);
$output = $this->commandTester->getDisplay();
$this->assertEquals(ExitCodes::EXIT_SUCCESS, $this->commandTester->getStatusCode());
$this->assertStringContainsString($shortUrl->toString(self::DOMAIN_CONFIG), $output);
self::assertEquals(ExitCodes::EXIT_SUCCESS, $this->commandTester->getStatusCode());
self::assertStringContainsString($shortUrl->toString(self::DOMAIN_CONFIG), $output);
$urlToShortCode->shouldHaveBeenCalledOnce();
}

View file

@ -88,7 +88,7 @@ class GetVisitsCommandTest extends TestCase
$output = $this->commandTester->getDisplay();
$info->shouldHaveBeenCalledOnce();
$this->assertStringContainsString(
self::assertStringContainsString(
sprintf('Ignored provided "startDate" since its value "%s" is not a valid date', $startDate),
$output,
);
@ -108,8 +108,8 @@ class GetVisitsCommandTest extends TestCase
$this->commandTester->execute(['shortCode' => $shortCode]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('foo', $output);
$this->assertStringContainsString('Spain', $output);
$this->assertStringContainsString('bar', $output);
self::assertStringContainsString('foo', $output);
self::assertStringContainsString('Spain', $output);
self::assertStringContainsString('bar', $output);
}
}

View file

@ -50,9 +50,9 @@ class ListShortUrlsCommandTest extends TestCase
$this->commandTester->execute([]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('Continue with page 2?', $output);
$this->assertStringContainsString('Continue with page 3?', $output);
$this->assertStringContainsString('Continue with page 4?', $output);
self::assertStringContainsString('Continue with page 2?', $output);
self::assertStringContainsString('Continue with page 3?', $output);
self::assertStringContainsString('Continue with page 4?', $output);
}
/** @test */
@ -72,13 +72,13 @@ class ListShortUrlsCommandTest extends TestCase
$this->commandTester->execute([]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('url_1', $output);
$this->assertStringContainsString('url_9', $output);
$this->assertStringNotContainsString('url_10', $output);
$this->assertStringNotContainsString('url_20', $output);
$this->assertStringNotContainsString('url_30', $output);
$this->assertStringContainsString('Continue with page 2?', $output);
$this->assertStringNotContainsString('Continue with page 3?', $output);
self::assertStringContainsString('url_1', $output);
self::assertStringContainsString('url_9', $output);
self::assertStringNotContainsString('url_10', $output);
self::assertStringNotContainsString('url_20', $output);
self::assertStringNotContainsString('url_30', $output);
self::assertStringContainsString('Continue with page 2?', $output);
self::assertStringNotContainsString('Continue with page 3?', $output);
}
/** @test */
@ -103,7 +103,7 @@ class ListShortUrlsCommandTest extends TestCase
$this->commandTester->setInputs(['y']);
$this->commandTester->execute(['--showTags' => true]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('Tags', $output);
self::assertStringContainsString('Tags', $output);
}
/**

View file

@ -44,7 +44,7 @@ class ResolveUrlCommandTest extends TestCase
$this->commandTester->execute(['shortCode' => $shortCode]);
$output = $this->commandTester->getDisplay();
$this->assertEquals('Long URL: ' . $expectedUrl . PHP_EOL, $output);
self::assertEquals('Long URL: ' . $expectedUrl . PHP_EOL, $output);
}
/** @test */
@ -59,6 +59,6 @@ class ResolveUrlCommandTest extends TestCase
$this->commandTester->execute(['shortCode' => $shortCode]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString(sprintf('No URL found with short code "%s"', $shortCode), $output);
self::assertStringContainsString(sprintf('No URL found with short code "%s"', $shortCode), $output);
}
}

View file

@ -34,7 +34,7 @@ class CreateTagCommandTest extends TestCase
$this->commandTester->execute([]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('You have to provide at least one tag name', $output);
self::assertStringContainsString('You have to provide at least one tag name', $output);
}
/** @test */
@ -48,7 +48,7 @@ class CreateTagCommandTest extends TestCase
]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('Tags properly created', $output);
self::assertStringContainsString('Tags properly created', $output);
$createTags->shouldHaveBeenCalled();
}
}

View file

@ -33,7 +33,7 @@ class DeleteTagsCommandTest extends TestCase
$this->commandTester->execute([]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('You have to provide at least one tag name', $output);
self::assertStringContainsString('You have to provide at least one tag name', $output);
}
/** @test */
@ -48,7 +48,7 @@ class DeleteTagsCommandTest extends TestCase
]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('Tags properly deleted', $output);
self::assertStringContainsString('Tags properly deleted', $output);
$deleteTags->shouldHaveBeenCalled();
}
}

View file

@ -37,7 +37,7 @@ class ListTagsCommandTest extends TestCase
$this->commandTester->execute([]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('No tags found', $output);
self::assertStringContainsString('No tags found', $output);
$tagsInfo->shouldHaveBeenCalled();
}
@ -52,12 +52,12 @@ class ListTagsCommandTest extends TestCase
$this->commandTester->execute([]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('| foo', $output);
$this->assertStringContainsString('| bar', $output);
$this->assertStringContainsString('| 10 ', $output);
$this->assertStringContainsString('| 2 ', $output);
$this->assertStringContainsString('| 7 ', $output);
$this->assertStringContainsString('| 32 ', $output);
self::assertStringContainsString('| foo', $output);
self::assertStringContainsString('| bar', $output);
self::assertStringContainsString('| 10 ', $output);
self::assertStringContainsString('| 2 ', $output);
self::assertStringContainsString('| 7 ', $output);
self::assertStringContainsString('| 32 ', $output);
$tagsInfo->shouldHaveBeenCalled();
}
}

View file

@ -42,7 +42,7 @@ class RenameTagCommandTest extends TestCase
]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('Tag with name "foo" could not be found', $output);
self::assertStringContainsString('Tag with name "foo" could not be found', $output);
$renameTag->shouldHaveBeenCalled();
}
@ -59,7 +59,7 @@ class RenameTagCommandTest extends TestCase
]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('Tag properly renamed', $output);
self::assertStringContainsString('Tag properly renamed', $output);
$renameTag->shouldHaveBeenCalled();
}
}

View file

@ -92,11 +92,11 @@ class LocateVisitsCommandTest extends TestCase
$this->commandTester->execute($args);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('Processing IP 1.2.3.0', $output);
self::assertStringContainsString('Processing IP 1.2.3.0', $output);
if ($expectWarningPrint) {
$this->assertStringContainsString('Continue at your own risk', $output);
self::assertStringContainsString('Continue at your own risk', $output);
} else {
$this->assertStringNotContainsString('Continue at your own risk', $output);
self::assertStringNotContainsString('Continue at your own risk', $output);
}
$locateVisits->shouldHaveBeenCalledTimes($expectedUnlocatedCalls);
$locateEmptyVisits->shouldHaveBeenCalledTimes($expectedEmptyCalls);
@ -132,11 +132,11 @@ class LocateVisitsCommandTest extends TestCase
$this->commandTester->execute([], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString($message, $output);
self::assertStringContainsString($message, $output);
if (empty($address)) {
$this->assertStringNotContainsString('Processing IP', $output);
self::assertStringNotContainsString('Processing IP', $output);
} else {
$this->assertStringContainsString('Processing IP', $output);
self::assertStringContainsString('Processing IP', $output);
}
$locateVisits->shouldHaveBeenCalledOnce();
$resolveIpLocation->shouldNotHaveBeenCalled();
@ -164,7 +164,7 @@ class LocateVisitsCommandTest extends TestCase
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('An error occurred while locating IP. Skipped', $output);
self::assertStringContainsString('An error occurred while locating IP. Skipped', $output);
$locateVisits->shouldHaveBeenCalledOnce();
$resolveIpLocation->shouldHaveBeenCalledOnce();
}
@ -192,7 +192,7 @@ class LocateVisitsCommandTest extends TestCase
$this->commandTester->execute([], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString(
self::assertStringContainsString(
sprintf('Command "%s" is already in progress. Skipping.', LocateVisitsCommand::NAME),
$output,
);
@ -222,11 +222,11 @@ class LocateVisitsCommandTest extends TestCase
$this->commandTester->execute([]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString(
self::assertStringContainsString(
sprintf('%s GeoLite2 database...', $olderDbExists ? 'Updating' : 'Downloading'),
$output,
);
$this->assertStringContainsString($expectedMessage, $output);
self::assertStringContainsString($expectedMessage, $output);
$locateVisits->shouldHaveBeenCalledTimes((int) $olderDbExists);
$checkDbUpdate->shouldHaveBeenCalledOnce();
}
@ -243,7 +243,7 @@ class LocateVisitsCommandTest extends TestCase
$this->commandTester->execute(['--all' => true]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('The --all flag has no effect on its own', $output);
self::assertStringContainsString('The --all flag has no effect on its own', $output);
}
/**

View file

@ -17,11 +17,11 @@ class ConfigProviderTest extends TestCase
}
/** @test */
public function confiIsProperlyReturned(): void
public function configIsProperlyReturned(): void
{
$config = ($this->configProvider)();
$this->assertArrayHasKey('cli', $config);
$this->assertArrayHasKey('dependencies', $config);
self::assertArrayHasKey('cli', $config);
self::assertArrayHasKey('dependencies', $config);
}
}

View file

@ -20,13 +20,13 @@ class GeolocationDbUpdateFailedExceptionTest extends TestCase
{
$e = GeolocationDbUpdateFailedException::create($olderDbExists, $prev);
$this->assertEquals($olderDbExists, $e->olderDbExists());
$this->assertEquals(
self::assertEquals($olderDbExists, $e->olderDbExists());
self::assertEquals(
'An error occurred while updating geolocation database, and an older version could not be found',
$e->getMessage(),
);
$this->assertEquals(0, $e->getCode());
$this->assertEquals($prev, $e->getPrevious());
self::assertEquals(0, $e->getCode());
self::assertEquals($prev, $e->getPrevious());
}
public function provideCreateArgs(): iterable

View file

@ -37,9 +37,9 @@ class ApplicationFactoryTest extends TestCase
$instance = ($this->factory)($sm);
$this->assertTrue($instance->has('foo'));
$this->assertTrue($instance->has('bar'));
$this->assertFalse($instance->has('baz'));
self::assertTrue($instance->has('foo'));
self::assertTrue($instance->has('bar'));
self::assertFalse($instance->has('baz'));
}
private function createServiceManager(array $config = []): ServiceManager

View file

@ -50,7 +50,7 @@ class GeolocationDbUpdaterTest extends TestCase
/** @test */
public function exceptionIsThrownWhenOlderDbDoesNotExistAndDownloadFails(): void
{
$mustBeUpdated = fn () => $this->assertTrue(true);
$mustBeUpdated = fn () => self::assertTrue(true);
$prev = new RuntimeException('');
$fileExists = $this->dbUpdater->databaseFileExists()->willReturn(false);
@ -59,12 +59,12 @@ class GeolocationDbUpdaterTest extends TestCase
try {
$this->geolocationDbUpdater->checkDbUpdate($mustBeUpdated);
$this->assertTrue(false); // If this is reached, the test will fail
self::assertTrue(false); // If this is reached, the test will fail
} catch (Throwable $e) {
/** @var GeolocationDbUpdateFailedException $e */
$this->assertInstanceOf(GeolocationDbUpdateFailedException::class, $e);
$this->assertSame($prev, $e->getPrevious());
$this->assertFalse($e->olderDbExists());
self::assertInstanceOf(GeolocationDbUpdateFailedException::class, $e);
self::assertSame($prev, $e->getPrevious());
self::assertFalse($e->olderDbExists());
}
$fileExists->shouldHaveBeenCalledOnce();
@ -95,12 +95,12 @@ class GeolocationDbUpdaterTest extends TestCase
try {
$this->geolocationDbUpdater->checkDbUpdate();
$this->assertTrue(false); // If this is reached, the test will fail
self::assertTrue(false); // If this is reached, the test will fail
} catch (Throwable $e) {
/** @var GeolocationDbUpdateFailedException $e */
$this->assertInstanceOf(GeolocationDbUpdateFailedException::class, $e);
$this->assertSame($prev, $e->getPrevious());
$this->assertTrue($e->olderDbExists());
self::assertInstanceOf(GeolocationDbUpdateFailedException::class, $e);
self::assertSame($prev, $e->getPrevious());
self::assertTrue($e->olderDbExists());
}
$fileExists->shouldHaveBeenCalledOnce();

View file

@ -60,6 +60,6 @@ class ShlinkTableTest extends TestCase
$baseTable = $ref->getProperty('baseTable');
$baseTable->setAccessible(true);
$this->assertInstanceOf(Table::class, $baseTable->getValue($instance));
self::assertInstanceOf(Table::class, $baseTable->getValue($instance));
}
}

View file

@ -57,25 +57,25 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
$this->getEntityManager()->flush();
$this->assertSame($regularOne, $this->repo->findOneWithDomainFallback($regularOne->getShortCode()));
$this->assertSame($regularOne, $this->repo->findOneWithDomainFallback(
self::assertSame($regularOne, $this->repo->findOneWithDomainFallback($regularOne->getShortCode()));
self::assertSame($regularOne, $this->repo->findOneWithDomainFallback(
$withDomainDuplicatingRegular->getShortCode(),
));
$this->assertSame($withDomain, $this->repo->findOneWithDomainFallback(
self::assertSame($withDomain, $this->repo->findOneWithDomainFallback(
$withDomain->getShortCode(),
'example.com',
));
$this->assertSame(
self::assertSame(
$withDomainDuplicatingRegular,
$this->repo->findOneWithDomainFallback($withDomainDuplicatingRegular->getShortCode(), 'doma.in'),
);
$this->assertSame(
self::assertSame(
$regularOne,
$this->repo->findOneWithDomainFallback($withDomainDuplicatingRegular->getShortCode(), 'other-domain.com'),
);
$this->assertNull($this->repo->findOneWithDomainFallback('invalid'));
$this->assertNull($this->repo->findOneWithDomainFallback($withDomain->getShortCode()));
$this->assertNull($this->repo->findOneWithDomainFallback($withDomain->getShortCode(), 'other-domain.com'));
self::assertNull($this->repo->findOneWithDomainFallback('invalid'));
self::assertNull($this->repo->findOneWithDomainFallback($withDomain->getShortCode()));
self::assertNull($this->repo->findOneWithDomainFallback($withDomain->getShortCode(), 'other-domain.com'));
}
/** @test */
@ -87,7 +87,7 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
}
$this->getEntityManager()->flush();
$this->assertEquals($count, $this->repo->countList());
self::assertEquals($count, $this->repo->countList());
}
/** @test */
@ -116,37 +116,37 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
$this->getEntityManager()->flush();
$result = $this->repo->findList(null, null, 'foo', ['bar']);
$this->assertCount(1, $result);
$this->assertEquals(1, $this->repo->countList('foo', ['bar']));
$this->assertSame($foo, $result[0]);
self::assertCount(1, $result);
self::assertEquals(1, $this->repo->countList('foo', ['bar']));
self::assertSame($foo, $result[0]);
$result = $this->repo->findList();
$this->assertCount(3, $result);
self::assertCount(3, $result);
$result = $this->repo->findList(2);
$this->assertCount(2, $result);
self::assertCount(2, $result);
$result = $this->repo->findList(2, 1);
$this->assertCount(2, $result);
self::assertCount(2, $result);
$this->assertCount(1, $this->repo->findList(2, 2));
self::assertCount(1, $this->repo->findList(2, 2));
$result = $this->repo->findList(null, null, null, [], ShortUrlsOrdering::fromRawData([
'orderBy' => ['visits' => 'DESC'],
]));
$this->assertCount(3, $result);
$this->assertSame($bar, $result[0]);
self::assertCount(3, $result);
self::assertSame($bar, $result[0]);
$result = $this->repo->findList(null, null, null, [], null, new DateRange(null, Chronos::now()->subDays(2)));
$this->assertCount(1, $result);
$this->assertEquals(1, $this->repo->countList(null, [], new DateRange(null, Chronos::now()->subDays(2))));
$this->assertSame($foo2, $result[0]);
self::assertCount(1, $result);
self::assertEquals(1, $this->repo->countList(null, [], new DateRange(null, Chronos::now()->subDays(2))));
self::assertSame($foo2, $result[0]);
$this->assertCount(
self::assertCount(
2,
$this->repo->findList(null, null, null, [], null, new DateRange(Chronos::now()->subDays(2))),
);
$this->assertEquals(2, $this->repo->countList(null, [], new DateRange(Chronos::now()->subDays(2))));
self::assertEquals(2, $this->repo->countList(null, [], new DateRange(Chronos::now()->subDays(2))));
}
/** @test */
@ -163,11 +163,11 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
'orderBy' => ['longUrl' => 'ASC'],
]));
$this->assertCount(count($urls), $result);
$this->assertEquals('a', $result[0]->getLongUrl());
$this->assertEquals('b', $result[1]->getLongUrl());
$this->assertEquals('c', $result[2]->getLongUrl());
$this->assertEquals('z', $result[3]->getLongUrl());
self::assertCount(count($urls), $result);
self::assertEquals('a', $result[0]->getLongUrl());
self::assertEquals('b', $result[1]->getLongUrl());
self::assertEquals('c', $result[2]->getLongUrl());
self::assertEquals('z', $result[3]->getLongUrl());
}
/** @test */
@ -184,12 +184,12 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
$this->getEntityManager()->flush();
$this->assertTrue($this->repo->shortCodeIsInUse('my-cool-slug'));
$this->assertFalse($this->repo->shortCodeIsInUse('my-cool-slug', 'doma.in'));
$this->assertFalse($this->repo->shortCodeIsInUse('slug-not-in-use'));
$this->assertFalse($this->repo->shortCodeIsInUse('another-slug'));
$this->assertFalse($this->repo->shortCodeIsInUse('another-slug', 'example.com'));
$this->assertTrue($this->repo->shortCodeIsInUse('another-slug', 'doma.in'));
self::assertTrue($this->repo->shortCodeIsInUse('my-cool-slug'));
self::assertFalse($this->repo->shortCodeIsInUse('my-cool-slug', 'doma.in'));
self::assertFalse($this->repo->shortCodeIsInUse('slug-not-in-use'));
self::assertFalse($this->repo->shortCodeIsInUse('another-slug'));
self::assertFalse($this->repo->shortCodeIsInUse('another-slug', 'example.com'));
self::assertTrue($this->repo->shortCodeIsInUse('another-slug', 'doma.in'));
}
/** @test */
@ -206,21 +206,21 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
$this->getEntityManager()->flush();
$this->assertNotNull($this->repo->findOne('my-cool-slug'));
$this->assertNull($this->repo->findOne('my-cool-slug', 'doma.in'));
$this->assertNull($this->repo->findOne('slug-not-in-use'));
$this->assertNull($this->repo->findOne('another-slug'));
$this->assertNull($this->repo->findOne('another-slug', 'example.com'));
$this->assertNotNull($this->repo->findOne('another-slug', 'doma.in'));
self::assertNotNull($this->repo->findOne('my-cool-slug'));
self::assertNull($this->repo->findOne('my-cool-slug', 'doma.in'));
self::assertNull($this->repo->findOne('slug-not-in-use'));
self::assertNull($this->repo->findOne('another-slug'));
self::assertNull($this->repo->findOne('another-slug', 'example.com'));
self::assertNotNull($this->repo->findOne('another-slug', 'doma.in'));
}
/** @test */
public function findOneMatchingReturnsNullForNonExistingShortUrls(): void
{
$this->assertNull($this->repo->findOneMatching('', [], ShortUrlMeta::createEmpty()));
$this->assertNull($this->repo->findOneMatching('foobar', [], ShortUrlMeta::createEmpty()));
$this->assertNull($this->repo->findOneMatching('foobar', ['foo', 'bar'], ShortUrlMeta::createEmpty()));
$this->assertNull($this->repo->findOneMatching('foobar', ['foo', 'bar'], ShortUrlMeta::fromRawData([
self::assertNull($this->repo->findOneMatching('', [], ShortUrlMeta::createEmpty()));
self::assertNull($this->repo->findOneMatching('foobar', [], ShortUrlMeta::createEmpty()));
self::assertNull($this->repo->findOneMatching('foobar', ['foo', 'bar'], ShortUrlMeta::createEmpty()));
self::assertNull($this->repo->findOneMatching('foobar', ['foo', 'bar'], ShortUrlMeta::fromRawData([
'validSince' => Chronos::parse('2020-03-05 20:18:30'),
'customSlug' => 'this_slug_does_not_exist',
])));
@ -253,33 +253,33 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
$this->getEntityManager()->flush();
$this->assertSame(
self::assertSame(
$shortUrl,
$this->repo->findOneMatching('foo', ['foo', 'bar'], ShortUrlMeta::fromRawData(['validSince' => $start])),
);
$this->assertSame(
self::assertSame(
$shortUrl2,
$this->repo->findOneMatching('bar', [], ShortUrlMeta::fromRawData(['validUntil' => $end])),
);
$this->assertSame(
self::assertSame(
$shortUrl3,
$this->repo->findOneMatching('baz', [], ShortUrlMeta::fromRawData([
'validSince' => $start,
'validUntil' => $end,
])),
);
$this->assertSame(
self::assertSame(
$shortUrl4,
$this->repo->findOneMatching('foo', [], ShortUrlMeta::fromRawData([
'customSlug' => 'custom',
'validUntil' => $end,
])),
);
$this->assertSame(
self::assertSame(
$shortUrl5,
$this->repo->findOneMatching('foo', [], ShortUrlMeta::fromRawData(['maxVisits' => 3])),
);
$this->assertSame(
self::assertSame(
$shortUrl6,
$this->repo->findOneMatching('foo', [], ShortUrlMeta::fromRawData(['domain' => 'doma.in'])),
);
@ -307,15 +307,15 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
$this->getEntityManager()->flush();
$this->assertSame(
self::assertSame(
$shortUrl1,
$this->repo->findOneMatching('foo', $tags, ShortUrlMeta::fromRawData($meta)),
);
$this->assertNotSame(
self::assertNotSame(
$shortUrl2,
$this->repo->findOneMatching('foo', $tags, ShortUrlMeta::fromRawData($meta)),
);
$this->assertNotSame(
self::assertNotSame(
$shortUrl3,
$this->repo->findOneMatching('foo', $tags, ShortUrlMeta::fromRawData($meta)),
);

View file

@ -32,7 +32,7 @@ class TagRepositoryTest extends DatabaseTestCase
/** @test */
public function deleteByNameDoesNothingWhenEmptyListIsProvided(): void
{
$this->assertEquals(0, $this->repo->deleteByName([]));
self::assertEquals(0, $this->repo->deleteByName([]));
}
/** @test */
@ -46,7 +46,7 @@ class TagRepositoryTest extends DatabaseTestCase
}
$this->getEntityManager()->flush();
$this->assertEquals(2, $this->repo->deleteByName($toDelete));
self::assertEquals(2, $this->repo->deleteByName($toDelete));
}
/** @test */
@ -79,20 +79,20 @@ class TagRepositoryTest extends DatabaseTestCase
$result = $this->repo->findTagsWithInfo();
$this->assertCount(4, $result);
$this->assertEquals(
self::assertCount(4, $result);
self::assertEquals(
['tag' => $tags[3], 'shortUrlsCount' => 0, 'visitsCount' => 0],
$result[0]->jsonSerialize(),
);
$this->assertEquals(
self::assertEquals(
['tag' => $tags[1], 'shortUrlsCount' => 1, 'visitsCount' => 3],
$result[1]->jsonSerialize(),
);
$this->assertEquals(
self::assertEquals(
['tag' => $tags[2], 'shortUrlsCount' => 1, 'visitsCount' => 3],
$result[2]->jsonSerialize(),
);
$this->assertEquals(
self::assertEquals(
['tag' => $tags[0], 'shortUrlsCount' => 2, 'visitsCount' => 4],
$result[3]->jsonSerialize(),
);

View file

@ -75,9 +75,9 @@ class VisitRepositoryTest extends DatabaseTestCase
// Important! assertCount will not work here, as this iterable object loads data dynamically and the count
// is 0 if not iterated
$this->assertEquals(2, $countIterable($unlocated));
$this->assertEquals(4, $countIterable($withEmptyLocation));
$this->assertEquals(6, $countIterable($all));
self::assertEquals(2, $countIterable($unlocated));
self::assertEquals(4, $countIterable($withEmptyLocation));
self::assertEquals(6, $countIterable($all));
}
public function provideBlockSize(): iterable
@ -90,22 +90,22 @@ class VisitRepositoryTest extends DatabaseTestCase
{
[$shortCode, $domain] = $this->createShortUrlsAndVisits();
$this->assertCount(0, $this->repo->findVisitsByShortCode('invalid'));
$this->assertCount(6, $this->repo->findVisitsByShortCode($shortCode));
$this->assertCount(3, $this->repo->findVisitsByShortCode($shortCode, $domain));
$this->assertCount(2, $this->repo->findVisitsByShortCode($shortCode, null, new DateRange(
self::assertCount(0, $this->repo->findVisitsByShortCode('invalid'));
self::assertCount(6, $this->repo->findVisitsByShortCode($shortCode));
self::assertCount(3, $this->repo->findVisitsByShortCode($shortCode, $domain));
self::assertCount(2, $this->repo->findVisitsByShortCode($shortCode, null, new DateRange(
Chronos::parse('2016-01-02'),
Chronos::parse('2016-01-03'),
)));
$this->assertCount(4, $this->repo->findVisitsByShortCode($shortCode, null, new DateRange(
self::assertCount(4, $this->repo->findVisitsByShortCode($shortCode, null, new DateRange(
Chronos::parse('2016-01-03'),
)));
$this->assertCount(1, $this->repo->findVisitsByShortCode($shortCode, $domain, new DateRange(
self::assertCount(1, $this->repo->findVisitsByShortCode($shortCode, $domain, new DateRange(
Chronos::parse('2016-01-03'),
)));
$this->assertCount(3, $this->repo->findVisitsByShortCode($shortCode, null, null, 3, 2));
$this->assertCount(2, $this->repo->findVisitsByShortCode($shortCode, null, null, 5, 4));
$this->assertCount(1, $this->repo->findVisitsByShortCode($shortCode, $domain, null, 3, 2));
self::assertCount(3, $this->repo->findVisitsByShortCode($shortCode, null, null, 3, 2));
self::assertCount(2, $this->repo->findVisitsByShortCode($shortCode, null, null, 5, 4));
self::assertCount(1, $this->repo->findVisitsByShortCode($shortCode, $domain, null, 3, 2));
}
/** @test */
@ -113,17 +113,17 @@ class VisitRepositoryTest extends DatabaseTestCase
{
[$shortCode, $domain] = $this->createShortUrlsAndVisits();
$this->assertEquals(0, $this->repo->countVisitsByShortCode('invalid'));
$this->assertEquals(6, $this->repo->countVisitsByShortCode($shortCode));
$this->assertEquals(3, $this->repo->countVisitsByShortCode($shortCode, $domain));
$this->assertEquals(2, $this->repo->countVisitsByShortCode($shortCode, null, new DateRange(
self::assertEquals(0, $this->repo->countVisitsByShortCode('invalid'));
self::assertEquals(6, $this->repo->countVisitsByShortCode($shortCode));
self::assertEquals(3, $this->repo->countVisitsByShortCode($shortCode, $domain));
self::assertEquals(2, $this->repo->countVisitsByShortCode($shortCode, null, new DateRange(
Chronos::parse('2016-01-02'),
Chronos::parse('2016-01-03'),
)));
$this->assertEquals(4, $this->repo->countVisitsByShortCode($shortCode, null, new DateRange(
self::assertEquals(4, $this->repo->countVisitsByShortCode($shortCode, null, new DateRange(
Chronos::parse('2016-01-03'),
)));
$this->assertEquals(1, $this->repo->countVisitsByShortCode($shortCode, $domain, new DateRange(
self::assertEquals(1, $this->repo->countVisitsByShortCode($shortCode, $domain, new DateRange(
Chronos::parse('2016-01-03'),
)));
}
@ -147,13 +147,13 @@ class VisitRepositoryTest extends DatabaseTestCase
$this->getEntityManager()->flush();
$this->assertCount(0, $this->repo->findVisitsByTag('invalid'));
$this->assertCount(18, $this->repo->findVisitsByTag((string) $foo));
$this->assertCount(6, $this->repo->findVisitsByTag((string) $foo, new DateRange(
self::assertCount(0, $this->repo->findVisitsByTag('invalid'));
self::assertCount(18, $this->repo->findVisitsByTag((string) $foo));
self::assertCount(6, $this->repo->findVisitsByTag((string) $foo, new DateRange(
Chronos::parse('2016-01-02'),
Chronos::parse('2016-01-03'),
)));
$this->assertCount(12, $this->repo->findVisitsByTag((string) $foo, new DateRange(
self::assertCount(12, $this->repo->findVisitsByTag((string) $foo, new DateRange(
Chronos::parse('2016-01-03'),
)));
}
@ -174,13 +174,13 @@ class VisitRepositoryTest extends DatabaseTestCase
$this->getEntityManager()->flush();
$this->assertEquals(0, $this->repo->countVisitsByTag('invalid'));
$this->assertEquals(12, $this->repo->countVisitsByTag((string) $foo));
$this->assertEquals(4, $this->repo->countVisitsByTag((string) $foo, new DateRange(
self::assertEquals(0, $this->repo->countVisitsByTag('invalid'));
self::assertEquals(12, $this->repo->countVisitsByTag((string) $foo));
self::assertEquals(4, $this->repo->countVisitsByTag((string) $foo, new DateRange(
Chronos::parse('2016-01-02'),
Chronos::parse('2016-01-03'),
)));
$this->assertEquals(8, $this->repo->countVisitsByTag((string) $foo, new DateRange(
self::assertEquals(8, $this->repo->countVisitsByTag((string) $foo, new DateRange(
Chronos::parse('2016-01-03'),
)));
}

View file

@ -47,8 +47,8 @@ class PixelActionTest extends TestCase
$request = (new ServerRequest())->withAttribute('shortCode', $shortCode);
$response = $this->action->process($request, $this->prophesize(RequestHandlerInterface::class)->reveal());
$this->assertInstanceOf(PixelResponse::class, $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('image/gif', $response->getHeaderLine('content-type'));
self::assertInstanceOf(PixelResponse::class, $response);
self::assertEquals(200, $response->getStatusCode());
self::assertEquals('image/gif', $response->getHeaderLine('content-type'));
}
}

View file

@ -77,8 +77,8 @@ class QrCodeActionTest extends TestCase
$delegate->reveal(),
);
$this->assertInstanceOf(QrCodeResponse::class, $resp);
$this->assertEquals(200, $resp->getStatusCode());
self::assertInstanceOf(QrCodeResponse::class, $resp);
self::assertEquals(200, $resp->getStatusCode());
$delegate->handle(Argument::any())->shouldHaveBeenCalledTimes(0);
}
@ -97,7 +97,7 @@ class QrCodeActionTest extends TestCase
$resp = $this->action->process($req, $delegate->reveal());
$this->assertEquals($expectedContentType, $resp->getHeaderLine('Content-Type'));
self::assertEquals($expectedContentType, $resp->getHeaderLine('Content-Type'));
}
public function provideQueries(): iterable

View file

@ -60,10 +60,10 @@ class RedirectActionTest extends TestCase
$request = (new ServerRequest())->withAttribute('shortCode', $shortCode)->withQueryParams($query);
$response = $this->action->process($request, $this->prophesize(RequestHandlerInterface::class)->reveal());
$this->assertInstanceOf(Response\RedirectResponse::class, $response);
$this->assertEquals(302, $response->getStatusCode());
$this->assertTrue($response->hasHeader('Location'));
$this->assertEquals($expectedUrl, $response->getHeaderLine('Location'));
self::assertInstanceOf(Response\RedirectResponse::class, $response);
self::assertEquals(302, $response->getStatusCode());
self::assertTrue($response->hasHeader('Location'));
self::assertEquals($expectedUrl, $response->getHeaderLine('Location'));
$shortCodeToUrl->shouldHaveBeenCalledOnce();
$track->shouldHaveBeenCalledTimes(array_key_exists('foobar', $query) ? 0 : 1);
}
@ -135,10 +135,10 @@ class RedirectActionTest extends TestCase
$request = (new ServerRequest())->withAttribute('shortCode', $shortCode);
$response = $this->action->process($request, $this->prophesize(RequestHandlerInterface::class)->reveal());
$this->assertInstanceOf(Response\RedirectResponse::class, $response);
$this->assertEquals($expectedStatus, $response->getStatusCode());
$this->assertEquals($response->hasHeader('Cache-Control'), $expectedCacheControl !== null);
$this->assertEquals($response->getHeaderLine('Cache-Control'), $expectedCacheControl ?? '');
self::assertInstanceOf(Response\RedirectResponse::class, $response);
self::assertEquals($expectedStatus, $response->getStatusCode());
self::assertEquals($response->hasHeader('Cache-Control'), $expectedCacheControl !== null);
self::assertEquals($response->getHeaderLine('Cache-Control'), $expectedCacheControl ?? '');
}
public function provideRedirectConfigs(): iterable

View file

@ -32,9 +32,9 @@ class BasePathPrefixerTest extends TestCase
'url_shortener' => $urlShortener,
] = ($this->prefixer)($originalConfig);
$this->assertEquals($expectedRoutes, $routes);
$this->assertEquals($expectedMiddlewares, $middlewares);
$this->assertEquals([
self::assertEquals($expectedRoutes, $routes);
self::assertEquals($expectedMiddlewares, $middlewares);
self::assertEquals([
'domain' => [
'hostname' => $expectedHostname,
],

View file

@ -29,7 +29,7 @@ class DeprecatedConfigParserTest extends TestCase
$result = ($this->postProcessor)($config);
$this->assertEquals($config, $result);
self::assertEquals($config, $result);
}
/** @test */
@ -46,7 +46,7 @@ class DeprecatedConfigParserTest extends TestCase
$result = ($this->postProcessor)($config);
$this->assertEquals($config, $result);
self::assertEquals($config, $result);
}
/** @test */
@ -68,7 +68,7 @@ class DeprecatedConfigParserTest extends TestCase
$result = ($this->postProcessor)($config);
$this->assertEquals($expected, $result);
self::assertEquals($expected, $result);
}
/** @test */
@ -89,7 +89,7 @@ class DeprecatedConfigParserTest extends TestCase
$result = ($this->postProcessor)($config);
$this->assertEquals($expected, $result);
self::assertEquals($expected, $result);
}
/** @test */
@ -106,6 +106,6 @@ class DeprecatedConfigParserTest extends TestCase
$result = ($this->postProcessor)($config);
$this->assertEquals($expected, $result);
self::assertEquals($expected, $result);
}
}

View file

@ -153,6 +153,6 @@ class SimplifiedConfigParserTest extends TestCase
$result = ($this->postProcessor)(array_merge($config, $simplified));
$this->assertEquals(array_merge($expected, $simplified), $result);
self::assertEquals(array_merge($expected, $simplified), $result);
}
}

View file

@ -21,9 +21,9 @@ class ConfigProviderTest extends TestCase
{
$config = $this->configProvider->__invoke();
$this->assertArrayHasKey('routes', $config);
$this->assertArrayHasKey('dependencies', $config);
$this->assertArrayHasKey('templates', $config);
$this->assertArrayHasKey('mezzio', $config);
self::assertArrayHasKey('routes', $config);
self::assertArrayHasKey('dependencies', $config);
self::assertArrayHasKey('templates', $config);
self::assertArrayHasKey('mezzio', $config);
}
}

View file

@ -27,7 +27,7 @@ class PersistenceDomainResolverTest extends TestCase
{
$getRepository = $this->em->getRepository(Domain::class);
$this->assertNull($this->domainResolver->resolveDomain(null));
self::assertNull($this->domainResolver->resolveDomain(null));
$getRepository->shouldNotHaveBeenCalled();
}
@ -44,10 +44,10 @@ class PersistenceDomainResolverTest extends TestCase
$result = $this->domainResolver->resolveDomain($authority);
if ($foundDomain !== null) {
$this->assertSame($result, $foundDomain);
self::assertSame($result, $foundDomain);
}
$this->assertInstanceOf(Domain::class, $result);
$this->assertEquals($authority, $result->getAuthority());
self::assertInstanceOf(Domain::class, $result);
self::assertEquals($authority, $result->getAuthority());
$findDomain->shouldHaveBeenCalledOnce();
$getRepository->shouldHaveBeenCalledOnce();
}

View file

@ -26,10 +26,10 @@ class SimpleDomainResolverTest extends TestCase
$result = $this->domainResolver->resolveDomain($domain);
if ($domain === null) {
$this->assertNull($result);
self::assertNull($result);
} else {
$this->assertInstanceOf(Domain::class, $result);
$this->assertEquals($domain, $result->getAuthority());
self::assertInstanceOf(Domain::class, $result);
self::assertEquals($domain, $result->getAuthority());
}
}

View file

@ -53,7 +53,7 @@ class ShortUrlTest extends TestCase
$shortUrl->regenerateShortCode();
$secondShortCode = $shortUrl->getShortCode();
$this->assertNotEquals($firstShortCode, $secondShortCode);
self::assertNotEquals($firstShortCode, $secondShortCode);
}
/**
@ -66,7 +66,7 @@ class ShortUrlTest extends TestCase
[ShortUrlMetaInputFilter::SHORT_CODE_LENGTH => $length],
));
$this->assertEquals($expectedLength, strlen($shortUrl->getShortCode()));
self::assertEquals($expectedLength, strlen($shortUrl->getShortCode()));
}
public function provideLengths(): iterable

View file

@ -13,6 +13,6 @@ class TagTest extends TestCase
public function jsonSerializationOfTagsReturnsItsStringRepresentation(): void
{
$tag = new Tag('This is my name');
$this->assertEquals((string) $tag, $tag->jsonSerialize());
self::assertEquals((string) $tag, $tag->jsonSerialize());
}
}

View file

@ -19,7 +19,7 @@ class VisitLocationTest extends TestCase
$payload = new Location(...$args);
$location = new VisitLocation($payload);
$this->assertEquals($isEmpty, $location->isEmpty());
self::assertEquals($isEmpty, $location->isEmpty());
}
public function provideArgs(): iterable

View file

@ -21,7 +21,7 @@ class VisitTest extends TestCase
{
$visit = new Visit(new ShortUrl(''), new Visitor('Chrome', 'some site', '1.2.3.4'), true, $date);
$this->assertEquals([
self::assertEquals([
'referer' => 'some site',
'date' => ($date ?? $visit->getDate())->toAtomString(),
'userAgent' => 'Chrome',
@ -43,7 +43,7 @@ class VisitTest extends TestCase
{
$visit = new Visit(new ShortUrl(''), new Visitor('Chrome', 'some site', $address), $anonymize);
$this->assertEquals($expectedAddress, $visit->getRemoteAddr());
self::assertEquals($expectedAddress, $visit->getRemoteAddr());
}
public function provideAddresses(): iterable

View file

@ -45,8 +45,8 @@ class NotFoundRedirectHandlerTest extends TestCase
$resp = $this->middleware->process($request, $next->reveal());
$this->assertInstanceOf(Response\RedirectResponse::class, $resp);
$this->assertEquals($expectedRedirectTo, $resp->getHeaderLine('Location'));
self::assertInstanceOf(Response\RedirectResponse::class, $resp);
self::assertEquals($expectedRedirectTo, $resp->getHeaderLine('Location'));
$handle->shouldNotHaveBeenCalled();
}
@ -93,7 +93,7 @@ class NotFoundRedirectHandlerTest extends TestCase
$result = $this->middleware->process($req, $next->reveal());
$this->assertSame($resp, $result);
self::assertSame($resp, $result);
$handle->shouldHaveBeenCalledOnce();
}
}

View file

@ -37,7 +37,7 @@ class NotFoundTemplateHandlerTest extends TestCase
$resp = $this->handler->handle($request);
$this->assertInstanceOf(Response\HtmlResponse::class, $resp);
self::assertInstanceOf(Response\HtmlResponse::class, $resp);
$render->shouldHaveBeenCalledOnce();
}

View file

@ -37,7 +37,7 @@ class CloseDbConnectionEventListenerDelegatorTest extends TestCase
($this->delegator)($this->container->reveal(), '', $callback);
$this->assertTrue($callbackInvoked);
self::assertTrue($callbackInvoked);
$getEm->shouldHaveBeenCalledOnce();
}
}

View file

@ -45,7 +45,7 @@ class CloseDbConnectionEventListenerTest extends TestCase
// Ignore exceptions
}
$this->assertTrue($wrappedWasCalled);
self::assertTrue($wrappedWasCalled);
$close->shouldHaveBeenCalledOnce();
$getConn->shouldHaveBeenCalledOnce();
$clear->shouldHaveBeenCalledOnce();

View file

@ -112,7 +112,7 @@ class LocateShortUrlVisitTest extends TestCase
($this->locateVisit)($event);
$this->assertEquals($visit->getVisitLocation(), new VisitLocation(Location::emptyInstance()));
self::assertEquals($visit->getVisitLocation(), new VisitLocation(Location::emptyInstance()));
$findVisit->shouldHaveBeenCalledOnce();
$flush->shouldHaveBeenCalledOnce();
$resolveIp->shouldNotHaveBeenCalled();
@ -149,7 +149,7 @@ class LocateShortUrlVisitTest extends TestCase
($this->locateVisit)($event);
$this->assertEquals($visit->getVisitLocation(), new VisitLocation($location));
self::assertEquals($visit->getVisitLocation(), new VisitLocation($location));
$findVisit->shouldHaveBeenCalledOnce();
$flush->shouldHaveBeenCalledOnce();
$resolveIp->shouldHaveBeenCalledOnce();
@ -182,7 +182,7 @@ class LocateShortUrlVisitTest extends TestCase
($this->locateVisit)($event);
$this->assertEquals($visit->getVisitLocation(), new VisitLocation($location));
self::assertEquals($visit->getVisitLocation(), new VisitLocation($location));
$findVisit->shouldHaveBeenCalledOnce();
$flush->shouldHaveBeenCalledOnce();
$resolveIp->shouldHaveBeenCalledOnce();
@ -217,7 +217,7 @@ class LocateShortUrlVisitTest extends TestCase
($this->locateVisit)($event);
$this->assertNull($visit->getVisitLocation());
self::assertNull($visit->getVisitLocation());
$findVisit->shouldHaveBeenCalledOnce();
$flush->shouldNotHaveBeenCalled();
$resolveIp->shouldNotHaveBeenCalled();

View file

@ -25,16 +25,16 @@ class DeleteShortUrlExceptionTest extends TestCase
): void {
$e = DeleteShortUrlException::fromVisitsThreshold($threshold, $shortCode);
$this->assertEquals($threshold, $e->getVisitsThreshold());
$this->assertEquals($expectedMessage, $e->getMessage());
$this->assertEquals($expectedMessage, $e->getDetail());
$this->assertEquals([
self::assertEquals($threshold, $e->getVisitsThreshold());
self::assertEquals($expectedMessage, $e->getMessage());
self::assertEquals($expectedMessage, $e->getDetail());
self::assertEquals([
'shortCode' => $shortCode,
'threshold' => $threshold,
], $e->getAdditionalData());
$this->assertEquals('Cannot delete short URL', $e->getTitle());
$this->assertEquals('INVALID_SHORTCODE_DELETION', $e->getType());
$this->assertEquals(422, $e->getStatus());
self::assertEquals('Cannot delete short URL', $e->getTitle());
self::assertEquals('INVALID_SHORTCODE_DELETION', $e->getType());
self::assertEquals(422, $e->getStatus());
}
public function provideThresholds(): array

View file

@ -24,14 +24,14 @@ class InvalidUrlExceptionTest extends TestCase
$expectedMessage = sprintf('Provided URL %s is invalid. Try with a different one.', $url);
$e = InvalidUrlException::fromUrl($url, $prev);
$this->assertEquals($expectedMessage, $e->getMessage());
$this->assertEquals($expectedMessage, $e->getDetail());
$this->assertEquals('Invalid URL', $e->getTitle());
$this->assertEquals('INVALID_URL', $e->getType());
$this->assertEquals(['url' => $url], $e->getAdditionalData());
$this->assertEquals(StatusCodeInterface::STATUS_BAD_REQUEST, $e->getCode());
$this->assertEquals(StatusCodeInterface::STATUS_BAD_REQUEST, $e->getStatus());
$this->assertEquals($prev, $e->getPrevious());
self::assertEquals($expectedMessage, $e->getMessage());
self::assertEquals($expectedMessage, $e->getDetail());
self::assertEquals('Invalid URL', $e->getTitle());
self::assertEquals('INVALID_URL', $e->getType());
self::assertEquals(['url' => $url], $e->getAdditionalData());
self::assertEquals(StatusCodeInterface::STATUS_BAD_REQUEST, $e->getCode());
self::assertEquals(StatusCodeInterface::STATUS_BAD_REQUEST, $e->getStatus());
self::assertEquals($prev, $e->getPrevious());
}
public function providePrevious(): iterable

View file

@ -18,10 +18,10 @@ class IpCannotBeLocatedExceptionTest extends TestCase
{
$e = IpCannotBeLocatedException::forEmptyAddress();
$this->assertTrue($e->isNonLocatableAddress());
$this->assertEquals('Ignored visit with no IP address', $e->getMessage());
$this->assertEquals(0, $e->getCode());
$this->assertNull($e->getPrevious());
self::assertTrue($e->isNonLocatableAddress());
self::assertEquals('Ignored visit with no IP address', $e->getMessage());
self::assertEquals(0, $e->getCode());
self::assertNull($e->getPrevious());
}
/** @test */
@ -29,10 +29,10 @@ class IpCannotBeLocatedExceptionTest extends TestCase
{
$e = IpCannotBeLocatedException::forLocalhost();
$this->assertTrue($e->isNonLocatableAddress());
$this->assertEquals('Ignored localhost address', $e->getMessage());
$this->assertEquals(0, $e->getCode());
$this->assertNull($e->getPrevious());
self::assertTrue($e->isNonLocatableAddress());
self::assertEquals('Ignored localhost address', $e->getMessage());
self::assertEquals(0, $e->getCode());
self::assertNull($e->getPrevious());
}
/**
@ -43,10 +43,10 @@ class IpCannotBeLocatedExceptionTest extends TestCase
{
$e = IpCannotBeLocatedException::forError($prev);
$this->assertFalse($e->isNonLocatableAddress());
$this->assertEquals('An error occurred while locating IP', $e->getMessage());
$this->assertEquals($prev->getCode(), $e->getCode());
$this->assertSame($prev, $e->getPrevious());
self::assertFalse($e->isNonLocatableAddress());
self::assertEquals('An error occurred while locating IP', $e->getMessage());
self::assertEquals($prev->getCode(), $e->getCode());
self::assertSame($prev, $e->getPrevious());
}
public function provideErrors(): iterable

View file

@ -22,12 +22,12 @@ class NonUniqueSlugExceptionTest extends TestCase
$e = NonUniqueSlugException::fromSlug($slug, $domain);
$this->assertEquals($expectedMessage, $e->getMessage());
$this->assertEquals($expectedMessage, $e->getDetail());
$this->assertEquals('Invalid custom slug', $e->getTitle());
$this->assertEquals('INVALID_SLUG', $e->getType());
$this->assertEquals(400, $e->getStatus());
$this->assertEquals($expectedAdditional, $e->getAdditionalData());
self::assertEquals($expectedMessage, $e->getMessage());
self::assertEquals($expectedMessage, $e->getDetail());
self::assertEquals('Invalid custom slug', $e->getTitle());
self::assertEquals('INVALID_SLUG', $e->getType());
self::assertEquals(400, $e->getStatus());
self::assertEquals($expectedAdditional, $e->getAdditionalData());
}
public function provideMessages(): iterable

View file

@ -26,12 +26,12 @@ class ShortUrlNotFoundExceptionTest extends TestCase
$e = ShortUrlNotFoundException::fromNotFound(new ShortUrlIdentifier($shortCode, $domain));
$this->assertEquals($expectedMessage, $e->getMessage());
$this->assertEquals($expectedMessage, $e->getDetail());
$this->assertEquals('Short URL not found', $e->getTitle());
$this->assertEquals('INVALID_SHORTCODE', $e->getType());
$this->assertEquals(404, $e->getStatus());
$this->assertEquals($expectedAdditional, $e->getAdditionalData());
self::assertEquals($expectedMessage, $e->getMessage());
self::assertEquals($expectedMessage, $e->getDetail());
self::assertEquals('Short URL not found', $e->getTitle());
self::assertEquals('INVALID_SHORTCODE', $e->getType());
self::assertEquals(404, $e->getStatus());
self::assertEquals($expectedAdditional, $e->getAdditionalData());
}
public function provideMessages(): iterable

View file

@ -19,11 +19,11 @@ class TagConflictExceptionTest extends TestCase
$expectedMessage = sprintf('You cannot rename tag %s to %s, because it already exists', $oldName, $newName);
$e = TagConflictException::fromExistingTag($oldName, $newName);
$this->assertEquals($expectedMessage, $e->getMessage());
$this->assertEquals($expectedMessage, $e->getDetail());
$this->assertEquals('Tag conflict', $e->getTitle());
$this->assertEquals('TAG_CONFLICT', $e->getType());
$this->assertEquals(['oldName' => $oldName, 'newName' => $newName], $e->getAdditionalData());
$this->assertEquals(409, $e->getStatus());
self::assertEquals($expectedMessage, $e->getMessage());
self::assertEquals($expectedMessage, $e->getDetail());
self::assertEquals('Tag conflict', $e->getTitle());
self::assertEquals('TAG_CONFLICT', $e->getType());
self::assertEquals(['oldName' => $oldName, 'newName' => $newName], $e->getAdditionalData());
self::assertEquals(409, $e->getStatus());
}
}

View file

@ -18,11 +18,11 @@ class TagNotFoundExceptionTest extends TestCase
$expectedMessage = sprintf('Tag with name "%s" could not be found', $tag);
$e = TagNotFoundException::fromTag($tag);
$this->assertEquals($expectedMessage, $e->getMessage());
$this->assertEquals($expectedMessage, $e->getDetail());
$this->assertEquals('Tag not found', $e->getTitle());
$this->assertEquals('TAG_NOT_FOUND', $e->getType());
$this->assertEquals(['tag' => $tag], $e->getAdditionalData());
$this->assertEquals(404, $e->getStatus());
self::assertEquals($expectedMessage, $e->getMessage());
self::assertEquals($expectedMessage, $e->getDetail());
self::assertEquals('Tag not found', $e->getTitle());
self::assertEquals('TAG_NOT_FOUND', $e->getType());
self::assertEquals(['tag' => $tag], $e->getAdditionalData());
self::assertEquals(404, $e->getStatus());
}
}

View file

@ -38,12 +38,12 @@ EOT;
$e = ValidationException::fromInputFilter($inputFilter->reveal());
$this->assertEquals($invalidData, $e->getInvalidElements());
$this->assertEquals(['invalidElements' => array_keys($invalidData)], $e->getAdditionalData());
$this->assertEquals('Provided data is not valid', $e->getMessage());
$this->assertEquals(StatusCodeInterface::STATUS_BAD_REQUEST, $e->getCode());
$this->assertEquals($prev, $e->getPrevious());
$this->assertStringContainsString($expectedStringRepresentation, (string) $e);
self::assertEquals($invalidData, $e->getInvalidElements());
self::assertEquals(['invalidElements' => array_keys($invalidData)], $e->getAdditionalData());
self::assertEquals('Provided data is not valid', $e->getMessage());
self::assertEquals(StatusCodeInterface::STATUS_BAD_REQUEST, $e->getCode());
self::assertEquals($prev, $e->getPrevious());
self::assertStringContainsString($expectedStringRepresentation, (string) $e);
$getMessages->shouldHaveBeenCalledOnce();
}

View file

@ -33,8 +33,8 @@ class MercureUpdatesGeneratorTest extends TestCase
$update = $this->generator->{$method}($visit);
$this->assertEquals([$expectedTopic], $update->getTopics());
$this->assertEquals([
self::assertEquals([$expectedTopic], $update->getTopics());
self::assertEquals([
'shortUrl' => [
'shortCode' => $shortUrl->getShortCode(),
'shortUrl' => 'http:/' . $shortUrl->getShortCode(),

View file

@ -68,17 +68,17 @@ class ShortUrlMetaTest extends TestCase
['validSince' => Chronos::parse('2015-01-01')->toAtomString(), 'customSlug' => $customSlug],
);
$this->assertTrue($meta->hasValidSince());
$this->assertEquals(Chronos::parse('2015-01-01'), $meta->getValidSince());
self::assertTrue($meta->hasValidSince());
self::assertEquals(Chronos::parse('2015-01-01'), $meta->getValidSince());
$this->assertFalse($meta->hasValidUntil());
$this->assertNull($meta->getValidUntil());
self::assertFalse($meta->hasValidUntil());
self::assertNull($meta->getValidUntil());
$this->assertTrue($meta->hasCustomSlug());
$this->assertEquals($expectedSlug, $meta->getCustomSlug());
self::assertTrue($meta->hasCustomSlug());
self::assertEquals($expectedSlug, $meta->getCustomSlug());
$this->assertFalse($meta->hasMaxVisits());
$this->assertNull($meta->getMaxVisits());
self::assertFalse($meta->hasMaxVisits());
self::assertNull($meta->getMaxVisits());
}
public function provideCustomSlugs(): iterable

View file

@ -23,9 +23,9 @@ class VisitorTest extends TestCase
$visitor = new Visitor(...$params);
['userAgent' => $userAgent, 'referer' => $referer, 'remoteAddress' => $remoteAddress] = $expected;
$this->assertEquals($userAgent, $visitor->getUserAgent());
$this->assertEquals($referer, $visitor->getReferer());
$this->assertEquals($remoteAddress, $visitor->getRemoteAddress());
self::assertEquals($userAgent, $visitor->getUserAgent());
self::assertEquals($referer, $visitor->getReferer());
self::assertEquals($remoteAddress, $visitor->getRemoteAddress());
}
public function provideParams(): iterable

View file

@ -44,7 +44,7 @@ class ShortUrlResolverTest extends TestCase
$result = $this->urlResolver->resolveShortUrl(new ShortUrlIdentifier($shortCode));
$this->assertSame($shortUrl, $result);
self::assertSame($shortUrl, $result);
$findOne->shouldHaveBeenCalledOnce();
$getRepo->shouldHaveBeenCalledOnce();
}
@ -77,7 +77,7 @@ class ShortUrlResolverTest extends TestCase
$result = $this->urlResolver->resolveEnabledShortUrl(new ShortUrlIdentifier($shortCode));
$this->assertSame($shortUrl, $result);
self::assertSame($shortUrl, $result);
$findOneByShortCode->shouldHaveBeenCalledOnce();
$getRepo->shouldHaveBeenCalledOnce();
}

View file

@ -61,7 +61,7 @@ class ShortUrlServiceTest extends TestCase
$this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal());
$list = $this->service->listShortUrls(ShortUrlsParams::emptyInstance());
$this->assertEquals(4, $list->getCurrentItemCount());
self::assertEquals(4, $list->getCurrentItemCount());
}
/** @test */
@ -97,11 +97,11 @@ class ShortUrlServiceTest extends TestCase
$result = $this->service->updateMetadataByShortCode(new ShortUrlIdentifier('abc123'), $shortUrlEdit);
$this->assertSame($shortUrl, $result);
$this->assertEquals($shortUrlEdit->validSince(), $shortUrl->getValidSince());
$this->assertEquals($shortUrlEdit->validUntil(), $shortUrl->getValidUntil());
$this->assertEquals($shortUrlEdit->maxVisits(), $shortUrl->getMaxVisits());
$this->assertEquals($shortUrlEdit->longUrl() ?? $originalLongUrl, $shortUrl->getLongUrl());
self::assertSame($shortUrl, $result);
self::assertEquals($shortUrlEdit->validSince(), $shortUrl->getValidSince());
self::assertEquals($shortUrlEdit->validUntil(), $shortUrl->getValidUntil());
self::assertEquals($shortUrlEdit->maxVisits(), $shortUrl->getMaxVisits());
self::assertEquals($shortUrlEdit->longUrl() ?? $originalLongUrl, $shortUrl->getLongUrl());
$findShortUrl->shouldHaveBeenCalled();
$flush->shouldHaveBeenCalled();
$this->urlValidator->validateUrl(

View file

@ -39,7 +39,7 @@ class TagServiceTest extends TestCase
$result = $this->service->listTags();
$this->assertEquals($expected, $result);
self::assertEquals($expected, $result);
$find->shouldHaveBeenCalled();
}
@ -52,7 +52,7 @@ class TagServiceTest extends TestCase
$result = $this->service->tagsInfo();
$this->assertEquals($expected, $result);
self::assertEquals($expected, $result);
$find->shouldHaveBeenCalled();
}
@ -75,7 +75,7 @@ class TagServiceTest extends TestCase
$result = $this->service->createTags(['foo', 'bar']);
$this->assertCount(2, $result);
self::assertCount(2, $result);
$find->shouldHaveBeenCalled();
$persist->shouldHaveBeenCalledTimes(2);
$flush->shouldHaveBeenCalled();
@ -106,8 +106,8 @@ class TagServiceTest extends TestCase
$tag = $this->service->renameTag($oldName, $newName);
$this->assertSame($expected, $tag);
$this->assertEquals($newName, (string) $tag);
self::assertSame($expected, $tag);
self::assertEquals($newName, (string) $tag);
$find->shouldHaveBeenCalled();
$flush->shouldHaveBeenCalled();
$countTags->shouldHaveBeenCalledTimes($count > 0 ? 0 : 1);

View file

@ -67,7 +67,7 @@ class UrlShortenerTest extends TestCase
ShortUrlMeta::createEmpty(),
);
$this->assertEquals('http://foobar.com/12345/hello?foo=bar', $shortUrl->getLongUrl());
self::assertEquals('http://foobar.com/12345/hello?foo=bar', $shortUrl->getLongUrl());
}
/** @test */
@ -91,7 +91,7 @@ class UrlShortenerTest extends TestCase
ShortUrlMeta::createEmpty(),
);
$this->assertEquals('http://foobar.com/12345/hello?foo=bar', $shortUrl->getLongUrl());
self::assertEquals('http://foobar.com/12345/hello?foo=bar', $shortUrl->getLongUrl());
$getRepo->shouldBeCalledTimes($expectedCalls);
$shortCodeIsInUse->shouldBeCalledTimes($expectedCalls);
}
@ -154,7 +154,7 @@ class UrlShortenerTest extends TestCase
$getRepo->shouldHaveBeenCalledOnce();
$this->em->persist(Argument::cetera())->shouldNotHaveBeenCalled();
$this->urlValidator->validateUrl(Argument::cetera())->shouldNotHaveBeenCalled();
$this->assertSame($expected, $result);
self::assertSame($expected, $result);
}
public function provideExistingShortUrls(): iterable

View file

@ -71,7 +71,7 @@ class VisitsTrackerTest extends TestCase
$paginator = $this->visitsTracker->info(new ShortUrlIdentifier($shortCode), new VisitsParams());
$this->assertEquals($list, ArrayUtils::iteratorToArray($paginator->getCurrentItems()));
self::assertEquals($list, ArrayUtils::iteratorToArray($paginator->getCurrentItems()));
$count->shouldHaveBeenCalledOnce();
}
@ -120,7 +120,7 @@ class VisitsTrackerTest extends TestCase
$paginator = $this->visitsTracker->visitsForTag($tag, new VisitsParams());
$this->assertEquals($list, ArrayUtils::iteratorToArray($paginator->getCurrentItems()));
self::assertEquals($list, ArrayUtils::iteratorToArray($paginator->getCurrentItems()));
$count->shouldHaveBeenCalledOnce();
$getRepo->shouldHaveBeenCalledOnce();
}

View file

@ -29,7 +29,7 @@ class ShortUrlDataTransformerTest extends TestCase
{
['meta' => $meta] = $this->transformer->transform($shortUrl);
$this->assertEquals($expectedMeta, $meta);
self::assertEquals($expectedMeta, $meta);
}
public function provideShortUrls(): iterable

View file

@ -38,7 +38,7 @@ class VisitsStatsHelperTest extends TestCase
$stats = $this->helper->getVisitsStats();
$this->assertEquals(new VisitsStats($expectedCount), $stats);
self::assertEquals(new VisitsStats($expectedCount), $stats);
$count->shouldHaveBeenCalledOnce();
$getRepo->shouldHaveBeenCalledOnce();
}

View file

@ -20,9 +20,9 @@ class CreateShortUrlActionTest extends ApiTestCase
$expectedKeys = ['shortCode', 'shortUrl', 'longUrl', 'dateCreated', 'visitsCount', 'tags'];
[$statusCode, $payload] = $this->createShortUrl();
$this->assertEquals(self::STATUS_OK, $statusCode);
self::assertEquals(self::STATUS_OK, $statusCode);
foreach ($expectedKeys as $key) {
$this->assertArrayHasKey($key, $payload);
self::assertArrayHasKey($key, $payload);
}
}
@ -31,8 +31,8 @@ class CreateShortUrlActionTest extends ApiTestCase
{
[$statusCode, $payload] = $this->createShortUrl(['customSlug' => 'my cool slug']);
$this->assertEquals(self::STATUS_OK, $statusCode);
$this->assertEquals('my-cool-slug', $payload['shortCode']);
self::assertEquals(self::STATUS_OK, $statusCode);
self::assertEquals('my-cool-slug', $payload['shortCode']);
}
/**
@ -46,17 +46,17 @@ class CreateShortUrlActionTest extends ApiTestCase
[$statusCode, $payload] = $this->createShortUrl(['customSlug' => $slug, 'domain' => $domain]);
$this->assertEquals(self::STATUS_BAD_REQUEST, $statusCode);
$this->assertEquals(self::STATUS_BAD_REQUEST, $payload['status']);
$this->assertEquals($detail, $payload['detail']);
$this->assertEquals('INVALID_SLUG', $payload['type']);
$this->assertEquals('Invalid custom slug', $payload['title']);
$this->assertEquals($slug, $payload['customSlug']);
self::assertEquals(self::STATUS_BAD_REQUEST, $statusCode);
self::assertEquals(self::STATUS_BAD_REQUEST, $payload['status']);
self::assertEquals($detail, $payload['detail']);
self::assertEquals('INVALID_SLUG', $payload['type']);
self::assertEquals('Invalid custom slug', $payload['title']);
self::assertEquals($slug, $payload['customSlug']);
if ($domain !== null) {
$this->assertEquals($domain, $payload['domain']);
self::assertEquals($domain, $payload['domain']);
} else {
$this->assertArrayNotHasKey('domain', $payload);
self::assertArrayNotHasKey('domain', $payload);
}
}
@ -65,8 +65,8 @@ class CreateShortUrlActionTest extends ApiTestCase
{
[$statusCode, ['tags' => $tags]] = $this->createShortUrl(['tags' => ['foo', 'bar', 'baz']]);
$this->assertEquals(self::STATUS_OK, $statusCode);
$this->assertEquals(['foo', 'bar', 'baz'], $tags);
self::assertEquals(self::STATUS_OK, $statusCode);
self::assertEquals(['foo', 'bar', 'baz'], $tags);
}
/**
@ -77,14 +77,14 @@ class CreateShortUrlActionTest extends ApiTestCase
{
[$statusCode, ['shortCode' => $shortCode]] = $this->createShortUrl(['maxVisits' => $maxVisits]);
$this->assertEquals(self::STATUS_OK, $statusCode);
self::assertEquals(self::STATUS_OK, $statusCode);
// Last request to the short URL will return a 404, and the rest, a 302
for ($i = 0; $i < $maxVisits; $i++) {
$this->assertEquals(self::STATUS_FOUND, $this->callShortUrl($shortCode)->getStatusCode());
self::assertEquals(self::STATUS_FOUND, $this->callShortUrl($shortCode)->getStatusCode());
}
$lastResp = $this->callShortUrl($shortCode);
$this->assertEquals(self::STATUS_NOT_FOUND, $lastResp->getStatusCode());
self::assertEquals(self::STATUS_NOT_FOUND, $lastResp->getStatusCode());
}
public function provideMaxVisits(): array
@ -99,11 +99,11 @@ class CreateShortUrlActionTest extends ApiTestCase
'validSince' => Chronos::now()->addDay()->toAtomString(),
]);
$this->assertEquals(self::STATUS_OK, $statusCode);
self::assertEquals(self::STATUS_OK, $statusCode);
// Request to the short URL will return a 404 since it's not valid yet
$lastResp = $this->callShortUrl($shortCode);
$this->assertEquals(self::STATUS_NOT_FOUND, $lastResp->getStatusCode());
self::assertEquals(self::STATUS_NOT_FOUND, $lastResp->getStatusCode());
}
/** @test */
@ -113,11 +113,11 @@ class CreateShortUrlActionTest extends ApiTestCase
'validUntil' => Chronos::now()->subDay()->toAtomString(),
]);
$this->assertEquals(self::STATUS_OK, $statusCode);
self::assertEquals(self::STATUS_OK, $statusCode);
// Request to the short URL will return a 404 since it's no longer valid
$lastResp = $this->callShortUrl($shortCode);
$this->assertEquals(self::STATUS_NOT_FOUND, $lastResp->getStatusCode());
self::assertEquals(self::STATUS_NOT_FOUND, $lastResp->getStatusCode());
}
/**
@ -131,9 +131,9 @@ class CreateShortUrlActionTest extends ApiTestCase
$body['findIfExists'] = true;
[$secondStatusCode, ['shortCode' => $secondShortCode]] = $this->createShortUrl($body);
$this->assertEquals(self::STATUS_OK, $firstStatusCode);
$this->assertEquals(self::STATUS_OK, $secondStatusCode);
$this->assertEquals($firstShortCode, $secondShortCode);
self::assertEquals(self::STATUS_OK, $firstStatusCode);
self::assertEquals(self::STATUS_OK, $secondStatusCode);
self::assertEquals($firstShortCode, $secondShortCode);
}
public function provideMatchingBodies(): iterable
@ -167,8 +167,8 @@ class CreateShortUrlActionTest extends ApiTestCase
'domain' => $domain,
]);
$this->assertEquals(self::STATUS_OK, $firstStatusCode);
$this->assertEquals(self::STATUS_BAD_REQUEST, $secondStatusCode);
self::assertEquals(self::STATUS_OK, $firstStatusCode);
self::assertEquals(self::STATUS_BAD_REQUEST, $secondStatusCode);
}
public function provideConflictingSlugs(): iterable
@ -188,9 +188,9 @@ class CreateShortUrlActionTest extends ApiTestCase
'findIfExists' => true,
]);
$this->assertEquals(self::STATUS_OK, $firstStatusCode);
$this->assertEquals(self::STATUS_OK, $secondStatusCode);
$this->assertNotEquals($firstShortCode, $secondShortCode);
self::assertEquals(self::STATUS_OK, $firstStatusCode);
self::assertEquals(self::STATUS_OK, $secondStatusCode);
self::assertNotEquals($firstShortCode, $secondShortCode);
}
/**
@ -201,8 +201,8 @@ class CreateShortUrlActionTest extends ApiTestCase
{
[$statusCode, $payload] = $this->createShortUrl(['longUrl' => $longUrl]);
$this->assertEquals(self::STATUS_OK, $statusCode);
$this->assertEquals($payload['longUrl'], $longUrl);
self::assertEquals(self::STATUS_OK, $statusCode);
self::assertEquals($payload['longUrl'], $longUrl);
}
public function provideIdn(): iterable
@ -220,12 +220,12 @@ class CreateShortUrlActionTest extends ApiTestCase
[$statusCode, $payload] = $this->createShortUrl(['longUrl' => $url]);
$this->assertEquals(self::STATUS_BAD_REQUEST, $statusCode);
$this->assertEquals(self::STATUS_BAD_REQUEST, $payload['status']);
$this->assertEquals('INVALID_URL', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Invalid URL', $payload['title']);
$this->assertEquals($url, $payload['url']);
self::assertEquals(self::STATUS_BAD_REQUEST, $statusCode);
self::assertEquals(self::STATUS_BAD_REQUEST, $payload['status']);
self::assertEquals('INVALID_URL', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Invalid URL', $payload['title']);
self::assertEquals($url, $payload['url']);
}
/** @test */
@ -238,10 +238,10 @@ class CreateShortUrlActionTest extends ApiTestCase
$getResp = $this->callApiWithKey(self::METHOD_GET, '/short-urls/' . $shortCode);
$payload = $this->getJsonResponsePayload($getResp);
$this->assertEquals(self::STATUS_OK, $createStatusCode);
$this->assertEquals(self::STATUS_OK, $getResp->getStatusCode());
$this->assertArrayHasKey('domain', $payload);
$this->assertNull($payload['domain']);
self::assertEquals(self::STATUS_OK, $createStatusCode);
self::assertEquals(self::STATUS_OK, $getResp->getStatusCode());
self::assertArrayHasKey('domain', $payload);
self::assertNull($payload['domain']);
}
/**

View file

@ -23,13 +23,13 @@ class DeleteShortUrlActionTest extends ApiTestCase
$resp = $this->callApiWithKey(self::METHOD_DELETE, $this->buildShortUrlPath($shortCode, $domain));
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
$this->assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
$this->assertEquals('INVALID_SHORTCODE', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Short URL not found', $payload['title']);
$this->assertEquals($shortCode, $payload['shortCode']);
$this->assertEquals($domain, $payload['domain'] ?? null);
self::assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
self::assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
self::assertEquals('INVALID_SHORTCODE', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Short URL not found', $payload['title']);
self::assertEquals($shortCode, $payload['shortCode']);
self::assertEquals($domain, $payload['domain'] ?? null);
}
/** @test */
@ -37,18 +37,18 @@ class DeleteShortUrlActionTest extends ApiTestCase
{
// Generate visits first
for ($i = 0; $i < 20; $i++) {
$this->assertEquals(self::STATUS_FOUND, $this->callShortUrl('abc123')->getStatusCode());
self::assertEquals(self::STATUS_FOUND, $this->callShortUrl('abc123')->getStatusCode());
}
$expectedDetail = 'Impossible to delete short URL with short code "abc123" since it has more than "15" visits.';
$resp = $this->callApiWithKey(self::METHOD_DELETE, '/short-urls/abc123');
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_UNPROCESSABLE_ENTITY, $resp->getStatusCode());
$this->assertEquals(self::STATUS_UNPROCESSABLE_ENTITY, $payload['status']);
$this->assertEquals('INVALID_SHORTCODE_DELETION', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Cannot delete short URL', $payload['title']);
self::assertEquals(self::STATUS_UNPROCESSABLE_ENTITY, $resp->getStatusCode());
self::assertEquals(self::STATUS_UNPROCESSABLE_ENTITY, $payload['status']);
self::assertEquals('INVALID_SHORTCODE_DELETION', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Cannot delete short URL', $payload['title']);
}
/** @test */
@ -60,10 +60,10 @@ class DeleteShortUrlActionTest extends ApiTestCase
$fetchWithDomainAfter = $this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789?domain=example.com');
$fetchWithoutDomainAfter = $this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789');
$this->assertEquals(self::STATUS_OK, $fetchWithDomainBefore->getStatusCode());
$this->assertEquals(self::STATUS_OK, $fetchWithoutDomainBefore->getStatusCode());
$this->assertEquals(self::STATUS_NO_CONTENT, $deleteResp->getStatusCode());
$this->assertEquals(self::STATUS_NOT_FOUND, $fetchWithDomainAfter->getStatusCode());
$this->assertEquals(self::STATUS_OK, $fetchWithoutDomainAfter->getStatusCode());
self::assertEquals(self::STATUS_OK, $fetchWithDomainBefore->getStatusCode());
self::assertEquals(self::STATUS_OK, $fetchWithoutDomainBefore->getStatusCode());
self::assertEquals(self::STATUS_NO_CONTENT, $deleteResp->getStatusCode());
self::assertEquals(self::STATUS_NOT_FOUND, $fetchWithDomainAfter->getStatusCode());
self::assertEquals(self::STATUS_OK, $fetchWithoutDomainAfter->getStatusCode());
}
}

View file

@ -41,9 +41,9 @@ class EditShortUrlActionTest extends ApiTestCase
]);
$metaAfterResetting = $this->findShortUrlMetaByShortCode($shortCode);
$this->assertEquals(self::STATUS_NO_CONTENT, $editWithProvidedMeta->getStatusCode());
$this->assertEquals(self::STATUS_NO_CONTENT, $editWithResetMeta->getStatusCode());
$this->assertEquals($resetMeta, $metaAfterResetting);
self::assertEquals(self::STATUS_NO_CONTENT, $editWithProvidedMeta->getStatusCode());
self::assertEquals(self::STATUS_NO_CONTENT, $editWithResetMeta->getStatusCode());
self::assertEquals($resetMeta, $metaAfterResetting);
self::assertArraySubset($meta, $metaAfterEditing);
}
@ -84,10 +84,10 @@ class EditShortUrlActionTest extends ApiTestCase
'longUrl' => $longUrl,
]]);
$this->assertEquals($expectedStatus, $resp->getStatusCode());
self::assertEquals($expectedStatus, $resp->getStatusCode());
if ($expectedError !== null) {
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals($expectedError, $payload['type']);
self::assertEquals($expectedError, $payload['type']);
}
}
@ -110,13 +110,13 @@ class EditShortUrlActionTest extends ApiTestCase
$resp = $this->callApiWithKey(self::METHOD_PATCH, $url, [RequestOptions::JSON => []]);
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
$this->assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
$this->assertEquals('INVALID_SHORTCODE', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Short URL not found', $payload['title']);
$this->assertEquals($shortCode, $payload['shortCode']);
$this->assertEquals($domain, $payload['domain'] ?? null);
self::assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
self::assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
self::assertEquals('INVALID_SHORTCODE', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Short URL not found', $payload['title']);
self::assertEquals($shortCode, $payload['shortCode']);
self::assertEquals($domain, $payload['domain'] ?? null);
}
/** @test */
@ -129,11 +129,11 @@ class EditShortUrlActionTest extends ApiTestCase
]]);
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_BAD_REQUEST, $resp->getStatusCode());
$this->assertEquals(self::STATUS_BAD_REQUEST, $payload['status']);
$this->assertEquals('INVALID_ARGUMENT', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Invalid data', $payload['title']);
self::assertEquals(self::STATUS_BAD_REQUEST, $resp->getStatusCode());
self::assertEquals(self::STATUS_BAD_REQUEST, $payload['status']);
self::assertEquals('INVALID_ARGUMENT', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Invalid data', $payload['title']);
}
/**
@ -154,10 +154,10 @@ class EditShortUrlActionTest extends ApiTestCase
]]);
$editedShortUrl = $this->getJsonResponsePayload($this->callApiWithKey(self::METHOD_GET, (string) $url));
$this->assertEquals(self::STATUS_NO_CONTENT, $editResp->getStatusCode());
$this->assertEquals($domain, $editedShortUrl['domain']);
$this->assertEquals($expectedUrl, $editedShortUrl['longUrl']);
$this->assertEquals(100, $editedShortUrl['meta']['maxVisits'] ?? null);
self::assertEquals(self::STATUS_NO_CONTENT, $editResp->getStatusCode());
self::assertEquals($domain, $editedShortUrl['domain']);
self::assertEquals($expectedUrl, $editedShortUrl['longUrl']);
self::assertEquals(100, $editedShortUrl['meta']['maxVisits'] ?? null);
}
public function provideDomains(): iterable

View file

@ -20,11 +20,11 @@ class EditShortUrlTagsActionTest extends ApiTestCase
$resp = $this->callApiWithKey(self::METHOD_PUT, '/short-urls/abc123/tags', [RequestOptions::JSON => []]);
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_BAD_REQUEST, $resp->getStatusCode());
$this->assertEquals(self::STATUS_BAD_REQUEST, $payload['status']);
$this->assertEquals('INVALID_ARGUMENT', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Invalid data', $payload['title']);
self::assertEquals(self::STATUS_BAD_REQUEST, $resp->getStatusCode());
self::assertEquals(self::STATUS_BAD_REQUEST, $payload['status']);
self::assertEquals('INVALID_ARGUMENT', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Invalid data', $payload['title']);
}
/**
@ -42,13 +42,13 @@ class EditShortUrlTagsActionTest extends ApiTestCase
]]);
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
$this->assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
$this->assertEquals('INVALID_SHORTCODE', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Short URL not found', $payload['title']);
$this->assertEquals($shortCode, $payload['shortCode']);
$this->assertEquals($domain, $payload['domain'] ?? null);
self::assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
self::assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
self::assertEquals('INVALID_SHORTCODE', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Short URL not found', $payload['title']);
self::assertEquals($shortCode, $payload['shortCode']);
self::assertEquals($domain, $payload['domain'] ?? null);
}
/** @test */
@ -67,8 +67,8 @@ class EditShortUrlTagsActionTest extends ApiTestCase
$this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789?domain=example.com'),
);
$this->assertEquals(self::STATUS_OK, $setTagsWithDomain->getStatusCode());
$this->assertEquals([], $fetchWithoutDomain['tags']);
$this->assertEquals(['bar', 'foo'], $fetchWithDomain['tags']);
self::assertEquals(self::STATUS_OK, $setTagsWithDomain->getStatusCode());
self::assertEquals([], $fetchWithoutDomain['tags']);
self::assertEquals(['bar', 'foo'], $fetchWithDomain['tags']);
}
}

View file

@ -14,8 +14,8 @@ class GlobalVisitsActionTest extends ApiTestCase
$resp = $this->callApiWithKey(self::METHOD_GET, '/visits');
$payload = $this->getJsonResponsePayload($resp);
$this->assertArrayHasKey('visits', $payload);
$this->assertArrayHasKey('visitsCount', $payload['visits']);
$this->assertEquals(7, $payload['visits']['visitsCount']);
self::assertArrayHasKey('visits', $payload);
self::assertArrayHasKey('visitsCount', $payload['visits']);
self::assertEquals(7, $payload['visits']['visitsCount']);
}
}

View file

@ -110,8 +110,8 @@ class ListShortUrlsTest extends ApiTestCase
$resp = $this->callApiWithKey(self::METHOD_GET, '/short-urls', [RequestOptions::QUERY => $query]);
$respPayload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_OK, $resp->getStatusCode());
$this->assertEquals([
self::assertEquals(self::STATUS_OK, $resp->getStatusCode());
self::assertEquals([
'shortUrls' => [
'data' => $expectedShortUrls,
'pagination' => $this->buildPagination(count($expectedShortUrls)),

View file

@ -18,7 +18,7 @@ class ListTagsActionTest extends ApiTestCase
$resp = $this->callApiWithKey(self::METHOD_GET, '/tags', [RequestOptions::QUERY => $query]);
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(['tags' => $expectedTags], $payload);
self::assertEquals(['tags' => $expectedTags], $payload);
}
public function provideQueries(): iterable

View file

@ -29,9 +29,9 @@ class ResolveShortUrlActionTest extends ApiTestCase
$visitResp = $this->callShortUrl($shortCode);
$fetchResp = $this->callApiWithKey(self::METHOD_GET, $url);
$this->assertEquals(self::STATUS_NO_CONTENT, $editResp->getStatusCode());
$this->assertEquals(self::STATUS_NOT_FOUND, $visitResp->getStatusCode());
$this->assertEquals(self::STATUS_OK, $fetchResp->getStatusCode());
self::assertEquals(self::STATUS_NO_CONTENT, $editResp->getStatusCode());
self::assertEquals(self::STATUS_NOT_FOUND, $visitResp->getStatusCode());
self::assertEquals(self::STATUS_OK, $fetchResp->getStatusCode());
}
public function provideDisabledMeta(): iterable
@ -55,12 +55,12 @@ class ResolveShortUrlActionTest extends ApiTestCase
$resp = $this->callApiWithKey(self::METHOD_GET, $this->buildShortUrlPath($shortCode, $domain));
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
$this->assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
$this->assertEquals('INVALID_SHORTCODE', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Short URL not found', $payload['title']);
$this->assertEquals($shortCode, $payload['shortCode']);
$this->assertEquals($domain, $payload['domain'] ?? null);
self::assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
self::assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
self::assertEquals('INVALID_SHORTCODE', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Short URL not found', $payload['title']);
self::assertEquals($shortCode, $payload['shortCode']);
self::assertEquals($domain, $payload['domain'] ?? null);
}
}

View file

@ -27,13 +27,13 @@ class ShortUrlVisitsActionTest extends ApiTestCase
$resp = $this->callApiWithKey(self::METHOD_GET, $this->buildShortUrlPath($shortCode, $domain, '/visits'));
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
$this->assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
$this->assertEquals('INVALID_SHORTCODE', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Short URL not found', $payload['title']);
$this->assertEquals($shortCode, $payload['shortCode']);
$this->assertEquals($domain, $payload['domain'] ?? null);
self::assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
self::assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
self::assertEquals('INVALID_SHORTCODE', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Short URL not found', $payload['title']);
self::assertEquals($shortCode, $payload['shortCode']);
self::assertEquals($domain, $payload['domain'] ?? null);
}
/**
@ -52,8 +52,8 @@ class ShortUrlVisitsActionTest extends ApiTestCase
$resp = $this->callApiWithKey(self::METHOD_GET, (string) $url);
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals($expectedAmountOfVisits, $payload['visits']['pagination']['totalItems'] ?? -1);
$this->assertCount($expectedAmountOfVisits, $payload['visits']['data'] ?? []);
self::assertEquals($expectedAmountOfVisits, $payload['visits']['pagination']['totalItems'] ?? -1);
self::assertCount($expectedAmountOfVisits, $payload['visits']['data'] ?? []);
}
public function provideDomains(): iterable

View file

@ -19,9 +19,9 @@ class TagVisitsActionTest extends ApiTestCase
$resp = $this->callApiWithKey(self::METHOD_GET, sprintf('/tags/%s/visits', $tag));
$payload = $this->getJsonResponsePayload($resp);
$this->assertArrayHasKey('visits', $payload);
$this->assertArrayHasKey('data', $payload['visits']);
$this->assertCount($expectedVisitsAmount, $payload['visits']['data']);
self::assertArrayHasKey('visits', $payload);
self::assertArrayHasKey('data', $payload['visits']);
self::assertCount($expectedVisitsAmount, $payload['visits']['data']);
}
public function provideTags(): iterable
@ -37,10 +37,10 @@ class TagVisitsActionTest extends ApiTestCase
$resp = $this->callApiWithKey(self::METHOD_GET, '/tags/invalid_tag/visits');
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
$this->assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
$this->assertEquals('TAG_NOT_FOUND', $payload['type']);
$this->assertEquals('Tag with name "invalid_tag" could not be found', $payload['detail']);
$this->assertEquals('Tag not found', $payload['title']);
self::assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
self::assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
self::assertEquals('TAG_NOT_FOUND', $payload['type']);
self::assertEquals('Tag with name "invalid_tag" could not be found', $payload['detail']);
self::assertEquals('Tag not found', $payload['title']);
}
}

View file

@ -20,11 +20,11 @@ class UpdateTagActionTest extends ApiTestCase
$resp = $this->callApiWithKey(self::METHOD_PUT, '/tags', [RequestOptions::JSON => $body]);
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_BAD_REQUEST, $resp->getStatusCode());
$this->assertEquals(self::STATUS_BAD_REQUEST, $payload['status']);
$this->assertEquals('INVALID_ARGUMENT', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Invalid data', $payload['title']);
self::assertEquals(self::STATUS_BAD_REQUEST, $resp->getStatusCode());
self::assertEquals(self::STATUS_BAD_REQUEST, $payload['status']);
self::assertEquals('INVALID_ARGUMENT', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Invalid data', $payload['title']);
}
public function provideInvalidBody(): iterable
@ -45,11 +45,11 @@ class UpdateTagActionTest extends ApiTestCase
]]);
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
$this->assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
$this->assertEquals('TAG_NOT_FOUND', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Tag not found', $payload['title']);
self::assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
self::assertEquals(self::STATUS_NOT_FOUND, $payload['status']);
self::assertEquals('TAG_NOT_FOUND', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Tag not found', $payload['title']);
}
/** @test */
@ -63,11 +63,11 @@ class UpdateTagActionTest extends ApiTestCase
]]);
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_CONFLICT, $resp->getStatusCode());
$this->assertEquals(self::STATUS_CONFLICT, $payload['status']);
$this->assertEquals('TAG_CONFLICT', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Tag conflict', $payload['title']);
self::assertEquals(self::STATUS_CONFLICT, $resp->getStatusCode());
self::assertEquals(self::STATUS_CONFLICT, $payload['status']);
self::assertEquals('TAG_CONFLICT', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Tag conflict', $payload['title']);
}
/** @test */
@ -78,6 +78,6 @@ class UpdateTagActionTest extends ApiTestCase
'newName' => 'foo',
]]);
$this->assertEquals(self::STATUS_NO_CONTENT, $resp->getStatusCode());
self::assertEquals(self::STATUS_NO_CONTENT, $resp->getStatusCode());
}
}

View file

@ -24,11 +24,11 @@ class AuthenticationTest extends ApiTestCase
$resp = $this->callApi(self::METHOD_GET, '/short-urls');
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_UNAUTHORIZED, $resp->getStatusCode());
$this->assertEquals(self::STATUS_UNAUTHORIZED, $payload['status']);
$this->assertEquals('INVALID_AUTHORIZATION', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Invalid authorization', $payload['title']);
self::assertEquals(self::STATUS_UNAUTHORIZED, $resp->getStatusCode());
self::assertEquals(self::STATUS_UNAUTHORIZED, $payload['status']);
self::assertEquals('INVALID_AUTHORIZATION', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Invalid authorization', $payload['title']);
}
/**
@ -46,11 +46,11 @@ class AuthenticationTest extends ApiTestCase
]);
$payload = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_UNAUTHORIZED, $resp->getStatusCode());
$this->assertEquals(self::STATUS_UNAUTHORIZED, $payload['status']);
$this->assertEquals('INVALID_API_KEY', $payload['type']);
$this->assertEquals($expectedDetail, $payload['detail']);
$this->assertEquals('Invalid API key', $payload['title']);
self::assertEquals(self::STATUS_UNAUTHORIZED, $resp->getStatusCode());
self::assertEquals(self::STATUS_UNAUTHORIZED, $payload['status']);
self::assertEquals('INVALID_API_KEY', $payload['type']);
self::assertEquals($expectedDetail, $payload['detail']);
self::assertEquals('Invalid API key', $payload['title']);
}
public function provideInvalidApiKeys(): iterable

View file

@ -15,8 +15,8 @@ class ImplicitOptionsTest extends ApiTestCase
{
$resp = $this->callApi(self::METHOD_OPTIONS, '/short-urls');
$this->assertEquals(self::STATUS_NO_CONTENT, $resp->getStatusCode());
$this->assertEmpty((string) $resp->getBody());
self::assertEquals(self::STATUS_NO_CONTENT, $resp->getStatusCode());
self::assertEmpty((string) $resp->getBody());
}
/** @test */
@ -25,7 +25,7 @@ class ImplicitOptionsTest extends ApiTestCase
$resp = $this->callApi(self::METHOD_OPTIONS, '/short-urls');
$allowedMethods = $resp->getHeaderLine('Allow');
$this->assertEquals([
self::assertEquals([
self::METHOD_GET,
self::METHOD_POST,
], explode(',', $allowedMethods));

View file

@ -37,14 +37,14 @@ class HealthActionTest extends TestCase
$resp = $this->action->handle(new ServerRequest());
$payload = $resp->getPayload();
$this->assertEquals(200, $resp->getStatusCode());
$this->assertEquals('pass', $payload['status']);
$this->assertEquals('1.2.3', $payload['version']);
$this->assertEquals([
self::assertEquals(200, $resp->getStatusCode());
self::assertEquals('pass', $payload['status']);
self::assertEquals('1.2.3', $payload['version']);
self::assertEquals([
'about' => 'https://shlink.io',
'project' => 'https://github.com/shlinkio/shlink',
], $payload['links']);
$this->assertEquals('application/health+json', $resp->getHeaderLine('Content-type'));
self::assertEquals('application/health+json', $resp->getHeaderLine('Content-type'));
$ping->shouldHaveBeenCalledOnce();
}
@ -57,14 +57,14 @@ class HealthActionTest extends TestCase
$resp = $this->action->handle(new ServerRequest());
$payload = $resp->getPayload();
$this->assertEquals(503, $resp->getStatusCode());
$this->assertEquals('fail', $payload['status']);
$this->assertEquals('1.2.3', $payload['version']);
$this->assertEquals([
self::assertEquals(503, $resp->getStatusCode());
self::assertEquals('fail', $payload['status']);
self::assertEquals('1.2.3', $payload['version']);
self::assertEquals([
'about' => 'https://shlink.io',
'project' => 'https://github.com/shlinkio/shlink',
], $payload['links']);
$this->assertEquals('application/health+json', $resp->getHeaderLine('Content-type'));
self::assertEquals('application/health+json', $resp->getHeaderLine('Content-type'));
$ping->shouldHaveBeenCalledOnce();
}
@ -77,14 +77,14 @@ class HealthActionTest extends TestCase
$resp = $this->action->handle(new ServerRequest());
$payload = $resp->getPayload();
$this->assertEquals(503, $resp->getStatusCode());
$this->assertEquals('fail', $payload['status']);
$this->assertEquals('1.2.3', $payload['version']);
$this->assertEquals([
self::assertEquals(503, $resp->getStatusCode());
self::assertEquals('fail', $payload['status']);
self::assertEquals('1.2.3', $payload['version']);
self::assertEquals([
'about' => 'https://shlink.io',
'project' => 'https://github.com/shlinkio/shlink',
], $payload['links']);
$this->assertEquals('application/health+json', $resp->getHeaderLine('Content-type'));
self::assertEquals('application/health+json', $resp->getHeaderLine('Content-type'));
$ping->shouldHaveBeenCalledOnce();
}
}

View file

@ -87,11 +87,11 @@ class MercureInfoActionTest extends TestCase
$resp = $action->handle(ServerRequestFactory::fromGlobals());
$payload = $resp->getPayload();
$this->assertArrayHasKey('mercureHubUrl', $payload);
$this->assertEquals('http://foobar.com/.well-known/mercure', $payload['mercureHubUrl']);
$this->assertArrayHasKey('token', $payload);
$this->assertArrayHasKey('jwtExpiration', $payload);
$this->assertEquals(
self::assertArrayHasKey('mercureHubUrl', $payload);
self::assertEquals('http://foobar.com/.well-known/mercure', $payload['mercureHubUrl']);
self::assertArrayHasKey('token', $payload);
self::assertArrayHasKey('jwtExpiration', $payload);
self::assertEquals(
Chronos::now()->addDays($days ?? 1)->startOfDay(),
Chronos::parse($payload['jwtExpiration'])->startOfDay(),
);

View file

@ -57,8 +57,8 @@ class CreateShortUrlActionTest extends TestCase
$request = ServerRequestFactory::fromGlobals()->withParsedBody($body);
$response = $this->action->handle($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue(strpos($response->getBody()->getContents(), $shortUrl->toString(self::DOMAIN_CONFIG)) > 0);
self::assertEquals(200, $response->getStatusCode());
self::assertTrue(strpos($response->getBody()->getContents(), $shortUrl->toString(self::DOMAIN_CONFIG)) > 0);
$shorten->shouldHaveBeenCalledOnce();
}

View file

@ -30,7 +30,7 @@ class DeleteShortUrlActionTest extends TestCase
$resp = $this->action->handle(new ServerRequest());
$this->assertEquals(204, $resp->getStatusCode());
self::assertEquals(204, $resp->getStatusCode());
$deleteByShortCode->shouldHaveBeenCalledOnce();
}
}

View file

@ -49,7 +49,7 @@ class EditShortUrlActionTest extends TestCase
$resp = $this->action->handle($request);
$this->assertEquals(204, $resp->getStatusCode());
self::assertEquals(204, $resp->getStatusCode());
$updateMeta->shouldHaveBeenCalled();
}
}

View file

@ -42,6 +42,6 @@ class EditShortUrlTagsActionTest extends TestCase
(new ServerRequest())->withAttribute('shortCode', 'abc123')
->withParsedBody(['tags' => []]),
);
$this->assertEquals(200, $response->getStatusCode());
self::assertEquals(200, $response->getStatusCode());
}
}

View file

@ -59,10 +59,10 @@ class ListShortUrlsActionTest extends TestCase
$response = $this->action->handle((new ServerRequest())->withQueryParams($query));
$payload = $response->getPayload();
$this->assertArrayHasKey('shortUrls', $payload);
$this->assertArrayHasKey('data', $payload['shortUrls']);
$this->assertEquals([], $payload['shortUrls']['data']);
$this->assertEquals(200, $response->getStatusCode());
self::assertArrayHasKey('shortUrls', $payload);
self::assertArrayHasKey('data', $payload['shortUrls']);
self::assertEquals([], $payload['shortUrls']['data']);
self::assertEquals(200, $response->getStatusCode());
$listShortUrls->shouldHaveBeenCalledOnce();
}

View file

@ -35,7 +35,7 @@ class ResolveShortUrlActionTest extends TestCase
$request = (new ServerRequest())->withAttribute('shortCode', $shortCode);
$response = $this->action->handle($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue(strpos($response->getBody()->getContents(), 'http://domain.com/foo/bar') > 0);
self::assertEquals(200, $response->getStatusCode());
self::assertTrue(strpos($response->getBody()->getContents(), 'http://domain.com/foo/bar') > 0);
}
}

View file

@ -80,7 +80,7 @@ class SingleStepCreateShortUrlActionTest extends TestCase
$resp = $this->action->handle($request);
$this->assertEquals(200, $resp->getStatusCode());
self::assertEquals(200, $resp->getStatusCode());
$findApiKey->shouldHaveBeenCalled();
$generateShortCode->shouldHaveBeenCalled();
}

View file

@ -33,7 +33,7 @@ class CreateTagsActionTest extends TestCase
$response = $this->action->handle($request);
$this->assertEquals(200, $response->getStatusCode());
self::assertEquals(200, $response->getStatusCode());
$deleteTags->shouldHaveBeenCalled();
}

View file

@ -32,7 +32,7 @@ class DeleteTagsActionTest extends TestCase
$response = $this->action->handle($request);
$this->assertEquals(204, $response->getStatusCode());
self::assertEquals(204, $response->getStatusCode());
$deleteTags->shouldHaveBeenCalled();
}

View file

@ -37,7 +37,7 @@ class ListTagsActionTest extends TestCase
$resp = $this->action->handle(ServerRequestFactory::fromGlobals()->withQueryParams($query));
$payload = $resp->getPayload();
$this->assertEquals([
self::assertEquals([
'tags' => [
'data' => $tags,
],
@ -65,7 +65,7 @@ class ListTagsActionTest extends TestCase
$resp = $this->action->handle(ServerRequestFactory::fromGlobals()->withQueryParams(['withStats' => 'true']));
$payload = $resp->getPayload();
$this->assertEquals([
self::assertEquals([
'tags' => [
'data' => ['foo', 'bar'],
'stats' => $stats,

View file

@ -54,7 +54,7 @@ class UpdateTagActionTest extends TestCase
$resp = $this->action->handle($request);
$this->assertEquals(204, $resp->getStatusCode());
self::assertEquals(204, $resp->getStatusCode());
$rename->shouldHaveBeenCalled();
}
}

View file

@ -33,7 +33,7 @@ class GlobalVisitsActionTest extends TestCase
$resp = $this->action->handle(ServerRequestFactory::fromGlobals());
$payload = $resp->getPayload();
$this->assertEquals($payload, ['visits' => $stats]);
self::assertEquals($payload, ['visits' => $stats]);
$getStats->shouldHaveBeenCalledOnce();
}
}

View file

@ -37,7 +37,7 @@ class ShortUrlVisitsActionTest extends TestCase
)->shouldBeCalledOnce();
$response = $this->action->handle((new ServerRequest())->withAttribute('shortCode', $shortCode));
$this->assertEquals(200, $response->getStatusCode());
self::assertEquals(200, $response->getStatusCode());
}
/** @test */
@ -60,6 +60,6 @@ class ShortUrlVisitsActionTest extends TestCase
'itemsPerPage' => '10',
]),
);
$this->assertEquals(200, $response->getStatusCode());
self::assertEquals(200, $response->getStatusCode());
}
}

View file

@ -35,7 +35,7 @@ class TagVisitsActionTest extends TestCase
$response = $this->action->handle((new ServerRequest())->withAttribute('tag', $tag));
$this->assertEquals(200, $response->getStatusCode());
self::assertEquals(200, $response->getStatusCode());
$getVisits->shouldHaveBeenCalledOnce();
}
}

View file

@ -29,7 +29,7 @@ class AuthenticationPluginManagerFactoryTest extends TestCase
'config' => $config,
]]));
$this->assertEquals($expectedPlugins, $this->getPlugins($instance));
self::assertEquals($expectedPlugins, $this->getPlugins($instance));
}
private function getPlugins(AuthenticationPluginManager $pluginManager): array

View file

@ -56,7 +56,7 @@ class ApiKeyHeaderPluginTest extends TestCase
$returnedResponse = $this->plugin->update($this->createRequest($apiKey), $response);
$this->assertSame($response, $returnedResponse);
self::assertSame($response, $returnedResponse);
}
private function createRequest(string $apiKey): ServerRequestInterface

View file

@ -21,8 +21,8 @@ class ConfigProviderTest extends TestCase
{
$config = ($this->configProvider)();
$this->assertArrayHasKey('routes', $config);
$this->assertArrayHasKey('dependencies', $config);
self::assertArrayHasKey('routes', $config);
self::assertArrayHasKey('dependencies', $config);
}
/**
@ -35,7 +35,7 @@ class ConfigProviderTest extends TestCase
$config = $configProvider();
$this->assertEquals($expected, $config['routes']);
self::assertEquals($expected, $config['routes']);
}
public function provideRoutesConfig(): iterable

View file

@ -25,12 +25,12 @@ class MissingAuthenticationExceptionTest extends TestCase
$e = MissingAuthenticationException::fromExpectedTypes($expectedTypes);
$this->assertEquals($expectedMessage, $e->getMessage());
$this->assertEquals($expectedMessage, $e->getDetail());
$this->assertEquals('Invalid authorization', $e->getTitle());
$this->assertEquals('INVALID_AUTHORIZATION', $e->getType());
$this->assertEquals(401, $e->getStatus());
$this->assertEquals(['expectedTypes' => $expectedTypes], $e->getAdditionalData());
self::assertEquals($expectedMessage, $e->getMessage());
self::assertEquals($expectedMessage, $e->getDetail());
self::assertEquals('Invalid authorization', $e->getTitle());
self::assertEquals('INVALID_AUTHORIZATION', $e->getType());
self::assertEquals(401, $e->getStatus());
self::assertEquals(['expectedTypes' => $expectedTypes], $e->getAdditionalData());
}
public function provideExpectedTypes(): iterable

View file

@ -14,6 +14,6 @@ class VerifyAuthenticationExceptionTest extends TestCase
{
$e = VerifyAuthenticationException::forInvalidApiKey();
$this->assertEquals('Provided API key does not exist or is invalid.', $e->getMessage());
self::assertEquals('Provided API key does not exist or is invalid.', $e->getMessage());
}
}

View file

@ -100,7 +100,7 @@ class AuthenticationMiddlewareTest extends TestCase
$handle = $handler->handle($request)->willReturn(new Response());
$response = $this->middleware->process($request, $handler->reveal());
$this->assertSame($response, $newResponse);
self::assertSame($response, $newResponse);
$verify->shouldHaveBeenCalledOnce();
$update->shouldHaveBeenCalledOnce();
$handle->shouldHaveBeenCalledOnce();

View file

@ -35,7 +35,7 @@ class BodyParserMiddlewareTest extends TestCase
$request->getMethod()->willReturn($method);
$request->getParsedBody()->willReturn([]);
$this->assertHandlingRequestJustFallsBackToNext($request);
self::assertHandlingRequestJustFallsBackToNext($request);
}
public function provideIgnoredRequestMethods(): iterable
@ -52,7 +52,7 @@ class BodyParserMiddlewareTest extends TestCase
$request->getMethod()->willReturn('POST');
$request->getParsedBody()->willReturn(['foo' => 'bar']);
$this->assertHandlingRequestJustFallsBackToNext($request);
self::assertHandlingRequestJustFallsBackToNext($request);
}
private function assertHandlingRequestJustFallsBackToNext(ProphecyInterface $requestMock): void

View file

@ -37,13 +37,13 @@ class CrossDomainMiddlewareTest extends TestCase
$response = $this->middleware->process(new ServerRequest(), $this->handler->reveal());
$headers = $response->getHeaders();
$this->assertSame($originalResponse, $response);
$this->assertEquals(404, $response->getStatusCode());
$this->assertArrayNotHasKey('Access-Control-Allow-Origin', $headers);
$this->assertArrayNotHasKey('Access-Control-Expose-Headers', $headers);
$this->assertArrayNotHasKey('Access-Control-Allow-Methods', $headers);
$this->assertArrayNotHasKey('Access-Control-Max-Age', $headers);
$this->assertArrayNotHasKey('Access-Control-Allow-Headers', $headers);
self::assertSame($originalResponse, $response);
self::assertEquals(404, $response->getStatusCode());
self::assertArrayNotHasKey('Access-Control-Allow-Origin', $headers);
self::assertArrayNotHasKey('Access-Control-Expose-Headers', $headers);
self::assertArrayNotHasKey('Access-Control-Allow-Methods', $headers);
self::assertArrayNotHasKey('Access-Control-Max-Age', $headers);
self::assertArrayNotHasKey('Access-Control-Allow-Headers', $headers);
}
/** @test */
@ -56,18 +56,18 @@ class CrossDomainMiddlewareTest extends TestCase
(new ServerRequest())->withHeader('Origin', 'local'),
$this->handler->reveal(),
);
$this->assertNotSame($originalResponse, $response);
self::assertNotSame($originalResponse, $response);
$headers = $response->getHeaders();
$this->assertEquals('local', $response->getHeaderLine('Access-Control-Allow-Origin'));
$this->assertEquals(
self::assertEquals('local', $response->getHeaderLine('Access-Control-Allow-Origin'));
self::assertEquals(
Authentication\Plugin\ApiKeyHeaderPlugin::HEADER_NAME,
$response->getHeaderLine('Access-Control-Expose-Headers'),
);
$this->assertArrayNotHasKey('Access-Control-Allow-Methods', $headers);
$this->assertArrayNotHasKey('Access-Control-Max-Age', $headers);
$this->assertArrayNotHasKey('Access-Control-Allow-Headers', $headers);
self::assertArrayNotHasKey('Access-Control-Allow-Methods', $headers);
self::assertArrayNotHasKey('Access-Control-Max-Age', $headers);
self::assertArrayNotHasKey('Access-Control-Allow-Headers', $headers);
}
/** @test */
@ -81,19 +81,19 @@ class CrossDomainMiddlewareTest extends TestCase
$this->handler->handle(Argument::any())->willReturn($originalResponse)->shouldBeCalledOnce();
$response = $this->middleware->process($request, $this->handler->reveal());
$this->assertNotSame($originalResponse, $response);
self::assertNotSame($originalResponse, $response);
$headers = $response->getHeaders();
$this->assertEquals('local', $response->getHeaderLine('Access-Control-Allow-Origin'));
$this->assertEquals(
self::assertEquals('local', $response->getHeaderLine('Access-Control-Allow-Origin'));
self::assertEquals(
Authentication\Plugin\ApiKeyHeaderPlugin::HEADER_NAME,
$response->getHeaderLine('Access-Control-Expose-Headers'),
);
$this->assertArrayHasKey('Access-Control-Allow-Methods', $headers);
$this->assertEquals('1000', $response->getHeaderLine('Access-Control-Max-Age'));
$this->assertEquals('foo, bar, baz', $response->getHeaderLine('Access-Control-Allow-Headers'));
$this->assertEquals(204, $response->getStatusCode());
self::assertArrayHasKey('Access-Control-Allow-Methods', $headers);
self::assertEquals('1000', $response->getHeaderLine('Access-Control-Max-Age'));
self::assertEquals('foo, bar, baz', $response->getHeaderLine('Access-Control-Allow-Headers'));
self::assertEquals(204, $response->getStatusCode());
}
/**
@ -112,8 +112,8 @@ class CrossDomainMiddlewareTest extends TestCase
$response = $this->middleware->process($request, $this->handler->reveal());
$this->assertEquals($response->getHeaderLine('Access-Control-Allow-Methods'), $expectedAllowedMethods);
$this->assertEquals(204, $response->getStatusCode());
self::assertEquals($response->getHeaderLine('Access-Control-Allow-Methods'), $expectedAllowedMethods);
self::assertEquals(204, $response->getStatusCode());
}
public function provideRouteResults(): iterable
@ -145,7 +145,7 @@ class CrossDomainMiddlewareTest extends TestCase
$response = $this->middleware->process($request, $this->handler->reveal());
$this->assertEquals($expectedStatus, $response->getStatusCode());
self::assertEquals($expectedStatus, $response->getStatusCode());
}
public function provideMethods(): iterable

View file

@ -23,7 +23,7 @@ class EmptyResponseImplicitOptionsMiddlewareFactoryTest extends TestCase
public function serviceIsCreated(): void
{
$instance = ($this->factory)();
$this->assertInstanceOf(ImplicitOptionsMiddleware::class, $instance);
self::assertInstanceOf(ImplicitOptionsMiddleware::class, $instance);
}
/** @test */
@ -34,6 +34,6 @@ class EmptyResponseImplicitOptionsMiddlewareFactoryTest extends TestCase
$ref = new ReflectionObject($instance);
$prop = $ref->getProperty('responseFactory');
$prop->setAccessible(true);
$this->assertInstanceOf(EmptyResponse::class, $prop->getValue($instance)());
self::assertInstanceOf(EmptyResponse::class, $prop->getValue($instance)());
}
}

View file

@ -33,7 +33,7 @@ class CreateShortUrlContentNegotiationMiddlewareTest extends TestCase
$resp = $this->middleware->process(new ServerRequest(), $this->requestHandler->reveal());
$this->assertSame($expectedResp, $resp);
self::assertSame($expectedResp, $resp);
}
/**
@ -54,7 +54,7 @@ class CreateShortUrlContentNegotiationMiddlewareTest extends TestCase
$response = $this->middleware->process($request, $this->requestHandler->reveal());
$this->assertEquals($expectedContentType, $response->getHeaderLine('Content-type'));
self::assertEquals($expectedContentType, $response->getHeaderLine('Content-type'));
$handle->shouldHaveBeenCalled();
}
@ -85,7 +85,7 @@ class CreateShortUrlContentNegotiationMiddlewareTest extends TestCase
$response = $this->middleware->process($request, $this->requestHandler->reveal());
$this->assertEquals($expectedBody, (string) $response->getBody());
self::assertEquals($expectedBody, (string) $response->getBody());
$handle->shouldHaveBeenCalled();
}

View file

@ -36,7 +36,7 @@ class ApiKeyServiceTest extends TestCase
$key = $this->service->create($date);
$this->assertEquals($date, $key->getExpirationDate());
self::assertEquals($date, $key->getExpirationDate());
}
public function provideCreationDate(): iterable
@ -56,7 +56,7 @@ class ApiKeyServiceTest extends TestCase
->shouldBeCalledOnce();
$this->em->getRepository(ApiKey::class)->willReturn($repo->reveal());
$this->assertFalse($this->service->check('12345'));
self::assertFalse($this->service->check('12345'));
}
public function provideInvalidApiKeys(): iterable
@ -74,7 +74,7 @@ class ApiKeyServiceTest extends TestCase
->shouldBeCalledOnce();
$this->em->getRepository(ApiKey::class)->willReturn($repo->reveal());
$this->assertTrue($this->service->check('12345'));
self::assertTrue($this->service->check('12345'));
}
/** @test */
@ -101,10 +101,10 @@ class ApiKeyServiceTest extends TestCase
$this->em->flush()->shouldBeCalledOnce();
$this->assertTrue($key->isEnabled());
self::assertTrue($key->isEnabled());
$returnedKey = $this->service->disable('12345');
$this->assertFalse($key->isEnabled());
$this->assertSame($key, $returnedKey);
self::assertFalse($key->isEnabled());
self::assertSame($key, $returnedKey);
}
/** @test */
@ -119,7 +119,7 @@ class ApiKeyServiceTest extends TestCase
$result = $this->service->listKeys();
$this->assertEquals($expectedApiKeys, $result);
self::assertEquals($expectedApiKeys, $result);
}
/** @test */
@ -134,6 +134,6 @@ class ApiKeyServiceTest extends TestCase
$result = $this->service->listKeys(true);
$this->assertEquals($expectedApiKeys, $result);
self::assertEquals($expectedApiKeys, $result);
}
}