Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
70 lines
2.5 KiB
PHP
70 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Release;
|
|
|
|
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class DiviFeatureTest extends TestCase
|
|
{
|
|
public function testTheThirteenFeaturesAndTheirValues(): void
|
|
{
|
|
self::assertSame(
|
|
[
|
|
'PageRead' => 'page-read',
|
|
'PageWrite' => 'page-write',
|
|
'Catalog' => 'catalog',
|
|
'DynamicSources' => 'dynamic-sources',
|
|
'DesignRead' => 'design-read',
|
|
'PresetWrite' => 'preset-write',
|
|
'ColorWrite' => 'color-write',
|
|
'VariableWrite' => 'variable-write',
|
|
'LibraryRead' => 'library-read',
|
|
'LibraryWrite' => 'library-write',
|
|
'Roles' => 'roles',
|
|
'ThemeBuilderRead' => 'tb-read',
|
|
'ThemeBuilderWrite' => 'tb-write',
|
|
],
|
|
array_column(array_map(
|
|
static fn (DiviFeature $feature): array => [$feature->name, $feature->value],
|
|
DiviFeature::cases()
|
|
), 1, 0)
|
|
);
|
|
}
|
|
|
|
public function testOnlyTheSixWriteFeaturesWrite(): void
|
|
{
|
|
$writing = array_values(array_map(
|
|
static fn (DiviFeature $feature): string => $feature->value,
|
|
array_filter(DiviFeature::cases(), static fn (DiviFeature $feature): bool => $feature->isWrite())
|
|
));
|
|
|
|
self::assertSame(
|
|
['page-write', 'preset-write', 'color-write', 'variable-write', 'library-write', 'tb-write'],
|
|
$writing
|
|
);
|
|
}
|
|
|
|
public function testEveryFeatureHasAUniqueGermanLabel(): void
|
|
{
|
|
$labels = array_map(static fn (DiviFeature $feature): string => $feature->label(), DiviFeature::cases());
|
|
|
|
self::assertCount(count(DiviFeature::cases()), array_unique($labels));
|
|
self::assertSame('Seiten schreiben', DiviFeature::PageWrite->label());
|
|
self::assertSame('Theme Builder lesen', DiviFeature::ThemeBuilderRead->label());
|
|
self::assertSame('Farben schreiben', DiviFeature::ColorWrite->label());
|
|
self::assertSame('Variablen schreiben', DiviFeature::VariableWrite->label());
|
|
foreach ($labels as $label) {
|
|
self::assertNotSame('', trim($label));
|
|
}
|
|
}
|
|
|
|
public function testValuesResolveBackToTheFeature(): void
|
|
{
|
|
self::assertSame(DiviFeature::ThemeBuilderWrite, DiviFeature::from('tb-write'));
|
|
self::assertNull(DiviFeature::tryFrom('page'));
|
|
}
|
|
}
|