I created a very simple basic api with the api-platform framework. Now I am trying to write a simple unit test with PHP unit but when I try to run the test I keep getting this error:
Class 'PHPUnit_Framework_TestCase' not found
It is complaining about this line:
class JobControllerTest extends \\PHPUnit_Framework_TestCase
It says undefined class
I installed phpunit with composer I have no idea what I'm doing wrong.
Here is my full test:
<?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);
}
}
If anyone could help me any bit that would be pretty cool :)
Many thanks in advance!
This is because on phpunit6 has been deprecated, use the following:
use PHPUnit\Framework\TestCase;
class UserControllerTest extends TestCase
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.