Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?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
|
||
));
|