mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
MOAR TESTS
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
cff382605c
commit
ea8d390596
|
@ -66,7 +66,7 @@ class DeleteUsersTest extends TestCase
|
|||
->json();
|
||||
}
|
||||
|
||||
public function testDisallowUserDeletionIfNotInSameCompanyIfNotSuperadmin()
|
||||
public function testDisallowUserDeletionIfNotInSameCompanyAndNotSuperadmin()
|
||||
{
|
||||
$this->settings->enableMultipleFullCompanySupport();
|
||||
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
||||
|
@ -94,6 +94,20 @@ class DeleteUsersTest extends TestCase
|
|||
|
||||
}
|
||||
|
||||
public function testUsersCannotDeleteThemselves()
|
||||
{
|
||||
$user = User::factory()->deleteUsers()->create();
|
||||
$this->actingAsForApi($user)
|
||||
->deleteJson(route('api.users.destroy', $user))
|
||||
->assertOk()
|
||||
->assertStatus(200)
|
||||
->assertStatusMessageIs('error')
|
||||
->json();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -13,27 +13,44 @@ class DeleteUsersTest extends TestCase
|
|||
|
||||
public function testDisallowUserDeletionIfStillManagingPeople()
|
||||
{
|
||||
$manager = User::factory()->create(['first_name' => 'Manager', 'last_name' => 'McManagerson']);
|
||||
User::factory()->create(['first_name' => 'Lowly', 'last_name' => 'Worker', 'manager_id' => $manager->id]);
|
||||
$manager = User::factory()->create();
|
||||
User::factory()->count(3)->create(['manager_id' => $manager->id]);
|
||||
|
||||
$this->actingAs(User::factory()->deleteUsers()->create())->assertFalse($manager->isDeletable());
|
||||
|
||||
$this->actingAs(User::factory()->deleteUsers()->create())
|
||||
->delete(route('users.destroy', $manager->id))
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('users.index'));
|
||||
}
|
||||
|
||||
public function testDisallowUserDeletionIfStillManagingLocations()
|
||||
{
|
||||
$manager = User::factory()->create(['first_name' => 'Manager', 'last_name' => 'McManagerson']);
|
||||
Location::factory()->create(['manager_id' => $manager->id]);
|
||||
$manager = User::factory()->create();
|
||||
Location::factory()->count(3)->create(['manager_id' => $manager->id]);
|
||||
|
||||
$this->actingAs(User::factory()->deleteUsers()->create())->assertFalse($manager->isDeletable());
|
||||
|
||||
$this->actingAs(User::factory()->deleteUsers()->create())
|
||||
->delete(route('users.destroy', $manager->id))
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('users.index'));
|
||||
}
|
||||
|
||||
public function testAllowUserDeletionIfNotManagingLocations()
|
||||
{
|
||||
$manager = User::factory()->create(['first_name' => 'Manager', 'last_name' => 'McManagerson']);
|
||||
$manager = User::factory()->create();
|
||||
$this->actingAs(User::factory()->deleteUsers()->create())->assertTrue($manager->isDeletable());
|
||||
|
||||
$this->actingAs(User::factory()->deleteUsers()->create())
|
||||
->delete(route('users.destroy', $manager->id))
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('users.index'));
|
||||
}
|
||||
|
||||
public function testDisallowUserDeletionIfNoDeletePermissions()
|
||||
{
|
||||
$manager = User::factory()->create(['first_name' => 'Manager', 'last_name' => 'McManagerson']);
|
||||
$manager = User::factory()->create();
|
||||
Location::factory()->create(['manager_id' => $manager->id]);
|
||||
$this->actingAs(User::factory()->editUsers()->create())->assertFalse($manager->isDeletable());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue