jeudi 1 janvier 2015

Why PHPUnit does not assert correctly a request with an unvalid method?

what I am trying to do is asserting a request with an unvalid method.


What I testing is a Guest attempting to logging out as GET (unvalid).


This is the code:



/**
* Enables router filters.
*
* @return void
*/
public function enableRouterFilters()
{
$this->app['router']->enableFilters();
}

[...]

/**
* Tests users/logout route as a Guest with GET.
*
* @return void
*/
public function testRouteToUsersLogoutAsGuestWithGetMethod()
{
$this->enableRouterFilters();

$response = $this->call('GET', '/users/logout');
$this->assertResponseStatus(405);
}

[...]


Instead of asserting true, PHPUnit complains about it:



[...]

There was 1 error:

1) RoutesTest::testRouteToUsersLogoutAsGuestWithGetMethod
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException:

[...]

FAILURES!
Tests: 7, Assertions: 11, Errors: 1.


Why it gives me an error if the assertion should be indeed true?


Aucun commentaire:

Enregistrer un commentaire