function EntityFieldDefaultValueTest::testDefaultValueCallback
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php \Drupal\KernelTests\Core\Entity\EntityFieldDefaultValueTest::testDefaultValueCallback()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php \Drupal\KernelTests\Core\Entity\EntityFieldDefaultValueTest::testDefaultValueCallback()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php \Drupal\KernelTests\Core\Entity\EntityFieldDefaultValueTest::testDefaultValueCallback()
Tests custom default value callbacks.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldDefaultValueTest.php, line 58
Class
- EntityFieldDefaultValueTest
- Tests default values for entity fields.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testDefaultValueCallback() {
$entity = $this->entityTypeManager
->getStorage('entity_test_default_value')
->create();
// The description field has a default value callback for testing, see
// entity_test_field_default_value().
$string = 'description_' . $entity->language()
->getId();
$expected = [
[
'shape' => "shape:0:{$string}",
'color' => "color:0:{$string}",
],
[
'shape' => "shape:1:{$string}",
'color' => "color:1:{$string}",
],
];
$this->assertEqual($entity->description
->getValue(), $expected);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.