mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 22:37:28 -08:00
Scaffold tests around asset checkout via web
This commit is contained in:
parent
21e23baa37
commit
984cc7a4f2
|
@ -46,6 +46,11 @@ class StatuslabelFactory extends Factory
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function readyToDeploy()
|
||||||
|
{
|
||||||
|
return $this->rtd();
|
||||||
|
}
|
||||||
|
|
||||||
public function pending()
|
public function pending()
|
||||||
{
|
{
|
||||||
return $this->state(function () {
|
return $this->state(function () {
|
||||||
|
|
73
tests/Feature/Checkouts/AssetCheckoutTest.php
Normal file
73
tests/Feature/Checkouts/AssetCheckoutTest.php
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Checkouts;
|
||||||
|
|
||||||
|
use App\Events\CheckoutableCheckedOut;
|
||||||
|
use App\Models\Asset;
|
||||||
|
use App\Models\Statuslabel;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
|
use Tests\Support\InteractsWithSettings;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AssetCheckoutTest extends TestCase
|
||||||
|
{
|
||||||
|
use InteractsWithSettings;
|
||||||
|
|
||||||
|
public function testCheckingOutAssetRequiresCorrectPermission()
|
||||||
|
{
|
||||||
|
$this->actingAs(User::factory()->create())
|
||||||
|
->post(route('hardware.checkout.store', Asset::factory()->create()), [
|
||||||
|
'checkout_to_type' => 'user',
|
||||||
|
'assigned_user' => User::factory()->create()->id,
|
||||||
|
])
|
||||||
|
->assertForbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testValidationWhenCheckingOutAsset()
|
||||||
|
{
|
||||||
|
$this->actingAs(User::factory()->create())
|
||||||
|
->post(route('hardware.checkout.store', Asset::factory()->create()), [
|
||||||
|
//
|
||||||
|
])
|
||||||
|
->assertSessionHasErrors();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAnAssetCanBeCheckedOutToAUser()
|
||||||
|
{
|
||||||
|
$this->markTestIncomplete();
|
||||||
|
|
||||||
|
Event::fake([CheckoutableCheckedOut::class]);
|
||||||
|
|
||||||
|
$status = Statuslabel::factory()->readyToDeploy()->create();
|
||||||
|
$asset = Asset::factory()->create();
|
||||||
|
$admin = User::factory()->create();
|
||||||
|
$user = User::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAs($admin)
|
||||||
|
->post(route('hardware.checkout.store', $asset), [
|
||||||
|
'checkout_to_type' => 'user',
|
||||||
|
'assigned_user' => $user->id,
|
||||||
|
'name' => 'Changed Name',
|
||||||
|
'status_id' => $status->id,
|
||||||
|
'checkout_at' => '2024-03-18',
|
||||||
|
'expected_checkin' => '2024-03-28',
|
||||||
|
'note' => 'An awesome note',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// @todo: assert CheckoutableCheckedOut dispatched with correct data
|
||||||
|
Event::assertDispatched(CheckoutableCheckedOut::class);
|
||||||
|
|
||||||
|
// @todo: assert action log entry created
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAnAssetCanBeCheckedOutToAnAsset()
|
||||||
|
{
|
||||||
|
$this->markTestIncomplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAnAssetCanBeCheckedOutToALocation()
|
||||||
|
{
|
||||||
|
$this->markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue