function EntityDisplayBaseTest::testChangeId
Tests that changing the entity ID updates related properties.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityDisplayBaseTest.php, line 177
Class
- EntityDisplayBaseTest
- @coversDefaultClass \Drupal\Core\Entity\EntityDisplayBase
Namespace
Drupal\KernelTests\Core\EntityCode
public function testChangeId() : void {
/** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */
$display = $this->container
->get(EntityDisplayRepositoryInterface::class)
->getViewDisplay('entity_test', 'entity_test');
$this->assertSame('entity_test.entity_test.default', $display->id());
$display->set('id', 'node.page.rss');
$this->assertSame('node', $display->getTargetEntityTypeId());
$this->assertSame('page', $display->getTargetBundle());
$this->assertSame('rss', $display->getMode());
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage("'a.b' is not a valid entity display ID.");
$display->set('id', 'a.b');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.