mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Very basic checkin tests
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
cd7f276c40
commit
e8ec11652f
|
@ -2,10 +2,15 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\Component;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\Location;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use App\Models\Supplier;
|
||||
|
||||
|
@ -97,5 +102,16 @@ class ComponentFactory extends Factory
|
|||
});
|
||||
}
|
||||
|
||||
public function checkedOutToAsset(Asset $asset = null)
|
||||
{
|
||||
return $this->afterCreating(function (Component $component) use ($asset) {
|
||||
$component->assets()->attach($component->id, [
|
||||
'component_id' => $component->id,
|
||||
'created_at' => Carbon::now(),
|
||||
'user_id' => 1,
|
||||
'asset_id' => $asset->id ?? Asset::factory()->create()->id,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
21
tests/Feature/Checkins/Ui/ComponentCheckinTest.php
Normal file
21
tests/Feature/Checkins/Ui/ComponentCheckinTest.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?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();
|
||||
}
|
||||
|
||||
|
||||
}
|
21
tests/Feature/Checkins/Ui/LicenseCheckinTest.php
Normal file
21
tests/Feature/Checkins/Ui/LicenseCheckinTest.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Checkins\Ui;
|
||||
|
||||
use App\Models\LicenseSeat;
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LicenseCheckinTest extends TestCase
|
||||
{
|
||||
public function testCheckingInLicenseRequiresCorrectPermission()
|
||||
{
|
||||
$this->actingAs(User::factory()->create())
|
||||
->post(route('licenses.checkin.save', [
|
||||
'licenseId' => LicenseSeat::factory()->assignedToUser()->create()->id,
|
||||
]))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in a new issue