我一直在嘗試運行FunctionalTest,它擴展了Symfony \ Bundle \ FrameworkBundle \ Tests \ Functional \ WebTestCase並沒有那麼成功。Symfony 2上的功能測試 - 問題與默認autoload.php.dist
的問題是:
在FrameworkBundle代碼\測試\功能\應用\ AppKernel.php嘗試加載autoload.php.dist在框架束(不是一個在應用程序/ )。
然後autoload.php.dist會嘗試加載該路徑中不存在的vendor \ autoload.php。
如果我刪除autoload.php.dist在FrameworkBundle那麼一切都很好,但我想避免這樣做,因爲每次我做的作曲家更新我便要刪除特定的罰款。
我想知道我做錯了什麼。
從控制檯確切的錯誤張貼下面您的信息:
Configuration read from D:\xampp\htdocs\demo\app\phpunit.xml. dist
require_once() called at [D:\xampp\htdocs\demo\vendor\sym fony\symfony\src\Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel.p hp:26]
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
測試類只需擴展WebTestCase與設置是這樣的:
static::$kernel = static::createKernel(array('test_case'));
static::$kernel->boot();
$this->containter = static::$kernel->getContainer();
我剛剛在我的unix機器上運行了一個測試,它工作正常。沒有方便的Windows機器。你只需要MyTest擴展WebTestCase?你有沒有得到測試在xampp之前運行?我在家使用xampp並沒有問題。什麼版本的symfony? – Cerad
我所有的測試都運行良好,但這些只是基本的單元測試,這是我第一次擴展WebTestCase。你是對的,MyTest只是擴展了WebTestCase,我也在setUp中模擬了容器。讓我補充一點,在 – mr1031011
這個問題中您是使用phpunit -C提供的phpunit.xml文件,還是僅僅通過在app目錄中運行phpunit?你有沒有對phpunit.xml做任何調整?那裏有一條引導線。 – Cerad