Task 3 - get a single record

This commit is contained in:
PovilasKorop
2021-11-16 08:05:39 +02:00
parent 065d5dc4fd
commit ec68bf7dcd
5 changed files with 35 additions and 4 deletions
+12 -1
View File
@@ -22,7 +22,7 @@ class EloquentTest extends TestCase
}
// TASK: Write Eloquent query to return the newest 3 verified users
public function test_users_get()
public function test_get_filtered_list()
{
$user1 = User::factory()->create(['created_at' => now()->subMinutes(5)]);
$user2 = User::factory()->create(['created_at' => now()->subMinutes(4)]);
@@ -44,4 +44,15 @@ class EloquentTest extends TestCase
$response->assertSee('3. ' . $user2->name); // not $user3
}
public function test_find_user_or_show_404_page()
{
$response = $this->get('users/1');
$response->assertStatus(404);
$user = User::factory()->create();
$response = $this->get('users/1');
$response->assertStatus(200);
$response->assertViewHas('user', $user);
}
}