I'm setting up phpunit for testing, and started with the Controller routes. When I test the 'GET' methods, they work fine. However, the 'DELETE' methods throw an MethodNotAllowedHttpException. NOTE: I'm not testing adding/removing database entities yet, just validating routes.
* @Route("/deviceprofile/{deviceprofile_id}/delete",
* name="deviceprofile_delete",
* methods={"DELETE"})
The test class:
class DeviceProfileControllerTest extends WebTestCase
{
public function testRouteDelete()
{
$client = static::createClient();
$client->followRedirects(true);
$client->request('DELETE', '/deviceprofile/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?
EDIT: here is the bin/console debug:router listing:
deviceprofile_delete DELETE ANY ANY
/deviceprofile/{deviceprofile_id}/delete
UPDATE: it also appears that 'POST' method only routes also fail.
php bin/console debug:routerto debug routes. - Leprechaun--env=test- Leprechaun