public function EntityFieldDefaultValueTest::testDefaultValueCallback in Drupal 8
Same name and namespace 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()
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);
}