Improved API tests by adding fixtures

This commit is contained in:
Alejandro Celaya
2019-01-27 12:14:18 +01:00
parent ce515767ce
commit 05c7672de3
9 changed files with 196 additions and 3 deletions

View File

@@ -38,13 +38,14 @@ class AuthenticationTest extends ApiTestCase
/**
* @test
* @dataProvider provideInvalidApiKeys
*/
public function apiKeyErrorIsReturnedWhenProvidedApiKeyIsInvalid()
public function apiKeyErrorIsReturnedWhenProvidedApiKeyIsInvalid(string $apiKey)
{
try {
$this->callApi(self::METHOD_GET, '/short-codes', [
'headers' => [
ApiKeyHeaderPlugin::HEADER_NAME => 'invalid',
ApiKeyHeaderPlugin::HEADER_NAME => $apiKey,
],
]);
} catch (ClientException $e) {
@@ -55,4 +56,13 @@ class AuthenticationTest extends ApiTestCase
$this->assertEquals('Provided API key does not exist or is invalid.', $message);
}
}
public function provideInvalidApiKeys(): array
{
return [
'key which does not exist' => ['invalid'],
'key which is expired' => ['expired_api_key'],
'key which is disabled' => ['disabled_api_key'],
];
}
}