public function assertErrorMessageContains(ApiTestResponse $response, $expectedStatus, $expectedError = null, $expectedMessage = null)
{
$body = $response->getBody();
$this->assertNotEmpty($body);
$printError = $this->printResponseError($response);
$this->assertEquals($expectedStatus, $response->response->getStatus(), $printError);
$this->assertObjectHasAttribute('errors', $body);
$this->assertNotEmpty($body->errors);
$error = reset($body->errors);
if ($expectedError !== null) {
$this->assertObjectHasAttribute('code', $error);
$this->assertEquals($expectedError, $error->code, $printError);
}
if ($expectedMessage !== null) {
$this->assertObjectHasAttribute('message', $error);
$this->assertContains($expectedMessage, $error->message, $printError);
}
}