I have a test application that we upgraded from Symfony 2.3 to 2.6. We kept track of all document updates and needed to change only a few minor things. Everything works fine except for PHPUnit tests.
We have 2 separate runs, one for testing only entity classes that runs on the pre-commit hook. and the second, which runs the full set, with database settings and as many as nine yards.
Now, starting with the upgrade to version 2.6, the tags PHPUnit_Framework_Errorthat were added to the unit tests were replaced with Symfony Symfony\Component\Debug\Exception\ContextErrorException, which failed to run all the tests as follows:
public function testCanNotSetClientToArbitraryValue($value)
Now I do not want to change this to a new exception, since running an entity-dependent test suite does not depend on symfony components, so symfony does not load, so errors are regular PHPUnit_Framework_Error, so changing them makes these tests fail.
In other words, when I run one test class, it works, as soon as a symfony dependent test runs, it fails:
phpunit -c app/phpunit.xml --debug src/My/Bundle/Tests/Entity
phpunit -c app/phpunit.xml --debug
This new ErrorHandler seems to be undocumented, I couldn't find much about it on google except pull request, and this little article
I tried:
- setting an environment variable
SYMFONY_DEBUG=0, but that doesn't seem to make any difference. - adding parameter
debug.error_handler.throw_at: 0to test_config.yml file
change
@cerad , , Ive 4 :
class MyControllerTest extends WebTestCase
{
public function testRoutesLoaded_1()
{
$client = self::createClient();
$router = $client->getKernel()->getContainer()->get('router');
$this->assertEquals('/menu', $router->generate('front_menu'));
}
public function testCreateOrder_1()
{
new Order();
}
public function testRoutesLoaded_2()
{
$client = $this->createNewFrontClient();
$router = $client->getKernel()->getContainer()->get('router');
$this->assertEquals('/menu', $router->generate('front_menu'));
}
public function testCreateOrder_2()
{
new Order();
}
}
, 2 , :
MyControllerTest:: testCreateOrder_2 , "Symfony\Component\Debug\Exception\ContextErrorException" "\ PHPUnit_Framework_Error"