Reputation: 309
I have developed a set of API's using the API Platform 3.4 for Symfony 6.4. I have written test cases using PHPUnit, However running the tests throws the following error
Error: Call to undefined method ApiPlatform\Symfony\Bundle\Test\Response::assertResponseIsSuccessful()
My test script is :
namespace App\Tests\Api;
use \Datetime;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
//use ApiPlatform\Symfony\Bundle\Test\Client;
use App\Entity\Carrier;
class CarrierTest extends ApiTestCase
{
public function testCreateCarrier(): void
{
$response = static::createClient()->request('POST', '/api/carriers`',
['json' => [
'CarrierName' => 'Name of the Carrier',
'CarrierCode' => 'CARR1',
'CarrierDoorOrPOBoxNumber' => '56A',
'CarrierBuildingName' => '',
'CarrierStreetName' => 'First Street',
'CarrierLocality' => 'Locality',
'CarrierStateOrCounty' => 'TN',
'CarrierCountry' => 'India',
'CarrierPostalCode' => '563115',
'AccountManager' => 'Account Manager 1',
'AccountNumber' => 'TBC',
'CarrierPhoneNumber' => '',
'CarrierEmail' => '[email protected]',
'CarrierLogo' => '',
]]);
$response->assertResponseIsSuccessful();
$response->assertResponseStatusCodeSame(201);
}
}
Inspite of digging deep in the API Platform documentation I am unable to come across anything concrete to resolve this. I have had no problems with PHP Unit tests in Symfony 5.x. Any sugesstion what I could be missing.
Upvotes: 0
Views: 48