function BlockComponentRenderArrayTest::testOnBuildRenderNoBlock
Same name in other branches
- 9 core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php \Drupal\Tests\layout_builder\Unit\BlockComponentRenderArrayTest::testOnBuildRenderNoBlock()
- 8.9.x core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php \Drupal\Tests\layout_builder\Unit\BlockComponentRenderArrayTest::testOnBuildRenderNoBlock()
- 11.x core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php \Drupal\Tests\layout_builder\Unit\BlockComponentRenderArrayTest::testOnBuildRenderNoBlock()
@covers ::onBuildRender
File
-
core/
modules/ layout_builder/ tests/ src/ Unit/ BlockComponentRenderArrayTest.php, line 505
Class
- BlockComponentRenderArrayTest
- @coversDefaultClass \Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray @group layout_builder
Namespace
Drupal\Tests\layout_builder\UnitCode
public function testOnBuildRenderNoBlock() : void {
$this->blockManager
->createInstance('some_block_id', [
'id' => 'some_block_id',
])
->willReturn(NULL);
$component = new SectionComponent('some-uuid', 'some-region', [
'id' => 'some_block_id',
]);
$contexts = [];
$in_preview = FALSE;
$event = new SectionComponentBuildRenderArrayEvent($component, $contexts, $in_preview);
$subscriber = new BlockComponentRenderArray($this->account
->reveal());
$expected_build = [];
$expected_cache = [
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => -1,
],
];
$subscriber->onBuildRender($event);
$result = $event->getBuild();
$this->assertEquals($expected_build, $result);
$event->getCacheableMetadata()
->applyTo($result);
$this->assertEquals($expected_cache, $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.