![](/img/trans.png)
[英]Symfony: Fatal error: Class 'PHPUnit_Framework_TestCase' not found in
[英]Class 'PHPUnit_Framework_TestCase' not found in Symfony2 project
我正在symfony2開發一個項目,我是單元測試的新手。
我已經通過PEAR安裝了PHPUnit 3.6.10,當我對phpunit命令進行編號時,它可以在終端上運行。
我按照SensioLab建議( http://symfony.com/doc/current/book/testing.html )編寫了我的第一個測試類,但是當我使用命令時
php -c app src/My/CalendarBundle/Tests/Calendar/CalendarTest.php
我有
Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /Library/WebServer/Documents/calendar/src/My/CalendarBundle/Tests/Calendar/CalendarTest.php on line 7
在這里,您是我的測試類:
<?php
namespace My\CalendarBundle\Tests\Calendar;
use My\CalendarBundle\Calendar\Calendar;
class CalendarTest extends \PHPUnit_Framework_TestCase
{
public function testGetNextMonth()
{
$calendar = new Calendar('09', '2012', null);
$result = $calendar->getNextMonth();
$this->assertEquals(10, $result);
}
}
我讀了這個討論為什么,致命的錯誤:類'PHPUnit_Framework_TestCase'找不到...? 但symfony文檔並未說明包含PHPUnit ...
我做錯了什么? 謝謝
我剛剛遇到了類似的問題(使用DoctrineFixturesBundle),並通過向Symfony添加PHPUnit來解決它(而不是通過PEAR安裝PHPUnit)。
對我有用的是:
1)將"phpunit/phpunit": "4.0.*"
到composer.json
的require
部分:
{
"require": {
...
"phpunit/phpunit": "4.0.*"
}
}
2)從命令行運行:
php composer.phar update phpunit/phpunit
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.