Scaffold tests around accessory check in

This commit is contained in:
Marcus Moore 2024-02-12 12:54:48 -08:00
parent 65e20282b6
commit 095a7d9b34
No known key found for this signature in database
2 changed files with 48 additions and 0 deletions

View file

@ -8,6 +8,7 @@ use App\Models\Location;
use App\Models\Manufacturer;
use App\Models\Supplier;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;
class AccessoryFactory extends Factory
@ -140,4 +141,16 @@ class AccessoryFactory extends Factory
$accessory->category->update(['require_acceptance' => 1]);
});
}
public function checkedOut()
{
return $this->afterCreating(function (Accessory $accessory) {
$accessory->users()->attach($accessory->id, [
'accessory_id' => $accessory->id,
'created_at' => Carbon::now(),
'user_id' => 1,
'assigned_to' => User::factory()->create()->id,
]);
});
}
}

View file

@ -0,0 +1,35 @@
<?php
namespace Tests\Feature\Checkins;
use App\Models\Accessory;
use App\Models\User;
use Tests\Support\InteractsWithSettings;
use Tests\TestCase;
class AccessoryCheckinTest extends TestCase
{
use InteractsWithSettings;
public function testCheckingInAccessoryRequiresCorrectPermission()
{
$this->actingAs(User::factory()->create())
->post(route('accessories.checkin.store', Accessory::factory()->checkedOut()->create()))
->assertForbidden();
}
public function testAccessoryCanBeCheckedIn()
{
$this->markTestIncomplete();
}
public function testEmailSentToUserIfSettingEnabled()
{
$this->markTestIncomplete();
}
public function testEmailNotSentToUserIfSettingDisabled()
{
$this->markTestIncomplete();
}
}