function EntityFieldValueTraitTest::testGetFieldValueFallsBackToInitializedFieldObjects
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityFieldValueTraitTest.php \Drupal\KernelTests\Core\Entity\EntityFieldValueTraitTest::testGetFieldValueFallsBackToInitializedFieldObjects()
Tests getFieldValue() falls back to initialized field objects.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldValueTraitTest.php, line 91
Class
- EntityFieldValueTraitTest
- Tests the EntityFieldValueTrait.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testGetFieldValueFallsBackToInitializedFieldObjects() : void {
$account = User::create([
'name' => 'user1',
'mail' => 'before@example.com',
]);
$account->get('name')->value = 'user2';
$account->get('mail')->value = 'after@example.com';
$account->get('status')->value = 0;
$account->get('timezone')->value = 'UTC';
$this->assertSame('user2', $this->getFieldValue($account, 'name', 'value'));
$this->assertSame('after@example.com', $this->getFieldValue($account, 'mail', 'value'));
$this->assertEquals(0, $this->getFieldValue($account, 'status', 'value'));
$this->assertSame('UTC', $this->getFieldValue($account, 'timezone', 'value'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.