1

I have been trying to run FunctionalTest which extends the Symfony\Bundle\FrameworkBundle\Tests\Functional\WebTestCase with not so much success.

The issue is that:

  1. the code in FrameworkBundle\Tests\Functional\app\AppKernel.php attempts to load autoload.php.dist in the framework bundle (not the one in the app/).

  2. And autoload.php.dist then tries to load vendor\autoload.php which does not exist within this path.

If I remove the autoload.php.dist in the FrameworkBundle then everything is fine, but I want to avoid doing that because each time I do composer update I will then have to remove that specific fine.

I wonder what I'm doing wrong.

The exact error from the console is posted below for your information:

Configuration read from D:\xampp\htdocs\demo\app\phpunit.xml. dist

  1. require_once() called at [D:\xampp\htdocs\demo\vendor\sym fony\symfony\src\Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel.p hp:26]

  2. require_once(D:\xampp\htdocs\demo\vendor\symfony\symfony\ src\Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel.php) called at [D:\xampp\htdocs\demo\vendor\symfony\symfony\src\Symfony\Bun dle\FrameworkBundle\Tests\Functional\WebTestCase.php:47]

Fatal error: main(): Failed opening required 'D:\xampp\htdocs\demo\vendor\symfony\symfony/vendor/autoload.php' (include_path='.;D:\xampp\php\PEAR') in D:\xampp\htdocs\demo\vendor\symfony\sym fony\autoload.php.dist on line 9

The test class simply extends WebTestCase with the setUp looks like this:

static::$kernel = static::createKernel(array('test_case'));
static::$kernel->boot();
$this->containter = static::$kernel->getContainer();
3
  • I just ran a test on my unix machine and it's working. Don't have a windows machine handy. You just have MyTest extends WebTestCase? Have you gotten tests to run under xampp before? I use xampp at home and have not had a problem. What version of symfony? Commented Aug 20, 2013 at 12:44
  • All my tests are running fine, but those are just basic unit tests, this is the first time I extends WebTestCase. You are right, MyTest simply extends WebTestCase, also I simly get the container in the setUp. Let me add that in the question Commented Aug 20, 2013 at 14:26
  • Are you using the supplied phpunit.xml file either with phpunit -C or just by running phpunit in the app directory? Did you make any tweaks to phpunit.xml? There is a bootstrap line in there. Commented Aug 20, 2013 at 14:48

1 Answer 1

4

Okay. I see the problem. You are extending from Tests\Functional\WebTestCase. That is actually a test for testing the WebTestCase. You want to extend from Test\WebTestCase.

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class PersonRepositoryTest extends WebTestCase
{
    public function testProject()
    {
        $client = static::createClient();

        $manager = $client->getContainer()->get('cerad_person.manager');

And you might want to get one or two working using the $client line shown above. All the setup stuff can be a bit tricky.

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

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.