![](/img/trans.png)
[英]Class 'PHPUnit_Framework_TestCase' not found in Symfony2 project
[英]Symfony/PHPUnitClass 'PHPUnit_Framework_TestCase' not found
我使用api平台框架创建了一个非常简单的基本api。 现在,我试图用PHP单元编写一个简单的单元测试,但是当我尝试运行测试时,却不断出现此错误:
Class 'PHPUnit_Framework_TestCase' not found
它在抱怨这一行:
class JobControllerTest extends \\PHPUnit_Framework_TestCase
它说undefined class
我用作曲家安装了phpunit我不知道我在做什么错。
这是我的完整测试:
<?php
namespace tests\AppBundle;
class JobControllerTest extends \PHPUnit_Framework_TestCase
{
public function testPOST()
{
$client = new Client('http://localhost:8000', array(
'request.options' => array(
'exceptions' => false,
)
));
$data = array(
'bar' => "hello",
);
$request = $client->post('/foos', null, json_encode($data));
$response = $request->send();
$this->assertEquals(201, $response->getStatusCode());
$this->assertTrue($response->hasHeader('Location'));
$data = json_decode($response->getBody(true), true);
$this->assertArrayHasKey('bar', $data);
}
}
如果有人可以帮助我,那将非常酷:)
提前谢谢了!
这是因为phpunit6已被弃用,请使用以下命令:
use PHPUnit\Framework\TestCase;
class UserControllerTest extends TestCase
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.