Skip to content

Commit 99b4ecc

Browse files
committed
Add integration test for page layout handling
1 parent 35f9465 commit 99b4ecc

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
3+
<layout id="loki_test">
4+
<label translate="true">Loki Test</label>
5+
</layout>
6+
</page_layouts>

Test/Integration/Util/Controller/TargetRendererWithCustomPageLayoutTest.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
use Magento\Framework\Module\ModuleList;
66
use Magento\TestFramework\Fixture\AppArea;
77
use Magento\TestFramework\Fixture\AppIsolation;
8+
use Magento\TestFramework\Fixture\Cache;
89
use Magento\TestFramework\Fixture\ComponentsDir;
10+
use PHPUnit\Framework\Attributes\DataProvider;
911
use Yireo\IntegrationTestHelper\Test\Integration\Traits\AssertModuleIsEnabled;
1012
use Yireo\IntegrationTestHelper\Test\Integration\Traits\AssertModuleIsRegistered;
1113
use Magento\Framework\Module\Status as ModuleStatus;
@@ -21,25 +23,37 @@ class TargetRendererWithCustomPageLayoutTest extends AbstractTargetRendererTestC
2123
use AssertModuleIsEnabled;
2224

2325
#[AppIsolation(true)]
24-
public function testCustomPageLayout(): void
26+
#[Cache('all', true)]
27+
#[Cache('layout', false)]
28+
#[DataProvider('getTestData')]
29+
public function testCustomPageLayout(bool $isolated): void
2530
{
26-
//$this->enableModule('LokiTest_CustomPageLayout');
31+
$this->enableModule('LokiTest_CustomPageLayout');
2732

2833
$handles = ['default'];
2934
$pageHandles = ['loki_test'];
3035
$blockName = 'loki-test-block';
31-
$layout = $this->getLayoutLoader()->load($handles, $pageHandles, false);
36+
$layout = $this->getLayoutLoader()->load($handles, $pageHandles, $isolated);
3237

3338
$allBlockNames = array_keys($layout->getAllBlocks());
3439
$this->assertNotEmpty($allBlockNames);
3540

3641
$debugMsg = 'Blocks: '.implode(', ', $allBlockNames);
3742
$this->assertContains($blockName, $allBlockNames, $debugMsg);
3843

39-
$htmlParts = $this->getTargetRenderer()->render($layout, [$blockName], false);
44+
$htmlParts = $this->getTargetRenderer()->render($layout, [$blockName]);
4045
$this->assertNotEmpty($htmlParts);
4146
}
4247

48+
49+
public static function getTestData(): array
50+
{
51+
return [
52+
[false],
53+
[true],
54+
];
55+
}
56+
4357
private function enableModule(string $moduleName = ''): void
4458
{
4559
$this->assertModuleIsRegistered($moduleName);

0 commit comments

Comments
 (0)