You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are trying to add testing around an API. This API has DB saves and other application logic. Assume our requirement is to receive 403 HTTP status If the DB save has failed (part of an error handling we do).
Now we want to mock that DB save (which is in our application) so that we can verify that our endpoint returns the correct HTTP status code, in case an application function has failed.
Our API endpoint’s code looks something like
if(!Model::dbSave()){
return 403;
}
return 200;
Our testcase: When the DB Save failed I would see a 403.
test::double({Model name in the Application}, ['dbSave' => false ]);
$I->sendGet("uri");
$I->seeResponseCodeIs(403);
We are having trouble mocking the application function this way. How could we mock application functions via API tests?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We use Codeception with Phalcon.
We are trying to add testing around an API. This API has DB saves and other application logic. Assume our requirement is to receive 403 HTTP status If the DB save has failed (part of an error handling we do).
Now we want to mock that DB save (which is in our application) so that we can verify that our endpoint returns the correct HTTP status code, in case an application function has failed.
Our API endpoint’s code looks something like
Our testcase: When the DB Save failed I would see a 403.
We are having trouble mocking the application function this way. How could we mock application functions via API tests?
Beta Was this translation helpful? Give feedback.
All reactions