function UserFieldValueTest::testFastPathFallsBackToInitializedFieldObjects

Same name and namespace in other branches
  1. main core/modules/user/tests/src/Kernel/UserFieldValueTest.php \Drupal\Tests\user\Kernel\UserFieldValueTest::testFastPathFallsBackToInitializedFieldObjects()

Tests that the fast path falls back to initialized field objects.

File

core/modules/user/tests/src/Kernel/UserFieldValueTest.php, line 56

Class

UserFieldValueTest
Tests fast scalar field access on the user entity.

Namespace

Drupal\Tests\user\Kernel

Code

public function testFastPathFallsBackToInitializedFieldObjects() : void {
  $user = User::create([
    'name' => 'initial-name',
    'mail' => 'initial@example.com',
  ]);
  $user->get('name')->value = 'updated-name';
  $user->get('status')->value = 0;
  $user->get('access')->value = 987654321;
  $user->get('timezone')->value = 'UTC';
  $this->assertSame('updated-name', $user->getAccountName());
  $this->assertFalse($user->isActive());
  $this->assertSame('UTC', $user->getTimeZone());
  $this->assertEquals($user->get('access')->value, $user->getLastAccessedTime());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.