2026-04-26 13:06:22 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Tests\Unit\Enums;
|
|
|
|
|
|
|
|
|
|
use App\Enums\CrawlOutcomeEnum;
|
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
|
|
class CrawlOutcomeEnumTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
public function test_all_expected_cases_exist_with_correct_backing_values(): void
|
|
|
|
|
{
|
|
|
|
|
$expected = [
|
|
|
|
|
'Success' => 'success',
|
|
|
|
|
'Failed' => 'failed',
|
|
|
|
|
'Timeout' => 'timeout',
|
|
|
|
|
'BlockedRobots' => 'blocked_robots',
|
|
|
|
|
'Blocked4xx' => 'blocked_4xx',
|
|
|
|
|
'Blocked5xx' => 'blocked_5xx',
|
2026-04-26 16:35:46 +02:00
|
|
|
'Rejected' => 'rejected',
|
2026-04-26 13:06:22 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
foreach ($expected as $caseName => $backingValue) {
|
|
|
|
|
$case = CrawlOutcomeEnum::from($backingValue);
|
|
|
|
|
|
|
|
|
|
$this->assertSame($caseName, $case->name, "Case name for '{$backingValue}' should be '{$caseName}'");
|
|
|
|
|
$this->assertSame($backingValue, $case->value, "Backing value for '{$caseName}' should be '{$backingValue}'");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-26 16:35:46 +02:00
|
|
|
public function test_enum_has_exactly_seven_cases(): void
|
2026-04-26 13:06:22 +02:00
|
|
|
{
|
2026-04-26 16:35:46 +02:00
|
|
|
$this->assertCount(7, CrawlOutcomeEnum::cases());
|
2026-04-26 13:06:22 +02:00
|
|
|
}
|
|
|
|
|
}
|