feat: Pods fields in Theme Builder bodies checked against the template's post types (E12)
Both forms Divi writes are recognized (ruling Q11): custom_meta_<key> and the dialog form post_meta_key + select_meta_key. Choice fields get a note about the stored value, relation fields name IDs (F4). Only templates the user may edit are checked or named; others are counted (Q21 pattern). Warnings only, also in the dry run of a live body. DynamicFields extracted from lit/divi-dynamic-sources. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@ use LIT\MCP\Integrations\Divi\Pages\DiviInsertAbility;
|
||||
use LIT\MCP\Integrations\Divi\Pages\DiviReplaceTextAbility;
|
||||
use LIT\MCP\Integrations\Divi\Pages\DiviSaver;
|
||||
use LIT\MCP\Integrations\Divi\Pages\DiviWriter;
|
||||
use LIT\MCP\Integrations\Divi\Pages\DynamicFields;
|
||||
use LIT\MCP\Integrations\Divi\Pages\VisibleEdits;
|
||||
use LIT\MCP\Integrations\Divi\ThemeBuilder\Template;
|
||||
use LIT\MCP\Integrations\Divi\ThemeBuilder\ThemeBuilderEdits;
|
||||
@@ -48,7 +49,7 @@ final class DiviWriterThemeBuilderTest extends TestCase
|
||||
}
|
||||
|
||||
/** @param list<Template> $templates */
|
||||
private function writer(array $templates, ?VisibleEdits $visible = null): DiviWriter
|
||||
private function writer(array $templates, ?VisibleEdits $visible = null, ?DynamicFields $fields = null): DiviWriter
|
||||
{
|
||||
$access = ThemeBuilderFixtures::access([], true, ThemeBuilderFixtures::store($templates));
|
||||
|
||||
@@ -58,7 +59,7 @@ final class DiviWriterThemeBuilderTest extends TestCase
|
||||
false,
|
||||
ThemeBuilderFixtures::loader($access),
|
||||
null,
|
||||
$visible === null ? new ThemeBuilderEdits($access) : new ThemeBuilderEdits($access, $visible)
|
||||
new ThemeBuilderEdits($access, $visible ?? new VisibleEdits(), $fields)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -192,4 +193,33 @@ final class DiviWriterThemeBuilderTest extends TestCase
|
||||
self::assertSame(1065, $entry['templates'][0]['id']);
|
||||
self::assertSame([], $this->saved);
|
||||
}
|
||||
|
||||
private static function unknownFields(): DynamicFields
|
||||
{
|
||||
$fields = Mockery::mock(DynamicFields::class);
|
||||
$fields->allows('reason')->andReturn('kein bekanntes Feld dieses Inhaltstyps');
|
||||
$fields->allows('note')->andReturnNull();
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/** E12: an unsuitable field in a body is a warning – saved anyway; the dry run of a live body shows it too. */
|
||||
public function testFieldWarningsInTheResultAndInTheDryRun(): void
|
||||
{
|
||||
$field = ['nodes' => [['type' => 'text', 'content' => '{{field:telefon}}']]];
|
||||
$disabled = ThemeBuilderFixtures::template(1066, ['use_on' => ['singular:post_type:lit_person:all']]);
|
||||
|
||||
$result = (new DiviInsertAbility($this->writer([$disabled], null, self::unknownFields())))
|
||||
->execute($this->insert($this->body, $field));
|
||||
self::assertTrue($result['ok']);
|
||||
self::assertCount(1, $this->saved);
|
||||
self::assertStringContainsString('„telefon“', implode(' ', $result['warnings']));
|
||||
|
||||
$live = ThemeBuilderFixtures::template(1066, ['enabled' => true, 'use_on' => ['singular:post_type:lit_person:all']]);
|
||||
$dry = (new DiviInsertAbility($this->writer([$live], null, self::unknownFields())))
|
||||
->execute($this->insert($this->body, $field));
|
||||
self::assertToolError($dry, 'confirm_required');
|
||||
self::assertStringContainsString('„telefon“', implode(' ', $dry->get_error_data()['warnings']));
|
||||
self::assertCount(1, $this->saved);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user