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();
4

1 回答 1

4

好的。我看到了问题。您正在从 Tests\Functional\WebTestCase 扩展。这实际上是一个测试 WebTestCase 的测试。您想从 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');

您可能希望使用上面显示的 $client 行让一两个工作。所有设置的东西都可能有点棘手。

于 2013-08-20T14:54:28.447 回答