function EntityFieldTest::doTestComputedProperties
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php \Drupal\KernelTests\Core\Entity\EntityFieldTest::doTestComputedProperties()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php \Drupal\KernelTests\Core\Entity\EntityFieldTest::doTestComputedProperties()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php \Drupal\KernelTests\Core\Entity\EntityFieldTest::doTestComputedProperties()
Executes the computed properties tests for the given entity type.
Parameters
string $entity_type: The entity type to run the tests with.
1 call to EntityFieldTest::doTestComputedProperties()
- EntityFieldTest::testComputedProperties in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php - Tests getting processed property values via a computed property.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php, line 911
Class
- EntityFieldTest
- Tests the Entity Field API.
Namespace
Drupal\KernelTests\Core\EntityCode
protected function doTestComputedProperties($entity_type) {
$entity = $this->createTestEntity($entity_type);
$entity->field_test_text->value = "The <strong>text</strong> text to filter.";
$entity->field_test_text->format = filter_default_format();
$target = "<p>The <strong>text</strong> text to filter.</p>\n";
$this->assertEquals($target, $entity->field_test_text->processed, new FormattableMarkup('%entity_type: Text is processed with the default filter.', [
'%entity_type' => $entity_type,
]));
// Save and load entity and make sure it still works.
$entity->save();
$entity = $this->container
->get('entity_type.manager')
->getStorage($entity_type)
->load($entity->id());
$this->assertEquals($target, $entity->field_test_text->processed, new FormattableMarkup('%entity_type: Text is processed with the default filter.', [
'%entity_type' => $entity_type,
]));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.