diff --git a/tests/Unit/Integrations/Divi/Pages/DiviContentComposerTest.php b/tests/Unit/Integrations/Divi/Pages/DiviContentComposerTest.php index 32d7b7d..09848a7 100644 --- a/tests/Unit/Integrations/Divi/Pages/DiviContentComposerTest.php +++ b/tests/Unit/Integrations/Divi/Pages/DiviContentComposerTest.php @@ -177,6 +177,26 @@ final class DiviContentComposerTest extends TestCase self::assertSame([], $this->saved); } + /** Ruling X3: a new entry has no loop scope (nor has a new Theme Builder layout, same LayoutBuilder). */ + public function testNewEntriesRefuseLoopContentWithTheLoopMessage(): void + { + $refused = $this->composer()->check('page', [ + ['type' => 'section', 'modules' => [['type' => 'text', 'content' => '{{loop:post_title}}']]], + ]); + + self::assertInstanceOf(WP_Error::class, $refused); + self::assertStringContainsString('braucht eine Divi-Schleife', implode(' ', self::errorFields($refused))); + + // A new loop container does not open a scope for its content in the same call either. + $inNewLoop = $this->composer()->check('page', [[ + 'type' => 'section', + 'attrs' => ['module.advanced.loop' => ['desktop' => ['enable' => 'on', 'queryType' => 'post_types']]], + 'modules' => [['type' => 'text', 'content' => '{{loop:post_title}}']], + ]]); + self::assertInstanceOf(WP_Error::class, $inNewLoop); + self::assertStringContainsString('braucht eine Divi-Schleife', implode(' ', self::errorFields($inNewLoop))); + } + public function testAFailingSaveIsThrown(): void { $this->saver = Mockery::mock(DiviSaver::class);