docs/test: S36-Hinweise abgelöst (X5); loopFields() in VariableRef gepinnt
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
f8912c255d
commit
5ee846e63d
@@ -101,7 +101,7 @@ final class DynamicContentMapTest extends TestCase
|
||||
// enable_html stays forbidden even though the registry lists it.
|
||||
$html = $ref('post_meta_key', ['enable_html' => 'on']);
|
||||
self::assertRejected(static fn () => $references->canonical($html, $sanitizer), 'enable_html');
|
||||
// Loop content: Divi offers it only inside loops – never through the tools.
|
||||
// Loop content needs a Divi loop of its kind (ruling X5) – this VariableRef has none.
|
||||
$loop = $ref('loop_post_title', []);
|
||||
self::assertRejected(static fn () => $references->canonical($loop, $sanitizer), 'Schleifen');
|
||||
}
|
||||
@@ -276,6 +276,36 @@ final class DynamicContentMapTest extends TestCase
|
||||
self::assertArrayNotHasKey('loop_post_meta_key_manual_custom_field', $map->loopFields(LoopScope::USER));
|
||||
}
|
||||
|
||||
/** The map a loop composition builds (Task 4): forPost() + loopFields() of the loop's kind. */
|
||||
public function testLoopFieldsWorkInVariableRefInsideALoopOfTheirKind(): void
|
||||
{
|
||||
$map = new DynamicContentMap(static fn (int $id): array => DiviFixtures::dynamicContentRegistry());
|
||||
$terms = LoopScope::ofQueryType('post_taxonomies');
|
||||
$references = new VariableRef(
|
||||
DiviFixtures::designSystem(),
|
||||
(array) $map->forPost(831) + $map->loopFields((string) $terms->kind(), 831),
|
||||
$terms
|
||||
);
|
||||
$sanitizer = ComposeFixture::sanitizer();
|
||||
$ref = static fn (string $name, array $settings): string => VariableRef::serialize('content', $name, $settings);
|
||||
|
||||
$name = $ref('loop_term_name', ['before' => 'Kategorie: ', 'after' => '', 'loop_position' => '']);
|
||||
self::assertSame($name, $references->canonical($name, $sanitizer));
|
||||
$title = $ref('post_title', ['before' => '', 'after' => '']);
|
||||
self::assertSame($title, $references->canonical($title, $sanitizer));
|
||||
self::assertRejected(
|
||||
static fn () => $references->canonical($ref('loop_post_title', []), $sanitizer),
|
||||
'passt nicht zur Schleife dieses Elements (Typ: Terme)'
|
||||
);
|
||||
self::assertRejected(
|
||||
static fn () => $references->canonical(
|
||||
$ref('loop_term_meta_key_manual_custom_field', ['enable_html' => 'on']),
|
||||
$sanitizer
|
||||
),
|
||||
'enable_html'
|
||||
);
|
||||
}
|
||||
|
||||
public function testLoopFieldsReadTheRegistryOfThePostAndAreEmptyWithoutIt(): void
|
||||
{
|
||||
$seen = [];
|
||||
|
||||
Reference in New Issue
Block a user