I am trying to run a unit test that checks if the assets are properly installed.
I simply make a request to an existing file and check if there is no errors:
$client = static::createClient();
$client->request('GET', '/bundles/mybundle/css/bg.css');
$this->assertFalse($client->getResponse()->isNotFound(), "Assets seem to not be installed");
Unfortunately, after checking with the Response instance, it always tries to reach some kind of controller with a route:
No route found for “GET /bundles/mybundle/css/bg.css”
Is there a way to make a pure request here without going through the routing system?
You’d need to use an actual HTTP client (the client implementation you are using for functional testing doesn’t actually make HTTP requests) to make that request, but you seem to be approaching this the wrong way. Installing assets should be part of your post deployment scripts — thus the test would always (or sometimes depending on the configuration of your development box, but the point is that it’s a deployment/staging detail) fail anyway. Just do a simple test in your deployment process in any language you want to make sure that the assets installed correctly.
Simplified example