Fixed tests

This commit is contained in:
snipe
2026-06-08 21:41:22 +01:00
parent 80c8aa41dc
commit 144772cfbe
3 changed files with 10 additions and 11 deletions
@@ -416,8 +416,7 @@ class BulkUsersController extends Controller
}
}
// Require delete permission before allowing user deletion.
if ($request->input('delete_user') == '1' && auth()->user()->cannot('delete', User::class)) {
if ($request->input('delete_user') == '1' && $users->isNotEmpty() && auth()->user()->cannot('delete', User::class)) {
return redirect()->route('users.index')->with('error', trans('general.insufficient_permissions'));
}
@@ -20,14 +20,14 @@ class LicenseCheckinTest extends TestCase
->assertForbidden();
}
public function test_non_reassignable_license_seat_cant_be_checked_out()
public function test_non_reassignable_seat_remains_unreassignable_after_checkin()
{
$licenseSeat = LicenseSeat::factory()
->notReassignable()
->assignedToUser()
->create();
$this->actingAs(User::factory()->checkoutLicenses()->create())
$this->actingAs(User::factory()->checkinLicenses()->create())
->post(route('licenses.checkin.save', $licenseSeat));
$licenseSeat->refresh();
@@ -44,7 +44,7 @@ class LicenseCheckinTest extends TestCase
$this->assertNull($licenseSeat->assigned_to);
$this->assertNull($licenseSeat->asset_id);
$this->actingAs(User::factory()->checkoutLicenses()->create())
$this->actingAs(User::factory()->checkinLicenses()->create())
->post(route('licenses.checkin.save', $licenseSeat), [
'notes' => 'my note',
'redirect_option' => 'index',
@@ -63,7 +63,7 @@ class LicenseCheckinTest extends TestCase
->assignedToAsset($asset)
->create();
$actor = User::factory()->checkoutLicenses()->create();
$actor = User::factory()->checkinLicenses()->create();
$this->actingAs($actor)
->post(route('licenses.checkin.save', $licenseSeat), [
@@ -96,7 +96,7 @@ class LicenseCheckinTest extends TestCase
->assignedToUser($user)
->create();
$actor = User::factory()->checkoutLicenses()->create();
$actor = User::factory()->checkinLicenses()->create();
$this->actingAs($actor)
->post(route('licenses.checkin.save', $licenseSeat), [
@@ -80,7 +80,7 @@ class BulkDeleteUsersTest extends TestCase
'delete_user' => '1',
])
->assertRedirect(route('users.index'))
->assertSessionHas('success', trans('general.bulk_checkin_delete_success'));
->assertSessionHas('error', trans('general.insufficient_permissions'));
$this->assertNotSoftDeleted($admin);
}
@@ -112,7 +112,7 @@ class BulkDeleteUsersTest extends TestCase
$this->attachAccessoryToUsers($accessoryA, [$userA, $userB, $userC]);
$this->attachAccessoryToUsers($accessoryB, [$userA, $userB]);
$this->actingAs(User::factory()->editUsers()->create())
$this->actingAs(User::factory()->editUsers()->checkinAccessories()->create())
->post(route('users/bulksave'), [
'ids' => [
$userA->id,
@@ -141,7 +141,7 @@ class BulkDeleteUsersTest extends TestCase
$lonelyAsset = $this->assignAssetToUser($userB);
$assetForUserC = $this->assignAssetToUser($userC);
$this->actingAs(User::factory()->editUsers()->create())
$this->actingAs(User::factory()->editUsers()->checkinAssets()->create())
->post(route('users/bulksave'), [
'ids' => [
$userA->id,
@@ -196,7 +196,7 @@ class BulkDeleteUsersTest extends TestCase
$lonelyLicenseSeat = LicenseSeat::factory()->assignedToUser($userB)->create();
$licenseSeatForUserC = LicenseSeat::factory()->assignedToUser($userC)->create();
$this->actingAs(User::factory()->editUsers()->create())
$this->actingAs(User::factory()->editUsers()->checkinLicenses()->create())
->post(route('users/bulksave'), [
'ids' => [
$userA->id,