Requirement, Call, ConstantRequirement, Mirror, Problem, FeatureStatus, CompatibilityMatrix, Manifest, ManifestCheck sowie Fingerprints und LineDiff liegen jetzt im divi-freien Kern. Neu: GlobalRequirement, CompatibilityMatrix::fromProblems(), ManifestCheck-Option signatures, DiviManifestCheck::create() und DiviAreas. Divi-Verhalten unverändert. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
2.1 KiB
PHP
63 lines
2.1 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace LIT\MCP\Tests\Unit\Integrations\Divi;
|
||
|
||
use LIT\MCP\Integrations\Divi\DiviCompatibility;
|
||
use LIT\MCP\Compatibility\Call;
|
||
use LIT\MCP\Integrations\Divi\Release\DiviAreas;
|
||
use LIT\MCP\Compatibility\Manifest;
|
||
use LIT\MCP\Compatibility\ManifestCheck;
|
||
use LIT\MCP\Compatibility\Mirror;
|
||
use PHPUnit\Framework\TestCase;
|
||
use RuntimeException;
|
||
|
||
final class DiviCompatibilityTest extends TestCase
|
||
{
|
||
public function testListsFailedAndThrowingChecks(): void
|
||
{
|
||
$compatibility = new DiviCompatibility([
|
||
'A' => static fn (): bool => true,
|
||
'B' => static fn (): bool => false,
|
||
'C' => static function (): bool {
|
||
throw new RuntimeException('Divi changed');
|
||
},
|
||
]);
|
||
|
||
self::assertSame(['B', 'C'], $compatibility->problems());
|
||
}
|
||
|
||
public function testDefaultsAreCodeRegistrationsAndFingerprints(): void
|
||
{
|
||
$check = new ManifestCheck(
|
||
['X' => new Manifest(
|
||
DiviAreas::LIBRARY,
|
||
calls: [new Call('strlen', 1)],
|
||
postTypes: ['et_pb_layout'],
|
||
mirrors: [new Mirror('m', 'a.php', 'a', null, 'Terme')]
|
||
)],
|
||
[],
|
||
static fn (): ?string => null,
|
||
static fn (): bool => true
|
||
);
|
||
|
||
self::assertSame(
|
||
['Bibliothek: strlen()', 'Bibliothek: Post-Typ et_pb_layout', 'Bibliothek: Nachbau von a() – Terme'],
|
||
array_keys(DiviCompatibility::defaults($check))
|
||
);
|
||
}
|
||
|
||
public function testRealDefaultsCoverEveryAdapterArea(): void
|
||
{
|
||
$labels = implode("\n", array_keys(DiviCompatibility::defaults()));
|
||
|
||
$areas = [DiviAreas::PAGES, DiviAreas::LIBRARY, DiviAreas::THEME_BUILDER, DiviAreas::DESIGN, DiviAreas::CATALOG];
|
||
foreach ($areas as $area) {
|
||
self::assertStringContainsString($area . ': ', $labels);
|
||
}
|
||
self::assertStringContainsString('Theme Builder: Nachbau von et_theme_builder_api_save()', $labels);
|
||
self::assertStringContainsString('Katalog: Block-Typ divi/global-layout', $labels);
|
||
}
|
||
}
|