Skip to content

Commit

Permalink
fixup! IBX-2839: Fix pagination with ez_render_content_query()
Browse files Browse the repository at this point in the history
  • Loading branch information
vidarl committed Jul 1, 2022
1 parent d40089a commit 35b5aee
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
namespace eZ\Publish\Core\MVC\Symfony\Templating\Tests\Twig\Extension;

use eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\QueryRenderingExtension;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;

final class QueryRenderingExtensionTest extends FileSystemTwigIntegrationTestCase
Expand All @@ -22,8 +24,18 @@ protected function getExtensions(): array
return var_export($args, true);
});

$currentRequest = $this->createMock(Request::class);
$currentRequest
->method('get')
->willReturn(1);

$requestStack = $this->createMock(RequestStack::class);
$requestStack
->method('getCurrentRequest')
->willReturn($currentRequest);

return [
new QueryRenderingExtension($fragmentHandler),
new QueryRenderingExtension($fragmentHandler, $requestStack),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ array (
),
'query' =>
array (
'page' => 1,
),
)),
1 => 'inline',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ array (
),
'query' =>
array (
'page' => 1,
),
)),
1 => 'esi',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--TEST--
"ez_render_content_query_b" function
--TEMPLATE--
{{ ez_render_content_query({
'query': {
'query_type': 'LatestBlogPost',
},
'pagination': {
'enabled': true,
'limit': 5,
'page_param' : 'current_page'
},
'template': 'latest_blog_post.html.twig',
}) }}
--DATA--
return array()
--EXPECT--
array (
0 =>
Symfony\Component\HttpKernel\Controller\ControllerReference::__set_state(array(
'controller' => 'ez_query_render::renderQuery',
'attributes' =>
array (
'options' =>
array (
'query' =>
array (
'query_type' => 'LatestBlogPost',
),
'pagination' =>
array (
'enabled' => true,
'limit' => 5,
'page_param' => 'current_page',
),
'template' => 'latest_blog_post.html.twig',
),
),
'query' =>
array (
'current_page' => 1,
),
)),
1 => 'inline',
2 =>
array (
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ array (
),
'query' =>
array (
'page' => 1,
),
)),
1 => 'inline',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ array (
),
'query' =>
array (
'page' => 1,
),
)),
1 => 'esi',
Expand Down

0 comments on commit 35b5aee

Please sign in to comment.