141 lines
3.9 KiB
PHP
141 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\BackupSet;
|
|
use App\Models\Tenant;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\RestoreRun>
|
|
*/
|
|
class RestoreRunFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'tenant_id' => Tenant::factory(),
|
|
'backup_set_id' => BackupSet::factory(),
|
|
'status' => 'completed',
|
|
'is_dry_run' => false,
|
|
'requested_items' => [],
|
|
'preview' => [],
|
|
'results' => [],
|
|
'metadata' => [],
|
|
'group_mapping' => null,
|
|
'started_at' => now()->subHour(),
|
|
'completed_at' => now(),
|
|
];
|
|
}
|
|
|
|
public function previewOnly(): static
|
|
{
|
|
return $this->state(fn (): array => [
|
|
'status' => 'previewed',
|
|
'is_dry_run' => true,
|
|
'preview' => [
|
|
[
|
|
'policy_identifier' => 'preview-policy',
|
|
'policy_type' => 'deviceConfiguration',
|
|
'platform' => 'windows',
|
|
'action' => 'update',
|
|
],
|
|
],
|
|
'results' => [],
|
|
'metadata' => [],
|
|
'completed_at' => null,
|
|
]);
|
|
}
|
|
|
|
public function failedOutcome(): static
|
|
{
|
|
return $this->state(fn (): array => [
|
|
'status' => 'failed',
|
|
'is_dry_run' => false,
|
|
'results' => [
|
|
'foundations' => [],
|
|
'items' => [
|
|
[
|
|
'status' => 'failed',
|
|
'policy_identifier' => 'failed-policy',
|
|
],
|
|
],
|
|
],
|
|
'metadata' => [],
|
|
'completed_at' => now(),
|
|
]);
|
|
}
|
|
|
|
public function partialOutcome(): static
|
|
{
|
|
return $this->state(fn (): array => [
|
|
'status' => 'completed',
|
|
'is_dry_run' => false,
|
|
'results' => [
|
|
'foundations' => [],
|
|
'items' => [
|
|
[
|
|
'status' => 'partial',
|
|
'policy_identifier' => 'partial-policy',
|
|
],
|
|
],
|
|
],
|
|
'metadata' => [],
|
|
'completed_at' => now(),
|
|
]);
|
|
}
|
|
|
|
public function completedWithFollowUp(): static
|
|
{
|
|
return $this->state(fn (): array => [
|
|
'status' => 'completed',
|
|
'is_dry_run' => false,
|
|
'results' => [
|
|
'foundations' => [],
|
|
'items' => [
|
|
[
|
|
'status' => 'applied',
|
|
'policy_identifier' => 'follow-up-policy',
|
|
'assignment_outcomes' => [
|
|
['status' => 'skipped', 'assignment' => []],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
'metadata' => [
|
|
'non_applied' => 1,
|
|
],
|
|
'completed_at' => now(),
|
|
]);
|
|
}
|
|
|
|
public function completedOutcome(): static
|
|
{
|
|
return $this->state(fn (): array => [
|
|
'status' => 'completed',
|
|
'is_dry_run' => false,
|
|
'results' => [
|
|
'foundations' => [],
|
|
'items' => [
|
|
[
|
|
'status' => 'applied',
|
|
'policy_identifier' => 'completed-policy',
|
|
'assignment_outcomes' => [
|
|
['status' => 'success', 'assignment' => []],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
'metadata' => [
|
|
'non_applied' => 0,
|
|
],
|
|
'completed_at' => now(),
|
|
]);
|
|
}
|
|
}
|