Task 4 - get or create a record

This commit is contained in:
PovilasKorop
2021-11-16 08:19:07 +02:00
parent ec68bf7dcd
commit 9a522ae509
4 changed files with 32 additions and 0 deletions
+14
View File
@@ -55,4 +55,18 @@ class EloquentTest extends TestCase
$response->assertViewHas('user', $user);
}
public function test_check_or_create_user()
{
$response = $this->get('users/check/john/john@john.com');
$response->assertStatus(200);
$this->assertDatabaseHas('users', [
'name' => 'john',
'email' => 'john@john.com'
]);
// Same parameters - should NOT create a new user
$this->get('users/check/john/john@john.com');
$this->assertDatabaseCount('users', 1);
}
}