mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
More (failing) tests
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
5cdb2b7163
commit
47420a802a
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Tests\Feature\Users\Ui;
|
namespace Tests\Feature\Users\Ui;
|
||||||
|
|
||||||
|
use App\Models\LicenseSeat;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
@ -40,6 +41,37 @@ class DeleteUserTest extends TestCase
|
||||||
$this->followRedirects($response)->assertSee('Error');
|
$this->followRedirects($response)->assertSee('Error');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDisallowUserDeletionIfStillHaveAccessories()
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
Accessory::factory()->count(3)->create(['assigned_to' => $user->id]);
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->deleteUsers()->create())->assertFalse($user->isDeletable());
|
||||||
|
|
||||||
|
$response = $this->actingAs(User::factory()->deleteUsers()->viewUsers()->create())
|
||||||
|
->delete(route('users.destroy', $user->id))
|
||||||
|
->assertStatus(302)
|
||||||
|
->assertRedirect(route('users.index'));
|
||||||
|
|
||||||
|
$this->followRedirects($response)->assertSee('Error');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDisallowUserDeletionIfStillHaveLicenses()
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
LicenseSeat::factory()->count(3)->create(['assigned_to' => $user->id]);
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->deleteUsers()->create())->assertFalse($user->isDeletable());
|
||||||
|
|
||||||
|
$response = $this->actingAs(User::factory()->deleteUsers()->viewUsers()->create())
|
||||||
|
->delete(route('users.destroy', $user->id))
|
||||||
|
->assertStatus(302)
|
||||||
|
->assertRedirect(route('users.index'));
|
||||||
|
|
||||||
|
$this->followRedirects($response)->assertSee('Error');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testAllowUserDeletionIfNotManagingLocations()
|
public function testAllowUserDeletionIfNotManagingLocations()
|
||||||
{
|
{
|
||||||
$manager = User::factory()->create();
|
$manager = User::factory()->create();
|
||||||
|
@ -61,5 +93,18 @@ class DeleteUserTest extends TestCase
|
||||||
$this->actingAs(User::factory()->editUsers()->create())->assertFalse($manager->isDeletable());
|
$this->actingAs(User::factory()->editUsers()->create())->assertFalse($manager->isDeletable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testUsersCannotDeleteThemselves()
|
||||||
|
{
|
||||||
|
$manager = User::factory()->deleteUsers()->create();
|
||||||
|
$this->actingAs(User::factory()->deleteUsers()->create())->assertTrue($manager->isDeletable());
|
||||||
|
|
||||||
|
$response = $this->actingAs($manager)
|
||||||
|
->delete(route('users.destroy', $manager->id))
|
||||||
|
->assertStatus(302)
|
||||||
|
->assertRedirect(route('users.index'));
|
||||||
|
|
||||||
|
$this->followRedirects($response)->assertSee('Error');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue