function SimplePageVariantTest::testBuild
Tests the build method.
@legacy-covers ::build
File
-
core/
tests/ Drupal/ Tests/ Core/ Render/ Plugin/ DisplayVariant/ SimplePageVariantTest.php, line 59
Class
Namespace
Drupal\Tests\Core\Render\Plugin\DisplayVariantCode
public function testBuild() : void {
$title = $this->randomString();
$content = $this->randomString();
$display_variant = $this->setUpDisplayVariant();
$display_variant->setTitle($title);
$display_variant->setMainContent([
'#markup' => $content,
]);
$expected = [
'content' => [
'messages' => [
'#type' => 'status_messages',
'#weight' => -1000,
'#include_fallback' => TRUE,
],
'page_title' => [
'#type' => 'page_title',
'#title' => $title,
'#weight' => -900,
],
'main_content' => [
'#weight' => -800,
'#markup' => $content,
],
],
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => -1,
],
];
$this->assertSame($expected, $display_variant->build());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.