feat: lit-divi-move warnt, wenn Schleifen-Inhalte ihre Schleife verlassen oder in eine andere Art kommen (X3, A11)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-19 20:52:53 +02:00
co-authored by Claude Sonnet 5.5
parent 8888d246a9
commit ed6fe12ada
2 changed files with 99 additions and 2 deletions
@@ -221,4 +221,41 @@ final class DiviLoopWriteTest extends DiviWriteAbilityTestCase
self::assertStringContainsString('Typ: Terme', $problems['changes[1].set.content'] ?? '');
self::assertCount(2, $this->saved);
}
public function testMovingLoopContentOutOfItsLoopWarns(): void
{
$out = $this->moveNode([
'id' => 's0.r0.c0.m0', 'parent' => 's0.r0.c2',
]);
self::assertTrue($out['ok'], 'Divi allows the move (A11): a warning, no refusal');
$warnings = implode(' | ', $out['warnings']);
self::assertStringContainsString('loop_post_title', $warnings);
self::assertStringContainsString('außerhalb jeder Divi-Schleife', $warnings);
$other = $this->moveNode([
'id' => 's0.r0.c2.m1', 'parent' => 's0.r0.c1',
]);
self::assertStringContainsString('Typ: Terme (vorher: keine Schleife)', implode(' | ', $other['warnings']));
}
public function testMovesThatKeepTheLoopDoNotWarn(): void
{
// Path IDs are positions: after this move c0 holds [Fest, title, own loop].
$withinLoop = $this->moveNode([
'id' => 's0.r0.c0.m0', 'after' => 's0.r0.c0.m1',
]);
// m0 is the plain text now: nothing to warn about when it leaves the loop.
$plain = $this->moveNode([
'id' => 's0.r0.c0.m0', 'parent' => 's0.r0.c2',
]);
// m1 is the module with its own term loop now: it takes the loop along.
$loopItself = $this->moveNode([
'id' => 's0.r0.c0.m1', 'parent' => 's0.r0.c2',
]);
foreach ([$withinLoop, $plain, $loopItself] as $result) {
self::assertTrue($result['ok'], (string) json_encode($result));
self::assertStringNotContainsString('Schleife', implode(' | ', $result['warnings']));
}
}
}