mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-14 17:44:17 -08:00
a77ece01a6
Signed-off-by: snipe <snipe@snipe.net>
69 lines
2.3 KiB
PHP
69 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Checkins\Ui;
|
|
|
|
use App\Models\Asset;
|
|
use App\Models\Component;
|
|
use App\Models\User;
|
|
use Tests\TestCase;
|
|
|
|
class ComponentsCheckoutTest extends TestCase
|
|
{
|
|
public function testCheckingOutComponentRequiresCorrectPermission()
|
|
{
|
|
$this->actingAs(User::factory()->create())
|
|
->post(route('components.checkout.store', [
|
|
'componentID' => Component::factory()->checkedOutToAsset()->create()->id,
|
|
]))
|
|
->assertForbidden();
|
|
}
|
|
|
|
public function testComponentCheckoutPagePostIsRedirectedIfRedirectSelectionIsIndex()
|
|
{
|
|
$component = Component::factory()->create();
|
|
|
|
$this->actingAs(User::factory()->admin()->create())
|
|
->from(route('components.index'))
|
|
->post(route('components.checkout.store', $component), [
|
|
'asset_id' => Asset::factory()->create()->id,
|
|
'redirect_option' => 'index',
|
|
'assigned_qty' => 1,
|
|
])
|
|
->assertStatus(302)
|
|
->assertRedirect(route('components.index'));
|
|
}
|
|
|
|
public function testComponentCheckoutPagePostIsRedirectedIfRedirectSelectionIsItem()
|
|
{
|
|
$component = Component::factory()->create();
|
|
|
|
$this->actingAs(User::factory()->admin()->create())
|
|
->from(route('components.index'))
|
|
->post(route('components.checkout.store' , $component), [
|
|
'asset_id' => Asset::factory()->create()->id,
|
|
'redirect_option' => 'item',
|
|
'assigned_qty' => 1,
|
|
])
|
|
->assertStatus(302)
|
|
->assertRedirect(route('components.show', ['component' => $component->id]));
|
|
}
|
|
|
|
public function testComponentCheckoutPagePostIsRedirectedIfRedirectSelectionIsTarget()
|
|
{
|
|
$asset = Asset::factory()->create();
|
|
$component = Component::factory()->create();
|
|
|
|
$this->actingAs(User::factory()->admin()->create())
|
|
->from(route('components.index'))
|
|
->post(route('components.checkout.store' , $component), [
|
|
'asset_id' => $asset->id,
|
|
'redirect_option' => 'target',
|
|
'assigned_qty' => 1,
|
|
])
|
|
->assertStatus(302)
|
|
->assertRedirect(route('hardware.show', ['hardware' => $asset]));
|
|
}
|
|
|
|
|
|
}
|