diff --git a/tests/bundle/Templating/Twig/EmbeddedItemEditFormExtensionTest.php b/tests/bundle/Templating/Twig/EmbeddedItemEditFormExtensionTest.php new file mode 100644 index 0000000000..7727e7ade4 --- /dev/null +++ b/tests/bundle/Templating/Twig/EmbeddedItemEditFormExtensionTest.php @@ -0,0 +1,100 @@ +createFormFactory(), + $this->createRouter() + ), + ]; + } + + /** + * @dataProvider getLegacyTests + * @group legacy + */ + public function testLegacyIntegration( + $file, + $message, + $condition, + $templates, + $exception, + $outputs, + $deprecation = '' + ): void { + // disable Twig legacy integration test to avoid producing risky warning + self::markTestSkipped('This package does not contain Twig legacy integration test cases'); + } + + protected function getFixturesDir(): string + { + return __DIR__ . '/_fixtures/render_embedded_item_edit_form/'; + } + + private function createEditForm(): FormInterface + { + $editForm = $this->createMock(FormInterface::class); + $editForm + ->expects(self::once()) + ->method('createView') + ->willReturn( + $this->createMock(FormView::class) + ); + + return $editForm; + } + + private function createFormFactory(): FormFactory + { + $formFactory = $this->createMock(FormFactory::class); + $formFactory + ->expects(self::atLeastOnce()) + ->method('contentEdit') + ->with( + new ContentEditData(), + 'embedded_item_edit', + [ + 'action' => self::FORM_ACTION, + ] + ) + ->willReturn($this->createEditForm()); + + return $formFactory; + } + + private function createRouter(): RouterInterface + { + $router = $this->createMock(RouterInterface::class); + $router + ->expects(self::once()) + ->method('generate') + ->with('ibexa.content.edit') + ->willReturn(self::FORM_ACTION); + + return $router; + } +} diff --git a/tests/bundle/Templating/Twig/_fixtures/render_embedded_item_edit_form/ibexa_render_embedded_item_edit_form.test b/tests/bundle/Templating/Twig/_fixtures/render_embedded_item_edit_form/ibexa_render_embedded_item_edit_form.test new file mode 100644 index 0000000000..d6679856e7 --- /dev/null +++ b/tests/bundle/Templating/Twig/_fixtures/render_embedded_item_edit_form/ibexa_render_embedded_item_edit_form.test @@ -0,0 +1,9 @@ +--TEST-- +"ibexa_render_embedded_item_edit_form" function +--TEMPLATE-- +{% set form = ibexa_render_embedded_item_edit_form() %} +{% if form is defined %} YES {% else %} NO {% endif %} +--DATA-- +return []; +--EXPECT-- +YES