6

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.

3
  • 2
    Do you extend the class? class dbTest extends WebTestCase Commented Jul 19, 2013 at 11:41
  • 1
    Looks like a problem with your autoloader Commented Jul 19, 2013 at 16:37
  • 1
    Try to run just phpunit -c app Commented Feb 22, 2016 at 10:02

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Check that you extends the dbTest class:

<?php

namespace Company\WebBundle\Tests;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class dbTest extends WebTestCase
{
    ...
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.