Add failing test for creating asset maintenance

This commit is contained in:
Marcus Moore 2025-03-12 15:35:14 -07:00
parent 824271078e
commit 9be27bdf07
No known key found for this signature in database

View file

@ -2,6 +2,8 @@
namespace Tests\Feature\AssetMaintenances\Ui; namespace Tests\Feature\AssetMaintenances\Ui;
use App\Models\Asset;
use App\Models\Supplier;
use App\Models\User; use App\Models\User;
use Tests\TestCase; use Tests\TestCase;
@ -13,4 +15,41 @@ class CreateAssetMaintenanceTest extends TestCase
->get(route('maintenances.create')) ->get(route('maintenances.create'))
->assertOk(); ->assertOk();
} }
public function testCanCreateAssetMaintenance()
{
$actor = User::factory()->superuser()->create();
$asset = Asset::factory()->create();
$supplier = Supplier::factory()->create();
$this->actingAs($actor)
->followingRedirects()
->post(route('maintenances.store'), [
'title' => 'Test Maintenance',
'asset_id' => $asset->id,
'supplier_id' => $supplier->id,
'asset_maintenance_type' => 'Maintenance',
'start_date' => '2021-01-01',
'completion_date' => '2021-01-10',
'is_warranty' => '1',
'cost' => '100.00',
'notes' => 'A note',
])
->assertOk();
$this->assertDatabaseHas('asset_maintenances', [
'asset_id' => $asset->id,
'supplier_id' => $supplier->id,
'asset_maintenance_type' => 'Maintenance',
'title' => 'Test Maintenance',
'is_warranty' => 1,
'start_date' => '2021-01-01',
'completion_date' => '2021-01-10',
'asset_maintenance_time' => '9',
'notes' => 'A note',
'cost' => '100.00',
'created_by' => $actor->id,
]);
}
} }