## Summary - implement the canonical shared fixture profile model with minimal, standard, and full semantics plus temporary legacy alias resolution - slim default factory behavior for operation runs, backup sets, provider connections, and provider credentials while keeping explicit heavy opt-in states - migrate the first console, navigation, RBAC, and drift caller packs to explicit lean helpers and wire lane comparison reporting into the existing Spec 206 seams - reconcile spec 207 docs, contracts, quickstart guidance, and task tracking with the implemented behavior ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Unit/Support/CreateUserWithTenantProfilesTest.php tests/Unit/Factories/TenantFactoryTest.php tests/Unit/Factories/OperationRunFactoryTest.php tests/Unit/Factories/BackupSetFactoryTest.php tests/Unit/Factories/ProviderConnectionFactoryTest.php tests/Unit/Factories/ProviderCredentialFactoryTest.php tests/Feature/Guards/FixtureCostProfilesGuardTest.php tests/Feature/Guards/FixtureLaneImpactBudgetTest.php tests/Feature/Guards/TestLaneArtifactsContractTest.php tests/Feature/Console/ReconcileOperationRunsCommandTest.php tests/Feature/Console/ReconcileBackupScheduleOperationRunsCommandTest.php tests/Feature/Navigation/RelatedNavigationResolverMemoizationTest.php tests/Feature/Spec080WorkspaceManagedTenantAdminMigrationTest.php tests/Feature/BaselineDriftEngine/FindingFidelityTest.php` - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` - `./scripts/platform-test-lane fast-feedback` - `./scripts/platform-test-lane confidence` - `./scripts/platform-test-report fast-feedback` - `./scripts/platform-test-report confidence` ## Lane outcome - `fast-feedback`: 136.400761s vs 176.73623s baseline, status `improved` - `confidence`: 394.5669s vs 394.383441s baseline, status `stable` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #240
114 lines
3.2 KiB
PHP
114 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\BackupItem;
|
|
use App\Models\Tenant;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\BackupSet>
|
|
*/
|
|
class BackupSetFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'tenant_id' => Tenant::factory(),
|
|
'name' => fake()->words(3, true),
|
|
'created_by' => fake()->email(),
|
|
'status' => 'completed',
|
|
'item_count' => 0,
|
|
'completed_at' => now(),
|
|
'metadata' => [],
|
|
];
|
|
}
|
|
|
|
public function minimal(): static
|
|
{
|
|
return $this->state(fn (): array => [
|
|
'item_count' => 0,
|
|
'metadata' => [],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $itemAttributes
|
|
*/
|
|
public function withItems(int $count = 1, array $itemAttributes = []): static
|
|
{
|
|
$count = max(1, $count);
|
|
|
|
return $this->state(fn (): array => [
|
|
'item_count' => $count,
|
|
])->afterCreating(function ($backupSet) use ($count, $itemAttributes): void {
|
|
BackupItem::factory()
|
|
->count($count)
|
|
->for($backupSet->tenant)
|
|
->for($backupSet)
|
|
->create(array_merge([
|
|
'payload' => ['id' => 'backup-item-'.fake()->uuid()],
|
|
'metadata' => [],
|
|
'assignments' => [],
|
|
], $itemAttributes));
|
|
});
|
|
}
|
|
|
|
public function full(): static
|
|
{
|
|
return $this->recentCompleted()->withItems();
|
|
}
|
|
|
|
public function recentCompleted(): static
|
|
{
|
|
return $this->state(fn (): array => [
|
|
'status' => 'completed',
|
|
'completed_at' => now()->subMinutes(20),
|
|
]);
|
|
}
|
|
|
|
public function staleCompleted(): static
|
|
{
|
|
return $this->state(fn (): array => [
|
|
'status' => 'completed',
|
|
'completed_at' => now()->subDays(2),
|
|
'item_count' => 1,
|
|
])->afterCreating(function ($backupSet): void {
|
|
BackupItem::factory()
|
|
->for($backupSet->tenant)
|
|
->for($backupSet)
|
|
->create([
|
|
'payload' => ['id' => 'stale-backup-item'],
|
|
'metadata' => [],
|
|
'assignments' => [],
|
|
]);
|
|
});
|
|
}
|
|
|
|
public function degradedCompleted(): static
|
|
{
|
|
return $this->state(fn (): array => [
|
|
'status' => 'completed',
|
|
'completed_at' => now()->subMinutes(30),
|
|
'item_count' => 1,
|
|
])->afterCreating(function ($backupSet): void {
|
|
BackupItem::factory()
|
|
->for($backupSet->tenant)
|
|
->for($backupSet)
|
|
->create([
|
|
'payload' => [],
|
|
'metadata' => [
|
|
'source' => 'metadata_only',
|
|
'assignments_fetch_failed' => true,
|
|
],
|
|
'assignments' => [],
|
|
]);
|
|
});
|
|
}
|
|
}
|