function EntityFieldValueTraitTest::testGetFieldValueWithScalarValues
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityFieldValueTraitTest.php \Drupal\KernelTests\Core\Entity\EntityFieldValueTraitTest::testGetFieldValueWithScalarValues()
Tests getFieldValue() with scalar values.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldValueTraitTest.php, line 140
Class
- EntityFieldValueTraitTest
- Tests the EntityFieldValueTrait.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testGetFieldValueWithScalarValues() : void {
$account = User::create([
'name' => 'user1',
'status' => 0,
]);
$account->save();
$account = User::load($account->id());
assert($account instanceof User);
// Zero can be stored as '0' or 0 - use loose comparison.
$this->assertEquals(0, $this->getFieldValue($account, 'status', 'value'));
$this->assertSame('user1', $this->getFieldValue($account, 'name', 'value'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.