mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 21:54:14 -08:00
Added tests
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
c6a0212384
commit
65e8765bdd
|
@ -11,6 +11,28 @@ use Tests\TestCase;
|
||||||
class DeleteUserTest extends TestCase
|
class DeleteUserTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function testUserCanDeleteAnotherUserViaApi()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->actingAsForApi(User::factory()->deleteUsers()->create())
|
||||||
|
->deleteJson(route('api.users.destroy', User::factory()->create()))
|
||||||
|
->assertOk()
|
||||||
|
->assertStatus(200)
|
||||||
|
->assertStatusMessageIs('success')
|
||||||
|
->json();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testErrorReturnedViaApiIfUserDoesNotExist()
|
||||||
|
{
|
||||||
|
$this->actingAsForApi(User::factory()->deleteUsers()->create(['company_id'=> null]))
|
||||||
|
->deleteJson(route('api.users.destroy', 'invalid-id'))
|
||||||
|
->assertOk()
|
||||||
|
->assertStatus(200)
|
||||||
|
->assertStatusMessageIs('error')
|
||||||
|
->json();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testDisallowUserDeletionViaApiIfStillManagingPeople()
|
public function testDisallowUserDeletionViaApiIfStillManagingPeople()
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,6 +14,30 @@ use App\Models\Asset;
|
||||||
class DeleteUserTest extends TestCase
|
class DeleteUserTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function testUserCanDeleteAnotherUser()
|
||||||
|
{
|
||||||
|
$user = User::factory()->deleteUsers()->viewUsers()->create();
|
||||||
|
$this->actingAs(User::factory()->deleteUsers()->viewUsers()->create())->assertTrue($user->isDeletable());
|
||||||
|
|
||||||
|
$response = $this->actingAs(User::factory()->deleteUsers()->viewUsers()->create())
|
||||||
|
->delete(route('users.destroy', ['user' => $user->id]))
|
||||||
|
->assertStatus(302)
|
||||||
|
->assertRedirect(route('users.index'));
|
||||||
|
|
||||||
|
$this->followRedirects($response)->assertSee(trans('general.notification_success'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testErrorReturnedIfUserDoesNotExist()
|
||||||
|
{
|
||||||
|
$response = $this->actingAs(User::factory()->deleteUsers()->viewUsers()->create())
|
||||||
|
->delete(route('users.destroy', ['user' => '40596803548609346']))
|
||||||
|
->assertStatus(302)
|
||||||
|
->assertRedirect(route('users.index'));
|
||||||
|
//$this->followRedirects($response)->assertSee(trans('general.error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testPermissionsToDeleteUser()
|
public function testPermissionsToDeleteUser()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue