mirror of
https://github.com/10h30/Test-Laravel-Eloquent-Basics.git
synced 2026-07-11 10:55:52 +09:00
Tasks until no.8 - mass delete users
This commit is contained in:
@@ -90,4 +90,33 @@ class EloquentTest extends TestCase
|
||||
$this->assertDatabaseMissing('projects', ['name' => 'Old name']);
|
||||
$this->assertDatabaseHas('projects', ['name' => 'New name']);
|
||||
}
|
||||
|
||||
public function test_check_or_update_user() {
|
||||
$response = $this->get('users/check_update/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_update/john/john2@john.com');
|
||||
$this->assertDatabaseHas('users', [
|
||||
'name' => 'john',
|
||||
'email' => 'john2@john.com'
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_mass_delete_users()
|
||||
{
|
||||
User::factory(4)->create();
|
||||
$this->assertDatabaseCount('users', 4);
|
||||
|
||||
$response = $this->delete('users', [
|
||||
'users' => [1, 2, 3]
|
||||
]);
|
||||
$response->assertRedirect();
|
||||
$this->assertDatabaseCount('users', 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user