vendredi 5 juin 2015

Symfony2 : PHPUnit How to use 'OR' condition in an assertion?

Using Symfony2 with PHPUnit, how can I use a OR condition in an assertion?

In my case a client request can return codes 200 OR 302, but the assertEquals expect only one possibility. Is there any way to throw an exception is the code is not 200 AND 302?

private function check($method, $url, $code)
{
    echo "Expected code [".$code."] => URL ".$url."\n";
    $this->client->request($method, $url);
    $this->assertEquals($code, $this->client->getResponse()->getStatusCode());        
}

Aucun commentaire:

Enregistrer un commentaire