Skip to content

Commit

Permalink
added tests for 100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Otero committed Jan 12, 2018
1 parent 7594e26 commit ef5ca69
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function testEndPointMiddleware()
new FakeEndPointMiddleware(),
]);

$this->assertResponse('', $dispatcher->dispatch(new ServerRequest()));
$this->assertResponse('', $dispatcher(new ServerRequest()));
}

public function testMiddleware()
Expand Down Expand Up @@ -148,6 +148,28 @@ public function testInvalidMiddlewareException()
$dispatcher->dispatch(new ServerRequest());
}

public function testInvalidStringMiddlewareException()
{
$this->expectException(InvalidArgumentException::class);

$dispatcher = new Dispatcher([
'invalid'
]);

$dispatcher->dispatch(new ServerRequest());
}

public function testInvalidMatcherException()
{
$this->expectException(InvalidArgumentException::class);

$dispatcher = new Dispatcher([
[new Datetime(), new FakeMiddleware()]
]);

$dispatcher->dispatch(new ServerRequest());
}

private function assertResponse(string $body, ResponseInterface $response)
{
$this->assertEquals($body, (string) $response->getBody());
Expand Down

0 comments on commit ef5ca69

Please sign in to comment.