Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with PHPUnit in Symfony2

I have a error with PHPUnit using Symfony2

In my test case I import:

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

But, when I execute it I get:

PHP Fatal error:  Class 'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found in C:\trabajo\web\Company\src\Company\WebBundle\Tests\dbTest.php on line 11

I use to execute it:

phpunit -c app/ src/Company/WebBundle/Tests/dbTest

Any help?

Thanks in advance.

like image 322
user2599114 Avatar asked Jul 19 '13 10:07

user2599114


1 Answers

This is because to execute the test case with CLI you need to provide

  • boostrap file /app/bootstrap.php.cache
  • configuration file app/phpunit.xml.dist

So the command would be like below:

phpunit --configuration app/phpunit.xml.dist ----bootstrap /app/bootstrap.php.cache

Bootstrap can be provided in phpunit.xml.dist as well within <phpunit> tag.

The other option assuming you have good phpunit.xml.dist file is to go to app directory and there execute the tests.

You may adjust the paths to your needs.

like image 186
Robert Avatar answered Oct 22 '22 19:10

Robert