-
Notifications
You must be signed in to change notification settings - Fork 19
IBX-3035 [Twig] Allowed passing parameters to ibexa render function
#674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.6
Are you sure you want to change the base?
Changes from all commits
acd8b0c
65e076a
e9c5516
804a8d0
de1c307
262701e
aac7409
dd139bd
483c1f9
489bf31
3616b3a
fb9261d
e7fc356
00e2b90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,13 +13,15 @@ | |||||||||
| use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo; | ||||||||||
| use Ibexa\Contracts\Core\Repository\Values\Content\Location as APILocation; | ||||||||||
| use Ibexa\Core\MVC\Symfony\SiteAccess; | ||||||||||
| use Ibexa\Core\MVC\Symfony\Templating\RenderOptions; | ||||||||||
| use Ibexa\Core\Repository\Values\Content\Content; | ||||||||||
| use Ibexa\Core\Repository\Values\Content\Location; | ||||||||||
| use Ibexa\Core\Repository\Values\Content\VersionInfo; | ||||||||||
| use Ibexa\Tests\Core\Search\TestCase; | ||||||||||
| use Symfony\Component\HttpFoundation\Request; | ||||||||||
| use Symfony\Component\HttpFoundation\RequestStack; | ||||||||||
| use Symfony\Component\HttpFoundation\Response; | ||||||||||
| use Symfony\Component\HttpKernel\Controller\ControllerReference; | ||||||||||
| use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface; | ||||||||||
|
|
||||||||||
| abstract class BaseRenderStrategyTest extends TestCase | ||||||||||
|
|
@@ -52,7 +54,7 @@ public function createFragmentRenderer( | |||||||||
| /** @var string */ | ||||||||||
| private $name; | ||||||||||
|
|
||||||||||
| /** @var string */ | ||||||||||
| /** @var string|null */ | ||||||||||
| private $rendered; | ||||||||||
|
|
||||||||||
| public function __construct( | ||||||||||
|
|
@@ -97,6 +99,58 @@ public function createContent(int $id): APIContent | |||||||||
| ]), | ||||||||||
| ]); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * @param \Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface|\PHPUnit\Framework\MockObject\MockObject $fragmentRendererMock | ||||||||||
| * @param \Ibexa\Contracts\Core\Repository\Values\ValueObject|\PHPUnit\Framework\MockObject\MockObject $valueObjectMock | ||||||||||
|
Comment on lines
+104
to
+105
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| * @param class-string<RenderStrategy> $renderStrategyClass | ||||||||||
| */ | ||||||||||
| public function forwardParamOptionsToFragmentRenderer( | ||||||||||
| object $fragmentRendererMock, | ||||||||||
| object $valueObjectMock, | ||||||||||
| string $renderStrategyClass | ||||||||||
| ): void { | ||||||||||
| $params = [ | ||||||||||
| 'param1' => 'value1', | ||||||||||
| 'param2' => 'value2', | ||||||||||
| ]; | ||||||||||
|
|
||||||||||
| $fragmentRendererMock | ||||||||||
| ->method('getName') | ||||||||||
| ->willReturn('fragment_render_mock'); | ||||||||||
| $fragmentRendererMock->expects(self::once()) | ||||||||||
| ->method('render') | ||||||||||
| ->with( | ||||||||||
| self::callback(static function ($controllerReference) use ($params): bool { | ||||||||||
| if (!$controllerReference instanceof ControllerReference) { | ||||||||||
| return false; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return $controllerReference->attributes['params'] === $params; | ||||||||||
| }), | ||||||||||
| self::anything(), | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either change the assertion or drop it entirely.
Suggested change
|
||||||||||
| ) | ||||||||||
| ->willReturn(new Response('fragment_render_mock_rendered')); | ||||||||||
|
|
||||||||||
| $renderContentStrategy = $this->createRenderStrategy( | ||||||||||
| $renderStrategyClass, | ||||||||||
| [ | ||||||||||
| $fragmentRendererMock, | ||||||||||
| ], | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| /** @var \Ibexa\Contracts\Core\Repository\Values\ValueObject&\PHPUnit\Framework\MockObject\MockObject $valueObjectMock */ | ||||||||||
| TestCase::assertTrue($renderContentStrategy->supports($valueObjectMock)); | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| TestCase::assertSame( | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| 'fragment_render_mock_rendered', | ||||||||||
| $renderContentStrategy->render($valueObjectMock, new RenderOptions([ | ||||||||||
| 'method' => 'fragment_render_mock', | ||||||||||
| 'viewType' => 'awesome', | ||||||||||
| 'params' => $params, | ||||||||||
| ])) | ||||||||||
| ); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| class_alias(BaseRenderStrategyTest::class, 'eZ\Publish\Core\MVC\Symfony\Templating\Tests\BaseRenderStrategyTest'); | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While on it - can we have a strict type here? We hardly skip typing when introducing a new code unless there is a good reason to put mixed.