Skip to content

Commit

Permalink
Fix TemplateManagerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
eerison committed Aug 22, 2022
1 parent af3f022 commit 9de96f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Resources/views/layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ file that was distributed with this source code.

{% block sonata_page_breadcrumb %}
<div class="row page-breadcrumb">
{{ sonata_block_render_event('breadcrumb', { 'context': 'page', 'current_uri': app.request.requestUri }) }}
{{ sonata_block_render_event('breadcrumb', { 'context': 'sonata.page.block.breadcrumb', 'current_uri': app.request.requestUri }) }}
</div>
{% endblock %}

Expand Down
30 changes: 16 additions & 14 deletions tests/Page/TemplateManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@

namespace Sonata\PageBundle\Tests\Page;

use Sonata\PageBundle\CmsManager\CmsSnapshotManager;
use Sonata\PageBundle\Model\PageInterface;
use Sonata\PageBundle\Model\SnapshotManagerInterface;
use Sonata\PageBundle\Model\Template;
use Sonata\PageBundle\Model\TransformerInterface;
use Sonata\PageBundle\Page\TemplateManager;
use Sonata\PageBundle\Tests\App\AppKernel;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Twig\Environment;

final class TemplateManagerTest extends KernelTestCase
Expand Down Expand Up @@ -136,11 +144,6 @@ public function testRenderResponseWithDefaultParameters(): void
);
}

/**
* NEXT_MAJOR: Remove the legacy group.
*
* @group legacy
*/
public function testTemplateShowingBreadcrumbIntoThePage(): void
{
$kernel = self::bootKernel();
Expand All @@ -150,20 +153,22 @@ public function testTemplateShowingBreadcrumbIntoThePage(): void
$requestStack->push(new Request());
$container->set('request_stack', $requestStack);

//Mocking snapshot
// Mocking snapshot
$pageMock = $this->createMock(PageInterface::class);
$pageMock->method('getName')->willReturn('Foo');
$pageMock->method('getParents')->willReturn([]);
$pageMock->method('getUrl')->willReturn('/');

$cmsSnapshotManagerMock = $this->createMock(CmsSnapshotManager::class);
$cmsSnapshotManagerMock->method('getCurrentPage')->willReturn($pageMock);
// Mock Snapshot manager
$snapshotManagerMock = $this->createMock(SnapshotManagerInterface::class);
$transformerMock = $this->createMock(TransformerInterface::class);
$cmsSnapshotManagerMock = new CmsSnapshotManager($snapshotManagerMock, $transformerMock);
$cmsSnapshotManagerMock->setCurrentPage($pageMock);
$container->set('sonata.page.cms.snapshot', $cmsSnapshotManagerMock);

//NEXT_MAJOR: change for twig
$templating = $container->get('templating');
$twig = $container->get('twig');

$manager = new TemplateManager($templating, []);
$manager = new TemplateManager($twig, []);
$response = $manager->renderResponse('test');
$crawler = new Crawler($response->getContent());

Expand All @@ -179,9 +184,6 @@ protected static function getKernelClass(): string
return AppKernel::class;
}

/**
* Returns the mock template.
*/
private function getTemplate(string $name, string $path = 'path/to/file'): Template
{
return new Template($name, $path);
Expand Down

0 comments on commit 9de96f2

Please sign in to comment.