function EntityFieldValueTraitTest::testGetFieldValueViaUserMethods
Same name and namespace in other branches
- main core/tests/Drupal/KernelTests/Core/Entity/EntityFieldValueTraitTest.php \Drupal\KernelTests\Core\Entity\EntityFieldValueTraitTest::testGetFieldValueViaUserMethods()
Tests getFieldValue() via User entity methods.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldValueTraitTest.php, line 43
Class
- EntityFieldValueTraitTest
- Tests the EntityFieldValueTrait.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testGetFieldValueViaUserMethods() : void {
$account = User::create([
'name' => 'user1',
'mail' => 'test@example.com',
'status' => 1,
'timezone' => 'UTC',
]);
$account->save();
$account = User::load($account->id());
assert($account instanceof User);
$this->assertTrue($account->isActive());
$this->assertSame('user1', $account->getAccountName());
$this->assertSame('UTC', $account->getTimeZone());
$this->assertIsNumeric($account->getLastAccessedTime());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.