Files
WP-LIT-MCP/tests/Unit/Integrations/Divi/DiviCompatibilityTest.php
T

62 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Divi;
use LIT\MCP\Integrations\Divi\DiviCompatibility;
use LIT\MCP\Integrations\Divi\Release\Call;
use LIT\MCP\Integrations\Divi\Release\Manifest;
use LIT\MCP\Integrations\Divi\Release\ManifestCheck;
use LIT\MCP\Integrations\Divi\Release\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(
Manifest::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 = [Manifest::PAGES, Manifest::LIBRARY, Manifest::THEME_BUILDER, Manifest::DESIGN, Manifest::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);
}
}