Files
WP-LIT-MCP/tests/Integration/divi-shortform-check.php
2026-09-30 02:21:09 +02:00

34 lines
1.1 KiB
PHP
Raw Permalink 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
/**
* Checks the curated short form against the live Divi catalog: every module exists, every
* field path is a known attribute path, every item type is an allowed child.
* Usage (DDEV, WordPress root): wp eval-file wp-content/plugins/WP-LIT-MCP/tests/Integration/divi-shortform-check.php
* No `declare(strict_types=1);` – wp eval-file runs the file through eval().
*/
defined('WP_CLI') && WP_CLI || exit;
use LIT\MCP\Integrations\Divi\Schema\DiviModules;
use LIT\MCP\Integrations\Divi\Schema\ShortformCheck;
use LIT\MCP\Integrations\Divi\Schema\ShortformMap;
if (! DiviModules::isAvailable()) {
WP_CLI::error('Divi 5 is not active.');
}
$started = microtime(true);
$catalog = (new DiviModules())->catalog();
$problems = ShortformCheck::problems($catalog);
if ($problems !== []) {
WP_CLI::error("Short form does not match the catalog:\n" . implode("\n", $problems));
}
WP_CLI::success(sprintf(
'%d short-form modules match the catalog of %d modules (%.0f ms).',
count(ShortformMap::types()),
count($catalog->names()),
(microtime(true) - $started) * 1000
));