Tasks until no.8 - mass delete users

This commit is contained in:
PovilasKorop
2021-11-16 10:25:05 +02:00
parent b39af5b844
commit a5acfdd85f
4 changed files with 80 additions and 0 deletions
+29
View File
@@ -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);
}
}