I'm setting up phpunit for testing, and started with the Controller routes. The GET routes are working fine, however, the DELETE routes are not. NOTE: I'm not testing adding/removing database entities yet, just validating routes.
* @Route("/{deviceprofile_id}/delete",
* name="delete",
* methods={"DELETE"})
The test class:
class DeviceProfileControllerTest extends WebTestCase
{
public function testRouteDelete()
{
$client = static::createClient();
$client->followRedirects(true);
$client->request('DELETE', '/1/delete');
$this->assertResponseIsSuccessful();
}
}
The phpunit error:
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: No route found for "GET /1/delete": Method Not Allowed (Allow: DELETE)
Based on the error, it appears that my $client->request is only doing 'GETs' regardless of the method listed.
So, what function should I be calling to test a 'DELETE' method?
Aucun commentaire:
Enregistrer un commentaire