feat: Divi-Fähigkeiten (DiviFeature, Requirement, ConstantRequirement) an Call, Mirror und Manifest; alle acht Adapter getaggt; Tests für Vollständigkeit und die gepinnte Zuordnung
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
e6e0f914ba
commit
392fe7c569
@@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Release;
|
||||
|
||||
use LIT\MCP\Integrations\Divi\Release\Call;
|
||||
use LIT\MCP\Integrations\Divi\Release\ConstantRequirement;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
|
||||
use LIT\MCP\Integrations\Divi\Release\Manifest;
|
||||
use LIT\MCP\Integrations\Divi\Release\Mirror;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -53,4 +55,61 @@ final class ManifestTest extends TestCase
|
||||
);
|
||||
self::assertSame('Bibliothek', $manifest->area);
|
||||
}
|
||||
|
||||
public function testPlainConstantNamesBecomeRequirementsWithALabel(): void
|
||||
{
|
||||
$manifest = new Manifest(
|
||||
Manifest::CATALOG,
|
||||
constants: ['ET_BUILDER_PRODUCT_VERSION', new ConstantRequirement('ET_OTHER', [DiviFeature::Roles])]
|
||||
);
|
||||
|
||||
self::assertSame(
|
||||
['ET_BUILDER_PRODUCT_VERSION', 'ET_OTHER'],
|
||||
array_map(static fn (ConstantRequirement $constant): string => $constant->name, $manifest->constants)
|
||||
);
|
||||
self::assertSame('Konstante ET_OTHER', $manifest->constants[1]->label());
|
||||
self::assertSame([], $manifest->constants[0]->features());
|
||||
self::assertSame([DiviFeature::Roles], $manifest->constants[1]->features());
|
||||
self::assertSame(['ET_BUILDER_PRODUCT_VERSION', 'ET_OTHER'], $manifest->names());
|
||||
}
|
||||
|
||||
public function testRequirementsAreCallsConstantsAndMirrorsInThatOrder(): void
|
||||
{
|
||||
$call = new Call('et_pb_is_allowed', 1);
|
||||
$mirror = new Mirror('m', 'a.php', 'a', null, 'Terme');
|
||||
$manifest = new Manifest(Manifest::LIBRARY, calls: [$call], constants: ['ET_X'], mirrors: [$mirror]);
|
||||
|
||||
$requirements = $manifest->requirements();
|
||||
|
||||
self::assertCount(3, $requirements);
|
||||
self::assertSame($call, $requirements[0]);
|
||||
self::assertSame('Konstante ET_X', $requirements[1]->label());
|
||||
self::assertSame($mirror, $requirements[2]);
|
||||
}
|
||||
|
||||
public function testFeaturesOfPrefersTheOwnFeaturesOverTheManifestDefault(): void
|
||||
{
|
||||
$own = new Call('et_a', null, [DiviFeature::PageWrite, DiviFeature::ThemeBuilderWrite]);
|
||||
$inherited = new Call('et_b');
|
||||
$mirror = new Mirror('m', 'a.php', 'a', null, 'x', [DiviFeature::LibraryWrite]);
|
||||
$manifest = new Manifest(
|
||||
Manifest::PAGES,
|
||||
calls: [$own, $inherited],
|
||||
constants: ['ET_X'],
|
||||
mirrors: [$mirror],
|
||||
features: [DiviFeature::PageRead]
|
||||
);
|
||||
|
||||
self::assertSame([DiviFeature::PageWrite, DiviFeature::ThemeBuilderWrite], $manifest->featuresOf($own));
|
||||
self::assertSame([DiviFeature::PageRead], $manifest->featuresOf($inherited));
|
||||
self::assertSame([DiviFeature::PageRead], $manifest->featuresOf($manifest->constants[0]));
|
||||
self::assertSame([DiviFeature::LibraryWrite], $manifest->featuresOf($mirror));
|
||||
}
|
||||
|
||||
public function testWithoutAnyFeaturesAnEntryHasNone(): void
|
||||
{
|
||||
$call = new Call('et_a');
|
||||
|
||||
self::assertSame([], (new Manifest(Manifest::PAGES, calls: [$call]))->featuresOf($call));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user