How can I test RESTful api of DELETE in Laravel by using Codeception?
I use the following function:
public function authenticatedUserSuccessDeleteEmployee(ApiTester $I)
{
$I->wantToTest('authenticated super user success delete employee');
// set header authorization
$I->amBearerAuthenticated($this->token);
//
$this->employee = factory(\App\Models\Employee::class)->create([
'id' => '20200100000000'
]);
// get created object id.
$id = $this->getExpectedId();
// see database row is containing our expected data
$I->seeRecord('employees', ['id' => '20200100000000']);
// Send delete request
$I->sendDELETE('employees', array('id' => $id));
// check expected response code is 200 OK
$I->seeResponseCodeIs(200);
}
But the employee does not created in the DB!
How can I create an object for testing delete API?
Aucun commentaire:
Enregistrer un commentaire