public function BlockViewTest::testViewBlock in Collapsiblock 3.x
Same name and namespace in other branches
- 4.x tests/src/Kernel/BlockViewTest.php \Drupal\Tests\collapsiblock\Kernel\BlockViewTest::testViewBlock()
Tests viewing a block.
File
- tests/
src/ Kernel/ BlockViewTest.php, line 44
Class
- BlockViewTest
- Tests viewing blocks with Collapsiblock enabled.
Namespace
Drupal\Tests\collapsiblock\KernelCode
public function testViewBlock() {
$entity = $this->blockStorage
->create([
'id' => 'test_block1',
'theme' => 'stark',
'plugin' => 'test_html',
]);
$entity
->save();
// Test the rendering of a block.
$entity = Block::load('test_block1');
$builder = \Drupal::entityTypeManager()
->getViewBuilder('block');
$build = $builder
->view($entity, 'block');
$expected = [];
$expected[] = '<div id="block-test-block1">';
$expected[] = ' ';
$expected[] = ' ';
$expected[] = ' ';
$expected[] = ' </div>';
$expected[] = '';
$expected_output = implode("\n", $expected);
$this
->assertEquals($expected_output, $this->renderer
->renderRoot($build));
}