I was trying out the new KnpRadBundle and when came the time to write to write unit tests, it didn’t work : my classes weren’t autoloaded properly.
It took me the best part of an afternoon to figure out, so I thought I should post it in case anyone stumbles upon this problem (perhaps I missed something …). Without further ado, here is the code :
<?php# src/YourProjectName/Tests/if(file_exists($file=__DIR__.'/../../../vendor/.composer/autoload.php')){$loader=require_once$file;$loader->add('YourProjectName',__DIR__.'/../..');}else{thrownewRuntimeException('Install dependencies to run test suite.');}