diff --git a/module/CLI/test/Command/Api/DisableKeyCommandTest.php b/module/CLI/test/Command/Api/DisableKeyCommandTest.php index 8b5ef6c4..2138fff6 100644 --- a/module/CLI/test/Command/Api/DisableKeyCommandTest.php +++ b/module/CLI/test/Command/Api/DisableKeyCommandTest.php @@ -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(); } } diff --git a/module/CLI/test/Command/Api/GenerateKeyCommandTest.php b/module/CLI/test/Command/Api/GenerateKeyCommandTest.php index 8ddd9f0b..bb467337 100644 --- a/module/CLI/test/Command/Api/GenerateKeyCommandTest.php +++ b/module/CLI/test/Command/Api/GenerateKeyCommandTest.php @@ -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(); } diff --git a/module/CLI/test/Command/Api/ListKeysCommandTest.php b/module/CLI/test/Command/Api/ListKeysCommandTest.php index 9e30605a..fc03a180 100644 --- a/module/CLI/test/Command/Api/ListKeysCommandTest.php +++ b/module/CLI/test/Command/Api/ListKeysCommandTest.php @@ -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); } } diff --git a/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php b/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php index d890f264..b34ebb56 100644 --- a/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php +++ b/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php @@ -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(); diff --git a/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php b/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php index 71587eea..985a7e74 100644 --- a/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php +++ b/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php @@ -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(); } } diff --git a/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php b/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php index 2c3526f5..b72a27a1 100644 --- a/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php +++ b/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php @@ -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(); } } diff --git a/module/CLI/test/Command/ShortUrl/GenerateShortUrlCommandTest.php b/module/CLI/test/Command/ShortUrl/GenerateShortUrlCommandTest.php index eee57b81..fd63fc2a 100644 --- a/module/CLI/test/Command/ShortUrl/GenerateShortUrlCommandTest.php +++ b/module/CLI/test/Command/ShortUrl/GenerateShortUrlCommandTest.php @@ -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(); } diff --git a/module/CLI/test/Command/ShortUrl/GetVisitsCommandTest.php b/module/CLI/test/Command/ShortUrl/GetVisitsCommandTest.php index a725240e..d57deb2e 100644 --- a/module/CLI/test/Command/ShortUrl/GetVisitsCommandTest.php +++ b/module/CLI/test/Command/ShortUrl/GetVisitsCommandTest.php @@ -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); } } diff --git a/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php b/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php index d8bc0f60..4fbeec40 100644 --- a/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php +++ b/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php @@ -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); } /** diff --git a/module/CLI/test/Command/ShortUrl/ResolveUrlCommandTest.php b/module/CLI/test/Command/ShortUrl/ResolveUrlCommandTest.php index 7c307252..8beeecd1 100644 --- a/module/CLI/test/Command/ShortUrl/ResolveUrlCommandTest.php +++ b/module/CLI/test/Command/ShortUrl/ResolveUrlCommandTest.php @@ -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); } } diff --git a/module/CLI/test/Command/Tag/CreateTagCommandTest.php b/module/CLI/test/Command/Tag/CreateTagCommandTest.php index e156cf28..c0a25371 100644 --- a/module/CLI/test/Command/Tag/CreateTagCommandTest.php +++ b/module/CLI/test/Command/Tag/CreateTagCommandTest.php @@ -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(); } } diff --git a/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php b/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php index 27a95de8..d76f1c7d 100644 --- a/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php +++ b/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php @@ -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(); } } diff --git a/module/CLI/test/Command/Tag/ListTagsCommandTest.php b/module/CLI/test/Command/Tag/ListTagsCommandTest.php index b6087307..d9b28fb0 100644 --- a/module/CLI/test/Command/Tag/ListTagsCommandTest.php +++ b/module/CLI/test/Command/Tag/ListTagsCommandTest.php @@ -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(); } } diff --git a/module/CLI/test/Command/Tag/RenameTagCommandTest.php b/module/CLI/test/Command/Tag/RenameTagCommandTest.php index ee499c48..b9685668 100644 --- a/module/CLI/test/Command/Tag/RenameTagCommandTest.php +++ b/module/CLI/test/Command/Tag/RenameTagCommandTest.php @@ -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(); } } diff --git a/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php b/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php index 803ae472..3eb89f57 100644 --- a/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php +++ b/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php @@ -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); } /** diff --git a/module/CLI/test/ConfigProviderTest.php b/module/CLI/test/ConfigProviderTest.php index baa4f311..42a8f504 100644 --- a/module/CLI/test/ConfigProviderTest.php +++ b/module/CLI/test/ConfigProviderTest.php @@ -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); } } diff --git a/module/CLI/test/Exception/GeolocationDbUpdateFailedExceptionTest.php b/module/CLI/test/Exception/GeolocationDbUpdateFailedExceptionTest.php index 21a1e006..33d7d76e 100644 --- a/module/CLI/test/Exception/GeolocationDbUpdateFailedExceptionTest.php +++ b/module/CLI/test/Exception/GeolocationDbUpdateFailedExceptionTest.php @@ -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 diff --git a/module/CLI/test/Factory/ApplicationFactoryTest.php b/module/CLI/test/Factory/ApplicationFactoryTest.php index 043349ab..b05e291e 100644 --- a/module/CLI/test/Factory/ApplicationFactoryTest.php +++ b/module/CLI/test/Factory/ApplicationFactoryTest.php @@ -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 diff --git a/module/CLI/test/Util/GeolocationDbUpdaterTest.php b/module/CLI/test/Util/GeolocationDbUpdaterTest.php index b5346629..91bf5627 100644 --- a/module/CLI/test/Util/GeolocationDbUpdaterTest.php +++ b/module/CLI/test/Util/GeolocationDbUpdaterTest.php @@ -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(); diff --git a/module/CLI/test/Util/ShlinkTableTest.php b/module/CLI/test/Util/ShlinkTableTest.php index 23c4eb32..4d270854 100644 --- a/module/CLI/test/Util/ShlinkTableTest.php +++ b/module/CLI/test/Util/ShlinkTableTest.php @@ -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)); } } diff --git a/module/Core/test-db/Repository/ShortUrlRepositoryTest.php b/module/Core/test-db/Repository/ShortUrlRepositoryTest.php index 57a174c7..ad99a9a3 100644 --- a/module/Core/test-db/Repository/ShortUrlRepositoryTest.php +++ b/module/Core/test-db/Repository/ShortUrlRepositoryTest.php @@ -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)), ); diff --git a/module/Core/test-db/Repository/TagRepositoryTest.php b/module/Core/test-db/Repository/TagRepositoryTest.php index 8e1a11ef..9f8b9893 100644 --- a/module/Core/test-db/Repository/TagRepositoryTest.php +++ b/module/Core/test-db/Repository/TagRepositoryTest.php @@ -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(), ); diff --git a/module/Core/test-db/Repository/VisitRepositoryTest.php b/module/Core/test-db/Repository/VisitRepositoryTest.php index 529a5ae0..f6df4b9b 100644 --- a/module/Core/test-db/Repository/VisitRepositoryTest.php +++ b/module/Core/test-db/Repository/VisitRepositoryTest.php @@ -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'), ))); } diff --git a/module/Core/test/Action/PixelActionTest.php b/module/Core/test/Action/PixelActionTest.php index f4aed872..c678fa3a 100644 --- a/module/Core/test/Action/PixelActionTest.php +++ b/module/Core/test/Action/PixelActionTest.php @@ -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')); } } diff --git a/module/Core/test/Action/QrCodeActionTest.php b/module/Core/test/Action/QrCodeActionTest.php index 236288dd..06e602e2 100644 --- a/module/Core/test/Action/QrCodeActionTest.php +++ b/module/Core/test/Action/QrCodeActionTest.php @@ -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 diff --git a/module/Core/test/Action/RedirectActionTest.php b/module/Core/test/Action/RedirectActionTest.php index 1a6bb617..495162bb 100644 --- a/module/Core/test/Action/RedirectActionTest.php +++ b/module/Core/test/Action/RedirectActionTest.php @@ -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 diff --git a/module/Core/test/Config/BasePathPrefixerTest.php b/module/Core/test/Config/BasePathPrefixerTest.php index 0e08fa89..e0949514 100644 --- a/module/Core/test/Config/BasePathPrefixerTest.php +++ b/module/Core/test/Config/BasePathPrefixerTest.php @@ -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, ], diff --git a/module/Core/test/Config/DeprecatedConfigParserTest.php b/module/Core/test/Config/DeprecatedConfigParserTest.php index 0da1d314..c58d9050 100644 --- a/module/Core/test/Config/DeprecatedConfigParserTest.php +++ b/module/Core/test/Config/DeprecatedConfigParserTest.php @@ -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); } } diff --git a/module/Core/test/Config/SimplifiedConfigParserTest.php b/module/Core/test/Config/SimplifiedConfigParserTest.php index dc85196a..6f040bb6 100644 --- a/module/Core/test/Config/SimplifiedConfigParserTest.php +++ b/module/Core/test/Config/SimplifiedConfigParserTest.php @@ -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); } } diff --git a/module/Core/test/ConfigProviderTest.php b/module/Core/test/ConfigProviderTest.php index 71cd90d1..2660803b 100644 --- a/module/Core/test/ConfigProviderTest.php +++ b/module/Core/test/ConfigProviderTest.php @@ -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); } } diff --git a/module/Core/test/Domain/Resolver/PersistenceDomainResolverTest.php b/module/Core/test/Domain/Resolver/PersistenceDomainResolverTest.php index d3769af9..c9f71851 100644 --- a/module/Core/test/Domain/Resolver/PersistenceDomainResolverTest.php +++ b/module/Core/test/Domain/Resolver/PersistenceDomainResolverTest.php @@ -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(); } diff --git a/module/Core/test/Domain/Resolver/SimpleDomainResolverTest.php b/module/Core/test/Domain/Resolver/SimpleDomainResolverTest.php index a0fa4bf1..ff5b6b90 100644 --- a/module/Core/test/Domain/Resolver/SimpleDomainResolverTest.php +++ b/module/Core/test/Domain/Resolver/SimpleDomainResolverTest.php @@ -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()); } } diff --git a/module/Core/test/Entity/ShortUrlTest.php b/module/Core/test/Entity/ShortUrlTest.php index e410dedb..054182ff 100644 --- a/module/Core/test/Entity/ShortUrlTest.php +++ b/module/Core/test/Entity/ShortUrlTest.php @@ -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 diff --git a/module/Core/test/Entity/TagTest.php b/module/Core/test/Entity/TagTest.php index 01b2f6ea..dcc21e71 100644 --- a/module/Core/test/Entity/TagTest.php +++ b/module/Core/test/Entity/TagTest.php @@ -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()); } } diff --git a/module/Core/test/Entity/VisitLocationTest.php b/module/Core/test/Entity/VisitLocationTest.php index f662645d..057a1920 100644 --- a/module/Core/test/Entity/VisitLocationTest.php +++ b/module/Core/test/Entity/VisitLocationTest.php @@ -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 diff --git a/module/Core/test/Entity/VisitTest.php b/module/Core/test/Entity/VisitTest.php index 73e41f12..9d75f793 100644 --- a/module/Core/test/Entity/VisitTest.php +++ b/module/Core/test/Entity/VisitTest.php @@ -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 diff --git a/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php b/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php index 61288e02..2dc5f16d 100644 --- a/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php +++ b/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php @@ -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(); } } diff --git a/module/Core/test/ErrorHandler/NotFoundTemplateHandlerTest.php b/module/Core/test/ErrorHandler/NotFoundTemplateHandlerTest.php index e43b3aab..a967c3f7 100644 --- a/module/Core/test/ErrorHandler/NotFoundTemplateHandlerTest.php +++ b/module/Core/test/ErrorHandler/NotFoundTemplateHandlerTest.php @@ -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(); } diff --git a/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerDelegatorTest.php b/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerDelegatorTest.php index 60113fc7..bb396983 100644 --- a/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerDelegatorTest.php +++ b/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerDelegatorTest.php @@ -37,7 +37,7 @@ class CloseDbConnectionEventListenerDelegatorTest extends TestCase ($this->delegator)($this->container->reveal(), '', $callback); - $this->assertTrue($callbackInvoked); + self::assertTrue($callbackInvoked); $getEm->shouldHaveBeenCalledOnce(); } } diff --git a/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerTest.php b/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerTest.php index acc1784f..b75ec8dc 100644 --- a/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerTest.php +++ b/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerTest.php @@ -45,7 +45,7 @@ class CloseDbConnectionEventListenerTest extends TestCase // Ignore exceptions } - $this->assertTrue($wrappedWasCalled); + self::assertTrue($wrappedWasCalled); $close->shouldHaveBeenCalledOnce(); $getConn->shouldHaveBeenCalledOnce(); $clear->shouldHaveBeenCalledOnce(); diff --git a/module/Core/test/EventDispatcher/LocateShortUrlVisitTest.php b/module/Core/test/EventDispatcher/LocateShortUrlVisitTest.php index 087c0e0b..fc87e98c 100644 --- a/module/Core/test/EventDispatcher/LocateShortUrlVisitTest.php +++ b/module/Core/test/EventDispatcher/LocateShortUrlVisitTest.php @@ -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(); diff --git a/module/Core/test/Exception/DeleteShortUrlExceptionTest.php b/module/Core/test/Exception/DeleteShortUrlExceptionTest.php index 6e45521f..a7028a02 100644 --- a/module/Core/test/Exception/DeleteShortUrlExceptionTest.php +++ b/module/Core/test/Exception/DeleteShortUrlExceptionTest.php @@ -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 diff --git a/module/Core/test/Exception/InvalidUrlExceptionTest.php b/module/Core/test/Exception/InvalidUrlExceptionTest.php index cb0a08bc..5351c1b3 100644 --- a/module/Core/test/Exception/InvalidUrlExceptionTest.php +++ b/module/Core/test/Exception/InvalidUrlExceptionTest.php @@ -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 diff --git a/module/Core/test/Exception/IpCannotBeLocatedExceptionTest.php b/module/Core/test/Exception/IpCannotBeLocatedExceptionTest.php index 84ee433c..b1487b69 100644 --- a/module/Core/test/Exception/IpCannotBeLocatedExceptionTest.php +++ b/module/Core/test/Exception/IpCannotBeLocatedExceptionTest.php @@ -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 diff --git a/module/Core/test/Exception/NonUniqueSlugExceptionTest.php b/module/Core/test/Exception/NonUniqueSlugExceptionTest.php index 00efa3cf..6720f0f3 100644 --- a/module/Core/test/Exception/NonUniqueSlugExceptionTest.php +++ b/module/Core/test/Exception/NonUniqueSlugExceptionTest.php @@ -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 diff --git a/module/Core/test/Exception/ShortUrlNotFoundExceptionTest.php b/module/Core/test/Exception/ShortUrlNotFoundExceptionTest.php index d0d77fb8..e6a48914 100644 --- a/module/Core/test/Exception/ShortUrlNotFoundExceptionTest.php +++ b/module/Core/test/Exception/ShortUrlNotFoundExceptionTest.php @@ -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 diff --git a/module/Core/test/Exception/TagConflictExceptionTest.php b/module/Core/test/Exception/TagConflictExceptionTest.php index f09e3a32..156fd500 100644 --- a/module/Core/test/Exception/TagConflictExceptionTest.php +++ b/module/Core/test/Exception/TagConflictExceptionTest.php @@ -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()); } } diff --git a/module/Core/test/Exception/TagNotFoundExceptionTest.php b/module/Core/test/Exception/TagNotFoundExceptionTest.php index ccee7b38..c6e8bf1d 100644 --- a/module/Core/test/Exception/TagNotFoundExceptionTest.php +++ b/module/Core/test/Exception/TagNotFoundExceptionTest.php @@ -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()); } } diff --git a/module/Core/test/Exception/ValidationExceptionTest.php b/module/Core/test/Exception/ValidationExceptionTest.php index 780b25e3..db689a11 100644 --- a/module/Core/test/Exception/ValidationExceptionTest.php +++ b/module/Core/test/Exception/ValidationExceptionTest.php @@ -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(); } diff --git a/module/Core/test/Mercure/MercureUpdatesGeneratorTest.php b/module/Core/test/Mercure/MercureUpdatesGeneratorTest.php index 992e25d6..aef2a489 100644 --- a/module/Core/test/Mercure/MercureUpdatesGeneratorTest.php +++ b/module/Core/test/Mercure/MercureUpdatesGeneratorTest.php @@ -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(), diff --git a/module/Core/test/Model/ShortUrlMetaTest.php b/module/Core/test/Model/ShortUrlMetaTest.php index fe3d42fc..c8cc3ff6 100644 --- a/module/Core/test/Model/ShortUrlMetaTest.php +++ b/module/Core/test/Model/ShortUrlMetaTest.php @@ -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 diff --git a/module/Core/test/Model/VisitorTest.php b/module/Core/test/Model/VisitorTest.php index 0a0c1828..d52a6389 100644 --- a/module/Core/test/Model/VisitorTest.php +++ b/module/Core/test/Model/VisitorTest.php @@ -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 diff --git a/module/Core/test/Service/ShortUrl/ShortUrlResolverTest.php b/module/Core/test/Service/ShortUrl/ShortUrlResolverTest.php index 5b3e3e19..ed6569f2 100644 --- a/module/Core/test/Service/ShortUrl/ShortUrlResolverTest.php +++ b/module/Core/test/Service/ShortUrl/ShortUrlResolverTest.php @@ -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(); } diff --git a/module/Core/test/Service/ShortUrlServiceTest.php b/module/Core/test/Service/ShortUrlServiceTest.php index fcb63ec2..0b6c82b0 100644 --- a/module/Core/test/Service/ShortUrlServiceTest.php +++ b/module/Core/test/Service/ShortUrlServiceTest.php @@ -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( diff --git a/module/Core/test/Service/Tag/TagServiceTest.php b/module/Core/test/Service/Tag/TagServiceTest.php index c031e51f..4f17da32 100644 --- a/module/Core/test/Service/Tag/TagServiceTest.php +++ b/module/Core/test/Service/Tag/TagServiceTest.php @@ -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); diff --git a/module/Core/test/Service/UrlShortenerTest.php b/module/Core/test/Service/UrlShortenerTest.php index adeda920..ba7185bf 100644 --- a/module/Core/test/Service/UrlShortenerTest.php +++ b/module/Core/test/Service/UrlShortenerTest.php @@ -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 diff --git a/module/Core/test/Service/VisitsTrackerTest.php b/module/Core/test/Service/VisitsTrackerTest.php index 5893b952..b1609282 100644 --- a/module/Core/test/Service/VisitsTrackerTest.php +++ b/module/Core/test/Service/VisitsTrackerTest.php @@ -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(); } diff --git a/module/Core/test/Transformer/ShortUrlDataTransformerTest.php b/module/Core/test/Transformer/ShortUrlDataTransformerTest.php index a65b9506..9abe5f1a 100644 --- a/module/Core/test/Transformer/ShortUrlDataTransformerTest.php +++ b/module/Core/test/Transformer/ShortUrlDataTransformerTest.php @@ -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 diff --git a/module/Core/test/Visit/VisitsStatsHelperTest.php b/module/Core/test/Visit/VisitsStatsHelperTest.php index a4b692d5..01569f04 100644 --- a/module/Core/test/Visit/VisitsStatsHelperTest.php +++ b/module/Core/test/Visit/VisitsStatsHelperTest.php @@ -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(); } diff --git a/module/Rest/test-api/Action/CreateShortUrlActionTest.php b/module/Rest/test-api/Action/CreateShortUrlActionTest.php index 79b7ba1e..c9bf6fe5 100644 --- a/module/Rest/test-api/Action/CreateShortUrlActionTest.php +++ b/module/Rest/test-api/Action/CreateShortUrlActionTest.php @@ -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']); } /** diff --git a/module/Rest/test-api/Action/DeleteShortUrlActionTest.php b/module/Rest/test-api/Action/DeleteShortUrlActionTest.php index ef32190b..7c66ff0b 100644 --- a/module/Rest/test-api/Action/DeleteShortUrlActionTest.php +++ b/module/Rest/test-api/Action/DeleteShortUrlActionTest.php @@ -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()); } } diff --git a/module/Rest/test-api/Action/EditShortUrlActionTest.php b/module/Rest/test-api/Action/EditShortUrlActionTest.php index b5cd4fd4..e6b37eba 100644 --- a/module/Rest/test-api/Action/EditShortUrlActionTest.php +++ b/module/Rest/test-api/Action/EditShortUrlActionTest.php @@ -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 diff --git a/module/Rest/test-api/Action/EditShortUrlTagsActionTest.php b/module/Rest/test-api/Action/EditShortUrlTagsActionTest.php index 0433a388..84d2af80 100644 --- a/module/Rest/test-api/Action/EditShortUrlTagsActionTest.php +++ b/module/Rest/test-api/Action/EditShortUrlTagsActionTest.php @@ -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']); } } diff --git a/module/Rest/test-api/Action/GlobalVisitsActionTest.php b/module/Rest/test-api/Action/GlobalVisitsActionTest.php index 8e4f5e11..b6767c0f 100644 --- a/module/Rest/test-api/Action/GlobalVisitsActionTest.php +++ b/module/Rest/test-api/Action/GlobalVisitsActionTest.php @@ -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']); } } diff --git a/module/Rest/test-api/Action/ListShortUrlsTest.php b/module/Rest/test-api/Action/ListShortUrlsTest.php index d59c488d..2f1cf484 100644 --- a/module/Rest/test-api/Action/ListShortUrlsTest.php +++ b/module/Rest/test-api/Action/ListShortUrlsTest.php @@ -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)), diff --git a/module/Rest/test-api/Action/ListTagsActionTest.php b/module/Rest/test-api/Action/ListTagsActionTest.php index 0690d4f2..9191b4e0 100644 --- a/module/Rest/test-api/Action/ListTagsActionTest.php +++ b/module/Rest/test-api/Action/ListTagsActionTest.php @@ -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 diff --git a/module/Rest/test-api/Action/ResolveShortUrlActionTest.php b/module/Rest/test-api/Action/ResolveShortUrlActionTest.php index d76d7946..cf1a7212 100644 --- a/module/Rest/test-api/Action/ResolveShortUrlActionTest.php +++ b/module/Rest/test-api/Action/ResolveShortUrlActionTest.php @@ -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); } } diff --git a/module/Rest/test-api/Action/ShortUrlVisitsActionTest.php b/module/Rest/test-api/Action/ShortUrlVisitsActionTest.php index ea39a267..6e2463a2 100644 --- a/module/Rest/test-api/Action/ShortUrlVisitsActionTest.php +++ b/module/Rest/test-api/Action/ShortUrlVisitsActionTest.php @@ -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 diff --git a/module/Rest/test-api/Action/TagVisitsActionTest.php b/module/Rest/test-api/Action/TagVisitsActionTest.php index 94e592f6..d0f9838b 100644 --- a/module/Rest/test-api/Action/TagVisitsActionTest.php +++ b/module/Rest/test-api/Action/TagVisitsActionTest.php @@ -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']); } } diff --git a/module/Rest/test-api/Action/UpdateTagActionTest.php b/module/Rest/test-api/Action/UpdateTagActionTest.php index eb70685a..de0b1594 100644 --- a/module/Rest/test-api/Action/UpdateTagActionTest.php +++ b/module/Rest/test-api/Action/UpdateTagActionTest.php @@ -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()); } } diff --git a/module/Rest/test-api/Middleware/AuthenticationTest.php b/module/Rest/test-api/Middleware/AuthenticationTest.php index aa90451f..f71ddfd1 100644 --- a/module/Rest/test-api/Middleware/AuthenticationTest.php +++ b/module/Rest/test-api/Middleware/AuthenticationTest.php @@ -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 diff --git a/module/Rest/test-api/Middleware/ImplicitOptionsTest.php b/module/Rest/test-api/Middleware/ImplicitOptionsTest.php index ddfaa62d..f9f140c2 100644 --- a/module/Rest/test-api/Middleware/ImplicitOptionsTest.php +++ b/module/Rest/test-api/Middleware/ImplicitOptionsTest.php @@ -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)); diff --git a/module/Rest/test/Action/HealthActionTest.php b/module/Rest/test/Action/HealthActionTest.php index 2ec68d25..57c0dd58 100644 --- a/module/Rest/test/Action/HealthActionTest.php +++ b/module/Rest/test/Action/HealthActionTest.php @@ -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(); } } diff --git a/module/Rest/test/Action/MercureInfoActionTest.php b/module/Rest/test/Action/MercureInfoActionTest.php index d40b3f70..aaf9e089 100644 --- a/module/Rest/test/Action/MercureInfoActionTest.php +++ b/module/Rest/test/Action/MercureInfoActionTest.php @@ -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(), ); diff --git a/module/Rest/test/Action/ShortUrl/CreateShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/CreateShortUrlActionTest.php index 66f1eaaa..78b28385 100644 --- a/module/Rest/test/Action/ShortUrl/CreateShortUrlActionTest.php +++ b/module/Rest/test/Action/ShortUrl/CreateShortUrlActionTest.php @@ -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(); } diff --git a/module/Rest/test/Action/ShortUrl/DeleteShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/DeleteShortUrlActionTest.php index cbd8e2bc..5c448561 100644 --- a/module/Rest/test/Action/ShortUrl/DeleteShortUrlActionTest.php +++ b/module/Rest/test/Action/ShortUrl/DeleteShortUrlActionTest.php @@ -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(); } } diff --git a/module/Rest/test/Action/ShortUrl/EditShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/EditShortUrlActionTest.php index d6247d9f..57d63cde 100644 --- a/module/Rest/test/Action/ShortUrl/EditShortUrlActionTest.php +++ b/module/Rest/test/Action/ShortUrl/EditShortUrlActionTest.php @@ -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(); } } diff --git a/module/Rest/test/Action/ShortUrl/EditShortUrlTagsActionTest.php b/module/Rest/test/Action/ShortUrl/EditShortUrlTagsActionTest.php index d7a86844..527ffb71 100644 --- a/module/Rest/test/Action/ShortUrl/EditShortUrlTagsActionTest.php +++ b/module/Rest/test/Action/ShortUrl/EditShortUrlTagsActionTest.php @@ -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()); } } diff --git a/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php b/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php index 3d98c2fe..423cd497 100644 --- a/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php +++ b/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php @@ -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(); } diff --git a/module/Rest/test/Action/ShortUrl/ResolveShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/ResolveShortUrlActionTest.php index a62b1f95..5e6316a0 100644 --- a/module/Rest/test/Action/ShortUrl/ResolveShortUrlActionTest.php +++ b/module/Rest/test/Action/ShortUrl/ResolveShortUrlActionTest.php @@ -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); } } diff --git a/module/Rest/test/Action/ShortUrl/SingleStepCreateShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/SingleStepCreateShortUrlActionTest.php index d63a83b9..cb931570 100644 --- a/module/Rest/test/Action/ShortUrl/SingleStepCreateShortUrlActionTest.php +++ b/module/Rest/test/Action/ShortUrl/SingleStepCreateShortUrlActionTest.php @@ -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(); } diff --git a/module/Rest/test/Action/Tag/CreateTagsActionTest.php b/module/Rest/test/Action/Tag/CreateTagsActionTest.php index 33aa0ba7..ac74740e 100644 --- a/module/Rest/test/Action/Tag/CreateTagsActionTest.php +++ b/module/Rest/test/Action/Tag/CreateTagsActionTest.php @@ -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(); } diff --git a/module/Rest/test/Action/Tag/DeleteTagsActionTest.php b/module/Rest/test/Action/Tag/DeleteTagsActionTest.php index 819a608a..de145bf0 100644 --- a/module/Rest/test/Action/Tag/DeleteTagsActionTest.php +++ b/module/Rest/test/Action/Tag/DeleteTagsActionTest.php @@ -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(); } diff --git a/module/Rest/test/Action/Tag/ListTagsActionTest.php b/module/Rest/test/Action/Tag/ListTagsActionTest.php index 461ddd3f..f881c75d 100644 --- a/module/Rest/test/Action/Tag/ListTagsActionTest.php +++ b/module/Rest/test/Action/Tag/ListTagsActionTest.php @@ -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, diff --git a/module/Rest/test/Action/Tag/UpdateTagActionTest.php b/module/Rest/test/Action/Tag/UpdateTagActionTest.php index 11b2c1c4..2caf20c3 100644 --- a/module/Rest/test/Action/Tag/UpdateTagActionTest.php +++ b/module/Rest/test/Action/Tag/UpdateTagActionTest.php @@ -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(); } } diff --git a/module/Rest/test/Action/Visit/GlobalVisitsActionTest.php b/module/Rest/test/Action/Visit/GlobalVisitsActionTest.php index 7e1dec06..5c28451e 100644 --- a/module/Rest/test/Action/Visit/GlobalVisitsActionTest.php +++ b/module/Rest/test/Action/Visit/GlobalVisitsActionTest.php @@ -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(); } } diff --git a/module/Rest/test/Action/Visit/ShortUrlVisitsActionTest.php b/module/Rest/test/Action/Visit/ShortUrlVisitsActionTest.php index 07508acf..c05cc84d 100644 --- a/module/Rest/test/Action/Visit/ShortUrlVisitsActionTest.php +++ b/module/Rest/test/Action/Visit/ShortUrlVisitsActionTest.php @@ -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()); } } diff --git a/module/Rest/test/Action/Visit/TagVisitsActionTest.php b/module/Rest/test/Action/Visit/TagVisitsActionTest.php index 863bc725..7906f530 100644 --- a/module/Rest/test/Action/Visit/TagVisitsActionTest.php +++ b/module/Rest/test/Action/Visit/TagVisitsActionTest.php @@ -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(); } } diff --git a/module/Rest/test/Authentication/AuthenticationPluginManagerFactoryTest.php b/module/Rest/test/Authentication/AuthenticationPluginManagerFactoryTest.php index 326054d7..03ffc8dd 100644 --- a/module/Rest/test/Authentication/AuthenticationPluginManagerFactoryTest.php +++ b/module/Rest/test/Authentication/AuthenticationPluginManagerFactoryTest.php @@ -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 diff --git a/module/Rest/test/Authentication/Plugin/ApiKeyHeaderPluginTest.php b/module/Rest/test/Authentication/Plugin/ApiKeyHeaderPluginTest.php index e6a9c23d..146957e4 100644 --- a/module/Rest/test/Authentication/Plugin/ApiKeyHeaderPluginTest.php +++ b/module/Rest/test/Authentication/Plugin/ApiKeyHeaderPluginTest.php @@ -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 diff --git a/module/Rest/test/ConfigProviderTest.php b/module/Rest/test/ConfigProviderTest.php index 8032a854..69f745ff 100644 --- a/module/Rest/test/ConfigProviderTest.php +++ b/module/Rest/test/ConfigProviderTest.php @@ -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 diff --git a/module/Rest/test/Exception/MissingAuthenticationExceptionTest.php b/module/Rest/test/Exception/MissingAuthenticationExceptionTest.php index eee6058e..afe2a54e 100644 --- a/module/Rest/test/Exception/MissingAuthenticationExceptionTest.php +++ b/module/Rest/test/Exception/MissingAuthenticationExceptionTest.php @@ -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 diff --git a/module/Rest/test/Exception/VerifyAuthenticationExceptionTest.php b/module/Rest/test/Exception/VerifyAuthenticationExceptionTest.php index 28563c5f..3221041d 100644 --- a/module/Rest/test/Exception/VerifyAuthenticationExceptionTest.php +++ b/module/Rest/test/Exception/VerifyAuthenticationExceptionTest.php @@ -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()); } } diff --git a/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php b/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php index cd002f60..e1b8deca 100644 --- a/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php +++ b/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php @@ -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(); diff --git a/module/Rest/test/Middleware/BodyParserMiddlewareTest.php b/module/Rest/test/Middleware/BodyParserMiddlewareTest.php index 5adae27d..8c047bb1 100644 --- a/module/Rest/test/Middleware/BodyParserMiddlewareTest.php +++ b/module/Rest/test/Middleware/BodyParserMiddlewareTest.php @@ -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 diff --git a/module/Rest/test/Middleware/CrossDomainMiddlewareTest.php b/module/Rest/test/Middleware/CrossDomainMiddlewareTest.php index 5cc99fb3..5e9398ea 100644 --- a/module/Rest/test/Middleware/CrossDomainMiddlewareTest.php +++ b/module/Rest/test/Middleware/CrossDomainMiddlewareTest.php @@ -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 diff --git a/module/Rest/test/Middleware/EmptyResponseImplicitOptionsMiddlewareFactoryTest.php b/module/Rest/test/Middleware/EmptyResponseImplicitOptionsMiddlewareFactoryTest.php index 73fdd07e..9d216913 100644 --- a/module/Rest/test/Middleware/EmptyResponseImplicitOptionsMiddlewareFactoryTest.php +++ b/module/Rest/test/Middleware/EmptyResponseImplicitOptionsMiddlewareFactoryTest.php @@ -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)()); } } diff --git a/module/Rest/test/Middleware/ShortUrl/CreateShortUrlContentNegotiationMiddlewareTest.php b/module/Rest/test/Middleware/ShortUrl/CreateShortUrlContentNegotiationMiddlewareTest.php index f70a4d4a..3950282c 100644 --- a/module/Rest/test/Middleware/ShortUrl/CreateShortUrlContentNegotiationMiddlewareTest.php +++ b/module/Rest/test/Middleware/ShortUrl/CreateShortUrlContentNegotiationMiddlewareTest.php @@ -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(); } diff --git a/module/Rest/test/Service/ApiKeyServiceTest.php b/module/Rest/test/Service/ApiKeyServiceTest.php index c371beab..d4d40e4b 100644 --- a/module/Rest/test/Service/ApiKeyServiceTest.php +++ b/module/Rest/test/Service/ApiKeyServiceTest.php @@ -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); } }