Skip to content

Commit c30dd60

Browse files
add unit test
1 parent ab74f29 commit c30dd60

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\Framework\View\Element\AbstractBlock;
2020
use Magento\Framework\View\Element\Template;
2121
use Magento\Framework\View\Layout;
22+
use Magento\Framework\View\Layout\BuilderInterface;
2223
use Magento\Framework\View\Layout\Data\Structure as LayoutStructure;
2324
use Magento\Framework\View\Layout\Element;
2425
use Magento\Framework\View\Layout\Generator\Block;
@@ -1169,4 +1170,27 @@ public function renderElementDisplayDataProvider(): array
11691170
[null],
11701171
];
11711172
}
1173+
1174+
/**
1175+
* Test render element with exception
1176+
*
1177+
* @return void
1178+
*/
1179+
public function testRenderNonCachedElementWithException(): void
1180+
{
1181+
$exception = new \Exception('Error message');
1182+
1183+
$builderMock = $this->createMock(BuilderInterface::class);
1184+
$builderMock->expects($this->once())
1185+
->method('build')
1186+
->willThrowException($exception);
1187+
1188+
$this->loggerMock->expects($this->once())
1189+
->method('critical')
1190+
->with($exception);
1191+
1192+
$model = clone $this->model;
1193+
$model->setBuilder($builderMock);
1194+
$model->renderNonCachedElement('test_container');
1195+
}
11721196
}

0 commit comments

Comments
 (0)