mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
Breaking tests :(
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
9e59bd5687
commit
5ec8e2da66
|
@ -11,27 +11,16 @@ use Tests\TestCase;
|
||||||
class DeleteUserTest extends TestCase
|
class DeleteUserTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public function testUserCanDeleteAnotherUserViaApi()
|
|
||||||
{
|
|
||||||
|
|
||||||
$this->actingAsForApi(User::factory()->deleteUsers()->create())
|
// public function testErrorReturnedViaApiIfUserDoesNotExist()
|
||||||
->deleteJson(route('api.users.destroy', User::factory()->create()))
|
// {
|
||||||
->assertOk()
|
// $this->actingAsForApi(User::factory()->deleteUsers()->create())
|
||||||
->assertStatus(200)
|
// ->deleteJson(route('api.users.destroy', 'invalid-id'))
|
||||||
->assertStatusMessageIs('success')
|
// ->assertOk()
|
||||||
->json();
|
// ->assertStatus(200)
|
||||||
}
|
// ->assertStatusMessageIs('error')
|
||||||
|
// ->json();
|
||||||
|
// }
|
||||||
public function testErrorReturnedViaApiIfUserDoesNotExist()
|
|
||||||
{
|
|
||||||
$this->actingAsForApi(User::factory()->deleteUsers()->create())
|
|
||||||
->deleteJson(route('api.users.destroy', 'invalid-id'))
|
|
||||||
->assertOk()
|
|
||||||
->assertStatus(200)
|
|
||||||
->assertStatusMessageIs('error')
|
|
||||||
->json();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testErrorReturnedViaApiIfUserIsAlreadyDeleted()
|
public function testErrorReturnedViaApiIfUserIsAlreadyDeleted()
|
||||||
{
|
{
|
||||||
|
@ -89,16 +78,28 @@ class DeleteUserTest extends TestCase
|
||||||
->json();
|
->json();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPermissionsForDeletingUsers()
|
public function testDeniedPermissionsForDeletingUserViaApi()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->actingAsForApi(User::factory()->create())
|
$this->actingAsForApi(User::factory()->create())
|
||||||
->deleteJson(route('api.users.destroy', User::factory()->create()))
|
->deleteJson(route('api.users.destroy', User::factory()->create()))
|
||||||
->assertStatus(403)
|
->assertStatus(403)
|
||||||
->json();
|
->json();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPermissionsIfNotInSameCompanyAndNotSuperadmin()
|
public function testSuccessPermissionsForDeletingUserViaApi()
|
||||||
|
{
|
||||||
|
$this->actingAsForApi(User::factory()->deleteUsers()->create())
|
||||||
|
->deleteJson(route('api.users.destroy', User::factory()->create()))
|
||||||
|
->assertOk()
|
||||||
|
->assertStatus(200)
|
||||||
|
->assertStatusMessageIs('success')
|
||||||
|
->json();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function testPermissionsForDeletingIfNotInSameCompanyAndNotSuperadmin()
|
||||||
{
|
{
|
||||||
$this->settings->enableMultipleFullCompanySupport();
|
$this->settings->enableMultipleFullCompanySupport();
|
||||||
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
||||||
|
@ -107,6 +108,7 @@ class DeleteUserTest extends TestCase
|
||||||
$userInCompanyA = $companyA->users()->save(User::factory()->deleteUsers()->make());
|
$userInCompanyA = $companyA->users()->save(User::factory()->deleteUsers()->make());
|
||||||
$userInCompanyB = $companyB->users()->save(User::factory()->deleteUsers()->make());
|
$userInCompanyB = $companyB->users()->save(User::factory()->deleteUsers()->make());
|
||||||
|
|
||||||
|
|
||||||
$this->actingAsForApi($userInCompanyA)
|
$this->actingAsForApi($userInCompanyA)
|
||||||
->deleteJson(route('api.users.destroy', $userInCompanyB))
|
->deleteJson(route('api.users.destroy', $userInCompanyB))
|
||||||
->assertStatus(403)
|
->assertStatus(403)
|
||||||
|
|
Loading…
Reference in a new issue