Skip to content

Commit

Permalink
fixup! Exceptions plugin to throw exceptions based on Matej API respo…
Browse files Browse the repository at this point in the history
…nse code
  • Loading branch information
OndraM committed Nov 12, 2017
1 parent 354b592 commit b0fb665
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/Http/Plugin/ExceptionPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ public function init(): void
};
}

/** @test */
public function shouldReturnResponseWhenNoError(): void
/**
* @test
* @dataProvider provideSuccessStatusCodes
*/
public function shouldReturnResponseWhenNoError(int $statusCode): void
{
$request = new Request('GET', 'http://foo.com/endpoint');
$response = new Response(StatusCodeInterface::STATUS_OK);
$response = new Response($statusCode);

$next = function (RequestInterface $receivedRequest) use ($request, $response) {
$this->assertSame($request, $receivedRequest);
Expand All @@ -41,6 +44,17 @@ public function shouldReturnResponseWhenNoError(): void
$this->assertInstanceOf(HttpFulfilledPromise::class, $promise);
}

/**
* @return array[]
*/
public function provideSuccessStatusCodes(): array
{
return [
'HTTP 200' => [StatusCodeInterface::STATUS_OK, RequestException::class],
'HTTP 201' => [StatusCodeInterface::STATUS_CREATED, AuthorizationException::class],
];
}

/**
* @test
* @dataProvider provideErrorStatusCodes
Expand Down

0 comments on commit b0fb665

Please sign in to comment.