Add failing test for updating asset maintenance

This commit is contained in:
Marcus Moore 2025-03-12 15:38:46 -07:00
parent e439f1f42b
commit ab8f4454d1
No known key found for this signature in database

View file

@ -2,7 +2,9 @@
namespace Tests\Feature\AssetMaintenances\Ui;
use App\Models\Asset;
use App\Models\AssetMaintenance;
use App\Models\Supplier;
use App\Models\User;
use Tests\TestCase;
@ -14,4 +16,43 @@ class EditAssetMaintenanceTest extends TestCase
->get(route('maintenances.edit', AssetMaintenance::factory()->create()->id))
->assertOk();
}
public function testCanUpdateAssetMaintenance()
{
$actor = User::factory()->superuser()->create();
$assetMaintenance = AssetMaintenance::factory()->create();
$asset = Asset::factory()->create();
$supplier = Supplier::factory()->create();
$this->actingAs($actor)
->followingRedirects()
->put(route('maintenances.update', $assetMaintenance->id), [
'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',
]);
}
}