function EntityReferenceFormatterTest::testIdFormatter
Same name in other branches
- 9 core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php \Drupal\Tests\field\Kernel\EntityReference\EntityReferenceFormatterTest::testIdFormatter()
- 10 core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php \Drupal\Tests\field\Kernel\EntityReference\EntityReferenceFormatterTest::testIdFormatter()
- 11.x core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php \Drupal\Tests\field\Kernel\EntityReference\EntityReferenceFormatterTest::testIdFormatter()
Tests the ID formatter.
File
-
core/
modules/ field/ tests/ src/ Kernel/ EntityReference/ EntityReferenceFormatterTest.php, line 187
Class
- EntityReferenceFormatterTest
- Tests the formatters functionality.
Namespace
Drupal\Tests\field\Kernel\EntityReferenceCode
public function testIdFormatter() {
$formatter = 'entity_reference_entity_id';
$build = $this->buildRenderArray([
$this->referencedEntity,
$this->unsavedReferencedEntity,
], $formatter);
$this->assertEqual($build[0]['#plain_text'], $this->referencedEntity
->id(), sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter));
$this->assertEqual($build[0]['#cache']['tags'], $this->referencedEntity
->getCacheTags(), sprintf('The %s formatter has the expected cache tags.', $formatter));
$this->assertTrue(!isset($build[1]), sprintf('The markup returned by the %s formatter is correct for an item with a unsaved entity.', $formatter));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.