Reduced amount of dead lines in tests

This commit is contained in:
Alejandro Celaya
2019-02-17 20:28:34 +01:00
parent 1bcd03b150
commit 687a1cc9c7
100 changed files with 481 additions and 938 deletions

View File

@@ -28,10 +28,8 @@ class RequestToAuthPluginTest extends TestCase
$this->requestToPlugin = new RequestToHttpAuthPlugin($this->pluginManager->reveal());
}
/**
* @test
*/
public function exceptionIsFoundWhenNoneOfTheSupportedMethodsIsFound()
/** @test */
public function exceptionIsFoundWhenNoneOfTheSupportedMethodsIsFound(): void
{
$request = new ServerRequest();
@@ -48,7 +46,7 @@ class RequestToAuthPluginTest extends TestCase
* @test
* @dataProvider provideHeaders
*/
public function properPluginIsFetchedWhenAnyAuthTypeIsFound(array $headers, string $expectedHeader)
public function properPluginIsFetchedWhenAnyAuthTypeIsFound(array $headers, string $expectedHeader): void
{
$request = new ServerRequest();
foreach ($headers as $header => $value) {
@@ -63,19 +61,17 @@ class RequestToAuthPluginTest extends TestCase
$getPlugin->shouldHaveBeenCalledOnce();
}
public function provideHeaders(): array
public function provideHeaders(): iterable
{
return [
'API key header only' => [[
ApiKeyHeaderPlugin::HEADER_NAME => 'foobar',
], ApiKeyHeaderPlugin::HEADER_NAME],
'Authorization header only' => [[
AuthorizationHeaderPlugin::HEADER_NAME => 'foobar',
], AuthorizationHeaderPlugin::HEADER_NAME],
'Both headers' => [[
AuthorizationHeaderPlugin::HEADER_NAME => 'foobar',
ApiKeyHeaderPlugin::HEADER_NAME => 'foobar',
], ApiKeyHeaderPlugin::HEADER_NAME],
];
yield 'API key header only' => [[
ApiKeyHeaderPlugin::HEADER_NAME => 'foobar',
], ApiKeyHeaderPlugin::HEADER_NAME];
yield 'Authorization header only' => [[
AuthorizationHeaderPlugin::HEADER_NAME => 'foobar',
], AuthorizationHeaderPlugin::HEADER_NAME];
yield 'Both headers' => [[
AuthorizationHeaderPlugin::HEADER_NAME => 'foobar',
ApiKeyHeaderPlugin::HEADER_NAME => 'foobar',
], ApiKeyHeaderPlugin::HEADER_NAME];
}
}