test: Theme Builder fixtures with Pods fields from the real builder (stage3b)
Own fixture pod lit_fixture_person (ruling Q1), template and body layout built through Divi's Theme Builder and Visual Builder UI, brief render with the template limited to one person (Q5), findings 10-12 in the README. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,21 +9,24 @@
|
||||
*
|
||||
* Usage (DDEV, WordPress root):
|
||||
* wp eval-file wp-content/plugins/WP-LIT-MCP/tests/Integration/divi-export-stage3-fixtures.php
|
||||
* wp eval-file wp-content/plugins/WP-LIT-MCP/tests/Integration/divi-export-stage3-fixtures.php stage3b "[Fixture 3b]"
|
||||
* Arguments: target folder below tests/Fixtures/divi (default stage3) and title prefix (default "[Fixture]").
|
||||
*
|
||||
* Only posts titled "[Fixture] …" are exported, plus the Default Website Template when its
|
||||
* Only posts titled "<prefix> …" are exported, plus the Default Website Template when its
|
||||
* layouts are fixture layouts. Read-only. Fixtures are committed – no personal data.
|
||||
* No `declare(strict_types=1);` – wp eval-file runs the file through eval().
|
||||
*/
|
||||
|
||||
defined('WP_CLI') && WP_CLI || exit;
|
||||
|
||||
$lit_prefix = '[Fixture] ';
|
||||
$lit_dir = dirname(__DIR__) . '/Fixtures/divi/stage3';
|
||||
$lit_stage = preg_match('/^[a-z0-9]+$/D', (string) ($args[0] ?? '')) === 1 ? (string) $args[0] : 'stage3';
|
||||
$lit_prefix = (string) ($args[1] ?? '[Fixture]') . ' ';
|
||||
$lit_dir = dirname(__DIR__) . '/Fixtures/divi/' . $lit_stage;
|
||||
$lit_skip_meta = ['_edit_lock', '_edit_last'];
|
||||
|
||||
/** Role name for a fixture post, derived from post type, title and scope. */
|
||||
$lit_role = static function (WP_Post $post, array $terms): string {
|
||||
$slug = sanitize_title(preg_replace('/^\[Fixture\]\s*/', '', $post->post_title));
|
||||
$slug = sanitize_title(preg_replace('/^\[Fixture[^\]]*\]\s*/', '', $post->post_title));
|
||||
$prefix = [
|
||||
'page' => 'page',
|
||||
'et_pb_layout' => in_array('global', array_column($terms['scope'] ?? [], 'slug'), true)
|
||||
@@ -33,6 +36,7 @@ $lit_role = static function (WP_Post $post, array $terms): string {
|
||||
'et_header_layout' => 'tb-header',
|
||||
'et_body_layout' => 'tb-body',
|
||||
'et_footer_layout' => 'tb-footer',
|
||||
'lit_fixture_person' => 'lit_fixture_person',
|
||||
][$post->post_type] ?? $post->post_type;
|
||||
|
||||
return $prefix . '--' . $slug;
|
||||
@@ -85,7 +89,7 @@ $lit_json = static fn (array $data): string => wp_json_encode(
|
||||
) . "\n";
|
||||
|
||||
global $wpdb;
|
||||
$lit_types = ['page', 'et_pb_layout', 'et_template', 'et_header_layout', 'et_body_layout', 'et_footer_layout'];
|
||||
$lit_types = ['page', 'et_pb_layout', 'et_template', 'et_header_layout', 'et_body_layout', 'et_footer_layout', 'lit_fixture_person'];
|
||||
$lit_ids = array_map('intval', $wpdb->get_col($wpdb->prepare(
|
||||
"SELECT ID FROM {$wpdb->posts}
|
||||
WHERE post_type IN (" . implode(', ', array_fill(0, count($lit_types), '%s')) . ")
|
||||
@@ -113,7 +117,11 @@ foreach ($lit_tb_templates as $templateId) {
|
||||
}
|
||||
|
||||
if ($lit_ids === []) {
|
||||
WP_CLI::error('No "[Fixture] " posts found – create them first (see tests/Fixtures/divi/stage3/README.md).');
|
||||
WP_CLI::error(sprintf(
|
||||
'No "%s" posts found – create them first (see tests/Fixtures/divi/%s/README.md).',
|
||||
$lit_prefix,
|
||||
$lit_stage
|
||||
));
|
||||
}
|
||||
|
||||
if (! is_dir($lit_dir) && ! wp_mkdir_p($lit_dir)) {
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Creates or removes the Pods test content type "lit_person" for integration tests.
|
||||
* Creates or removes the Pods test content type "lit_person" for integration tests, or creates the
|
||||
* permanent Etappe 3b fixture pod "lit_fixture_person" with two persons (tests/Fixtures/divi/stage3b).
|
||||
*
|
||||
* Usage (inside DDEV, Pods must be active):
|
||||
* wp eval-file wp-content/plugins/WP-LIT-MCP/tests/Integration/pods-fixture.php create
|
||||
* wp eval-file wp-content/plugins/WP-LIT-MCP/tests/Integration/pods-fixture.php delete
|
||||
* wp eval-file wp-content/plugins/WP-LIT-MCP/tests/Integration/pods-fixture.php fixture
|
||||
*
|
||||
* "delete" only removes "lit_person"; the fixture pod is kept (smokes never touch it).
|
||||
*
|
||||
* No strict_types: wp eval-file runs this through eval().
|
||||
*/
|
||||
@@ -28,6 +32,72 @@ if ($action === 'delete') {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($action === 'fixture') {
|
||||
// Etappe 3b fixture pod (ruling Q1): its own type, so no smoke deletes the fixture persons.
|
||||
if (! $api->load_pod(['name' => 'lit_fixture_person'])) {
|
||||
$api->save_pod([
|
||||
'name' => 'lit_fixture_person',
|
||||
'label' => '[Fixture] Personen',
|
||||
'label_singular' => '[Fixture] Person',
|
||||
'type' => 'post_type',
|
||||
'storage' => 'meta',
|
||||
'public' => 1,
|
||||
'show_ui' => 1,
|
||||
]);
|
||||
}
|
||||
$fixtureFields = [
|
||||
['name' => 'role', 'label' => 'Funktion', 'type' => 'text'],
|
||||
[
|
||||
'name' => 'level',
|
||||
'label' => 'Stufe',
|
||||
'type' => 'pick',
|
||||
'pick_object' => 'custom-simple',
|
||||
'pick_custom' => "junior|Junior\nsenior|Senior",
|
||||
],
|
||||
[
|
||||
'name' => 'mentor',
|
||||
'label' => 'Mentor',
|
||||
'type' => 'pick',
|
||||
'pick_object' => 'post_type',
|
||||
'pick_val' => 'lit_fixture_person',
|
||||
'pick_format_type' => 'single',
|
||||
],
|
||||
];
|
||||
foreach ($fixtureFields as $field) {
|
||||
if (! $api->load_field(['pod' => 'lit_fixture_person', 'name' => $field['name']])) {
|
||||
$api->save_field(array_merge(['pod' => 'lit_fixture_person'], $field));
|
||||
}
|
||||
}
|
||||
$existing = static function (string $title): int {
|
||||
$found = get_posts([
|
||||
'post_type' => 'lit_fixture_person',
|
||||
'post_status' => 'any',
|
||||
'title' => $title,
|
||||
'fields' => 'ids',
|
||||
'numberposts' => 1,
|
||||
]);
|
||||
|
||||
return (int) ($found[0] ?? 0);
|
||||
};
|
||||
$erika = $existing('[Fixture 3b] Erika Muster') ?: (int) pods('lit_fixture_person')->add([
|
||||
'post_title' => '[Fixture 3b] Erika Muster',
|
||||
'post_content' => '<p>Beitragsinhalt der Fixture-Person Erika Muster.</p>',
|
||||
'post_status' => 'publish',
|
||||
'role' => 'Geschäftsführung',
|
||||
'level' => 'senior',
|
||||
]);
|
||||
$max = $existing('[Fixture 3b] Max Beispiel') ?: (int) pods('lit_fixture_person')->add([
|
||||
'post_title' => '[Fixture 3b] Max Beispiel',
|
||||
'post_content' => '<p>Beitragsinhalt der Fixture-Person Max Beispiel.</p>',
|
||||
'post_status' => 'publish',
|
||||
'role' => 'Entwicklung',
|
||||
'level' => 'junior',
|
||||
'mentor' => $erika,
|
||||
]);
|
||||
echo "persons {$erika} {$max}\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $api->load_pod(['name' => 'lit_person'])) {
|
||||
$api->save_pod([
|
||||
'name' => 'lit_person',
|
||||
|
||||
Reference in New Issue
Block a user