Symfony2&;Phpunit为什么\Phpunit\u Framework\u测试用例工作,而Phpunit\Framework\TestCase不工作?
为了尝试一些东西,我有一个小型的Symfony2项目,我编写了以下测试类:Symfony2&;Phpunit为什么\Phpunit\u Framework\u测试用例工作,而Phpunit\Framework\TestCase不工作?,php,symfony,phpunit,Php,Symfony,Phpunit,为了尝试一些东西,我有一个小型的Symfony2项目,我编写了以下测试类: namespace AppBundle\Tests\Managers\CRUD; // use PHPUnit\Framework\TestCase; class PersonManagerTest extends \PHPUnit_Framework_TestCase { public function testTrue() { print "Test True"; $this->as
namespace AppBundle\Tests\Managers\CRUD;
// use PHPUnit\Framework\TestCase;
class PersonManagerTest extends \PHPUnit_Framework_TestCase
{
public function testTrue()
{
print "Test True";
$this->assertTrue(true);
}
}
这是应该的,但如果我尝试这样重构:
namespace AppBundle\Tests\Managers\CRUD;
use PHPUnit\Framework\TestCase;
class PersonManagerTest extends TestCase
{
public function testTrue()
{
print "Test True";
$this->assertTrue(true);
}
}
我得到以下错误:
PHP致命错误:在第8行的/home/pcmagas/Kwdikas/PHP/apps/sjonapi/src/AppBundle/Tests/Managers/CRUD/PersonManagerTest.PHP中找不到类“TestCase”
我想知道为什么会这样
我的composer.json是:
{
"name" : "pcmagas/sjonapi",
"license" : "WFPL",
"type" : "project",
"autoload" : {
"psr-4" : {
"" : "src/"
},
"classmap" : [
"app/AppKernel.php",
"app/AppCache.php"
]
},
"repositories": [{
"type": "vcs",
"url": "/home/pcmagas/Kwdikas/php/non-web/pcmagas-libs"
}],
"require" : {
"php" : ">=5.3.9",
"symfony/symfony" : "2.8.*",
"doctrine/orm" : "^2.5",
"doctrine/doctrine-bundle" : "~1.4",
"doctrine/common": "~2.5",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle" : "~2.3",
"symfony/monolog-bundle" : "~2.4",
"sensio/distribution-bundle" : "~5.0",
"sensio/framework-extra-bundle" : "^3.0.2",
"incenteev/composer-parameter-handler" : "~2.0",
"nilportugues/jsonapi-bundle" : "^1.5",
"pcmagas/libs": "dev-master",
"doctrine/annotations": "^1.3"
},
"require-dev" : {
"sensio/generator-bundle" : "~3.0",
"symfony/phpunit-bridge" : "~2.7",
"phpunit/phpunit": "5.5.*"
},
"scripts" : {
"post-install-cmd" : [
"@symfony-scripts"
],
"post-update-cmd" : [
"@symfony-scripts"
]
},
"config" : {
"bin-dir" : "bin"
},
"extra" : {
"symfony-app-dir" : "app",
"symfony-web-dir" : "web",
"symfony-assets-install" : "relative",
"incenteev-parameters" : {
"file" : "app/config/parameters.yml"
},
"map": [
[
"*",
"CommonLibs\\Helpers",
"CommonLibs\\Interfaces"
]
]
},
"description" : "A simple Demo using JSON API"
}
非常确定PHPUnit直到6.x才采用名称空格。
PHPUnit\Framework\TestCase
在5.4.3中作为前向兼容性别名添加(在5.4.0中,它最初作为PHPUnit\Framework\TestCase
)。