Task 3 - multi-level relationships

This commit is contained in:
PovilasKorop
2021-11-22 07:39:27 +02:00
parent 9c71409ffc
commit 0fbdf0c99a
8 changed files with 108 additions and 0 deletions
+19
View File
@@ -2,6 +2,7 @@
namespace Tests\Feature;
use App\Models\Comment;
use App\Models\Task;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
@@ -29,4 +30,22 @@ class RelationshipsTest extends TestCase
$response = $this->get('/tasks');
$response->assertStatus(200);
}
// TASK: define the two-level relationship in the User model
public function test_show_users_comments()
{
$user = User::factory()->create();
$task = Task::create([
'users_id' => $user->id,
'name' => 'Some task'
]);
Comment::create([
'task_id' => $task->id,
'name' => 'Some name',
'comment' => 'Some comment'
]);
$response = $this->get('/users/' . $user->id);
$response->assertStatus(200);
}
}