mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Updated delete users API tests, moved non-API tests
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
694e3b7f3a
commit
c09e93e288
69
tests/Feature/Api/Users/DeleteUsersTest.php
Normal file
69
tests/Feature/Api/Users/DeleteUsersTest.php
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Api\Users;
|
||||
|
||||
use App\Models\Location;
|
||||
use App\Models\User;
|
||||
use App\Models\LicenseSeat;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DeleteUsersTest extends TestCase
|
||||
{
|
||||
|
||||
|
||||
public function testDisallowUserDeletionViaApiIfStillManagingPeople()
|
||||
{
|
||||
$manager = User::factory()->create();
|
||||
User::factory()->count(5)->create(['manager_id' => $manager->id]);
|
||||
$this->assertFalse($manager->isDeletable());
|
||||
|
||||
$this->actingAsForApi(User::factory()->deleteUsers()->create())
|
||||
->deleteJson(route('api.users.destroy', $manager->id))
|
||||
->assertOk()
|
||||
->assertStatus(200)
|
||||
->assertStatusMessageIs('error')
|
||||
->json();
|
||||
}
|
||||
|
||||
public function testDisallowUserDeletionViaApiIfStillManagingLocations()
|
||||
{
|
||||
$manager = User::factory()->create();
|
||||
Location::factory()->count(5)->create(['manager_id' => $manager->id]);
|
||||
|
||||
$this->assertFalse($manager->isDeletable());
|
||||
|
||||
$this->actingAsForApi(User::factory()->deleteUsers()->create())
|
||||
->deleteJson(route('api.users.destroy', $manager->id))
|
||||
->assertOk()
|
||||
->assertStatus(200)
|
||||
->assertStatusMessageIs('error')
|
||||
->json();
|
||||
}
|
||||
|
||||
public function testDisallowUserDeletionViaApiIfStillHasLicenses()
|
||||
{
|
||||
$manager = User::factory()->create();
|
||||
LicenseSeat::factory()->count(5)->create(['assigned_to' => $manager->id]);
|
||||
|
||||
$this->assertFalse($manager->isDeletable());
|
||||
|
||||
$this->actingAsForApi(User::factory()->deleteUsers()->create())
|
||||
->deleteJson(route('api.users.destroy', $manager->id))
|
||||
->assertOk()
|
||||
->assertStatus(200)
|
||||
->assertStatusMessageIs('error')
|
||||
->json();
|
||||
}
|
||||
|
||||
public function testDisallowUserDeletionIfNoDeletePermissions()
|
||||
{
|
||||
|
||||
$this->actingAsForApi(User::factory()->create())
|
||||
->deleteJson(route('api.users.destroy', User::factory()->create()))
|
||||
->assertStatus(403)
|
||||
->json();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Api\Users;
|
||||
namespace Tests\Feature\Users;
|
||||
|
||||
use App\Models\Location;
|
||||
use App\Models\User;
|
||||
use Laravel\Passport\Passport;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UsersDeleteTest extends TestCase
|
||||
class DeleteUsersTest extends TestCase
|
||||
{
|
||||
|
||||
|
Loading…
Reference in a new issue