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
I have a kind of "crud tests" and in my first test case I'm testing the 'create' endpoint and it works.
My second test case is testing the PUT endpoint to update the data of this same entity, so I'm setting the ID with $this->myId in first test case to reuse it in the second one.
it('can create a collect', function () {
$response = $this->post(`... omitted `);
$response->assertOk();
expect($response->json('data.id'))->toBeInt();
$this->collectId = $response->json('data.id');
});
it('can update a collect', function () {
$collectId = $this->collectId;
The error: Undefined property: P\Tests\Feature\Http\Controllers\Internal\Logistics\ReverseCollectControllerTest::$collectId
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
-
I have a kind of "crud tests" and in my first test case I'm testing the 'create' endpoint and it works.
My second test case is testing the
PUT
endpoint to update the data of this same entity, so I'm setting the ID with$this->myId
in first test case to reuse it in the second one.The error:
Undefined property: P\Tests\Feature\Http\Controllers\Internal\Logistics\ReverseCollectControllerTest::$collectId
I found this explain about use
return
to share data to next test case in phpunit's classes but when I uses the value returned in the closure params, it conflicts withwith
feature.How could I pass the entity_id from the first test case to the second test case?
Beta Was this translation helpful? Give feedback.
All reactions