mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-24 04:03:34 -08:00
Add test case
This commit is contained in:
parent
6d572424ac
commit
4434de6241
|
@ -92,7 +92,6 @@ class AssetCheckoutController extends Controller
|
|||
$settings = \App\Models\Setting::getSettings();
|
||||
|
||||
// We have to check whether $target->company_id is null here since locations don't have a company yet
|
||||
// @todo: test this
|
||||
if (($settings->full_multiple_companies_support) && ((!is_null($target->company_id)) && (!is_null($asset->company_id)))) {
|
||||
if ($target->company_id != $asset->company_id){
|
||||
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('general.error_user_company'));
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Tests\Feature\Checkouts;
|
|||
|
||||
use App\Events\CheckoutableCheckedOut;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Company;
|
||||
use App\Models\LicenseSeat;
|
||||
use App\Models\Location;
|
||||
use App\Models\Statuslabel;
|
||||
|
@ -169,6 +170,28 @@ class AssetCheckoutTest extends TestCase
|
|||
});
|
||||
}
|
||||
|
||||
public function testCannotCheckoutAcrossCompaniesWhenFullCompanySupportEnabled()
|
||||
{
|
||||
Event::fake([CheckoutableCheckedOut::class]);
|
||||
|
||||
$this->settings->enableMultipleFullCompanySupport();
|
||||
|
||||
$assetCompany = Company::factory()->create();
|
||||
$userCompany = Company::factory()->create();
|
||||
|
||||
$user = User::factory()->for($userCompany)->create();
|
||||
$asset = Asset::factory()->for($assetCompany)->create();
|
||||
|
||||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->post(route('hardware.checkout.store', $asset), [
|
||||
'checkout_to_type' => 'user',
|
||||
'assigned_user' => $user->id,
|
||||
])
|
||||
->assertRedirect(route('hardware.checkout.store', $asset));
|
||||
|
||||
Event::assertNotDispatched(CheckoutableCheckedOut::class);
|
||||
}
|
||||
|
||||
public function testLicenseSeatsAreAssignedToUserUponCheckout()
|
||||
{
|
||||
$asset = Asset::factory()->create();
|
||||
|
|
Loading…
Reference in a new issue