function EntityFieldValueTraitTest::testGetFieldValueCorrectness
Same name and namespace in other branches
- main core/tests/Drupal/KernelTests/Core/Entity/EntityFieldValueTraitTest.php \Drupal\KernelTests\Core\Entity\EntityFieldValueTraitTest::testGetFieldValueCorrectness()
Tests getFieldValue() returns correct values.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldValueTraitTest.php, line 63
Class
- EntityFieldValueTraitTest
- Tests the EntityFieldValueTrait.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testGetFieldValueCorrectness() : void {
$account = User::create([
'name' => 'user1',
'mail' => 'test@example.com',
'status' => 0,
]);
$account->save();
$account = User::load($account->id());
assert($account instanceof User);
$this->assertSame('user1', $this->getFieldValue($account, 'name', 'value'));
$this->assertSame('test@example.com', $this->getFieldValue($account, 'mail', 'value'));
$this->assertEquals(0, $this->getFieldValue($account, 'status', 'value'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.