Files
ephub/tests/Enum/ResourceTypeTest.php
2026-09-17 16:10:34 +02:00

49 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Enum;
use App\Enum\ResourceType;
use PHPUnit\Framework\TestCase;
class ResourceTypeTest extends TestCase
{
/**
* The backing value is what appears in a URL, so it has to survive the round trip -- there
* is deliberately no separate slug mapping to keep in sync.
*/
public function testEveryValueResolvesBackToItsCase(): void
{
foreach (ResourceType::cases() as $type) {
self::assertSame($type, ResourceType::tryFrom($type->value));
}
}
public function testAnUnknownValueResolvesToNothing(): void
{
self::assertNull(ResourceType::tryFrom('bikes'));
}
public function testValuesAreUrlSafe(): void
{
foreach (ResourceType::cases() as $type) {
self::assertMatchesRegularExpression('/^[a-z]+$/', $type->value);
}
}
/**
* Every case must carry the presentation a dashboard tile needs, or adding one would produce
* a broken tile rather than a working one.
*/
public function testEveryCaseIsFullyDescribed(): void
{
foreach (ResourceType::cases() as $type) {
self::assertNotSame('', $type->label());
self::assertNotSame('', $type->plural());
self::assertNotSame('', $type->description());
self::assertStringStartsWith('lucide:', $type->icon());
}
}
}