lundi 12 avril 2021

PHP Unit Test - Problem with JsonApiException

I have a problem to use JsonApiException library. I need simulate a error, and this is my code:

$error = ErrorCloudCreativity::create([
    'msg' => 'Not Found',
    'title' => 'Not Found',
    'code' => Errors::ACTIVITY_EXCEPTIONNOT_FOUND_CANCEL_QUESTION,
]);

$this->expectExceptionObject(
    new JsonApiException($error, Response::HTTP_BAD_REQUEST)
);

And this is my error response in console:

There was 1 failure:

1) App\Services\Activity\ActivityServiceTest::testUpdateActivity
Failed asserting that exception of type "Neomerx\JsonApi\Exceptions\JsonApiException" is thrown.

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

How can I fix it or change this library? Thanks!

Aucun commentaire:

Enregistrer un commentaire