public function EntityViewBuilderTest::testEntityViewBuilderWeight in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/system/src/Tests/Entity/EntityViewBuilderTest.php \Drupal\system\Tests\Entity\EntityViewBuilderTest::testEntityViewBuilderWeight()
Tests weighting of display components.
File
- core/
modules/ system/ src/ Tests/ Entity/ EntityViewBuilderTest.php, line 182 - Contains \Drupal\system\Tests\Entity\EntityViewBuilderTest.
Class
- EntityViewBuilderTest
- Tests the entity view builder.
Namespace
Drupal\system\Tests\EntityCode
public function testEntityViewBuilderWeight() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = $this->container
->get('renderer');
// Set a weight for the label component.
entity_get_display('entity_test', 'entity_test', 'full')
->setComponent('label', array(
'weight' => 20,
))
->save();
// Create and build a test entity.
$entity_test = $this
->createTestEntity('entity_test');
$view = $this->container
->get('entity.manager')
->getViewBuilder('entity_test')
->view($entity_test, 'full');
$renderer
->renderRoot($view);
// Check that the weight is respected.
$this
->assertEqual($view['label']['#weight'], 20, 'The weight of a display component is respected.');
}