mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-14 17:44:17 -08:00
ff6e6ef88c
Signed-off-by: snipe <snipe@snipe.net>
50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Checkins\Ui;
|
|
|
|
use App\Models\Component;
|
|
use App\Models\User;
|
|
use Tests\TestCase;
|
|
|
|
class ComponentCheckinTest extends TestCase
|
|
{
|
|
public function testCheckingInComponentRequiresCorrectPermission()
|
|
{
|
|
$this->actingAs(User::factory()->create())
|
|
->post(route('components.checkin.store', [
|
|
'componentID' => Component::factory()->checkedOutToAsset()->create()->id,
|
|
]))
|
|
->assertForbidden();
|
|
}
|
|
|
|
public function testAssetCheckinPagePostIsRedirectedIfModelIsInvalid()
|
|
{
|
|
$component = Component::factory()->checkedOutToAsset()->create();
|
|
|
|
$this->actingAs(User::factory()->admin()->create())
|
|
->from(route('components.index'))
|
|
->post(route('components.checkin.store', $component), [
|
|
'redirect_option' => 'index',
|
|
'checkin_qty' => 1,
|
|
])
|
|
->assertStatus(302)
|
|
->assertRedirect(route('components.index'));
|
|
}
|
|
|
|
public function testComponentCheckinPagePostIsRedirectedIfRedirectSelectioonGiven()
|
|
{
|
|
$component = Component::factory()->checkedOutToAsset()->create();
|
|
|
|
$this->actingAs(User::factory()->admin()->create())
|
|
->from(route('components.index'))
|
|
->post(route('components.checkin.store', $component), [
|
|
'redirect_option' => 'item',
|
|
'checkin_qty' => 1,
|
|
])
|
|
->assertStatus(302)
|
|
->assertRedirect(route('components.show', ['component' => $component->id]));
|
|
}
|
|
|
|
|
|
}
|