Skip to content
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

Avoid using pager if not needed #2041

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Block/GalleryListBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function execute(BlockContextInterface $blockContext, ?Response $response
$order = $blockContext->getSetting('order');
\assert(\is_string($order));
$sortDirection = $blockContext->getSetting('sort');
\assert(\is_string($sortDirection));
\assert(\is_string($sortDirection) && \in_array($sortDirection, ['asc', 'desc'], true));
jordisala1991 marked this conversation as resolved.
Show resolved Hide resolved
$template = $blockContext->getTemplate();
\assert(\is_string($template));

Expand Down
6 changes: 2 additions & 4 deletions tests/Block/GalleryListBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Sonata\BlockBundle\Block\BlockContext;
use Sonata\BlockBundle\Model\Block;
use Sonata\BlockBundle\Test\BlockServiceTestCase;
use Sonata\DatagridBundle\Pager\PagerInterface;
use Sonata\MediaBundle\Block\GalleryListBlockService;
use Sonata\MediaBundle\Model\GalleryManagerInterface;
use Sonata\MediaBundle\Provider\Pool;
Expand All @@ -44,8 +43,7 @@ protected function setUp(): void

public function testExecute(): void
{
$pager = $this->createMock(PagerInterface::class);
$this->galleryManager->expects(self::once())->method('getPager')->willReturn($pager);
$this->galleryManager->expects(self::once())->method('findBy')->willReturn([]);

$block = new Block();

Expand All @@ -67,7 +65,7 @@ public function testExecute(): void
->method('render')
->with('@SonataMedia/Block/block_gallery_list.html.twig', [
'context' => $blockContext,
'pager' => $pager,
'galleries' => [],
'block' => $block,
'settings' => $settings,
]);
Expand Down