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!
$client = new Client(doesn't work? I did a composer require guzzlehttp/guzzle but doesn't seem to be working :pPHPUnit 6as well as for earlier versions.