create(); $user->refresh(); return $user; } function buildReplyWithParent(): array { $parentOwner = pdMakeUser(); $parent = Status::factory()->create([ 'profile_id' => $parentOwner->profile_id, 'scope' => 'public', 'type' => 'photo', ]); $replyOwner = pdMakeUser(); $reply = Status::factory()->create([ 'profile_id' => $replyOwner->profile_id, 'scope' => 'public', 'type' => 'reply', 'in_reply_to_id' => $parent->id, 'in_reply_to_profile_id' => $parentOwner->profile_id, ]); return compact('replyOwner', 'reply', 'parent'); } it('returns 200 when the parent is alive', function () { ['replyOwner' => $replyOwner, 'reply' => $reply] = buildReplyWithParent(); $response = $this->get("/p/{$replyOwner->profile->username}/{$reply->id}"); $response->assertOk(); }); it('returns 404 (not 500) when the parent is soft-deleted', function () { ['replyOwner' => $replyOwner, 'reply' => $reply, 'parent' => $parent] = buildReplyWithParent(); $parent->delete(); $response = $this->get("/p/{$replyOwner->profile->username}/{$reply->id}"); $response->assertNotFound(); }); it('returns 404 (not 500) when the parent is force-deleted', function () { ['replyOwner' => $replyOwner, 'reply' => $reply, 'parent' => $parent] = buildReplyWithParent(); $parent->forceDelete(); $response = $this->get("/p/{$replyOwner->profile->username}/{$reply->id}"); $response->assertNotFound(); });