Loading core/lib/Drupal/Core/Session/UserSession.php +2 −2 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ class UserSession implements AccountInterface { /** * The Unix timestamp when the user last accessed the site. * * @var string * @var int */ protected $access; Loading Loading @@ -194,7 +194,7 @@ public function getTimeZone() { * {@inheritdoc} */ public function getLastAccessedTime() { return $this->access; return (int) $this->access; } /** Loading core/modules/user/src/Entity/User.php +1 −1 Original line number Diff line number Diff line Loading @@ -289,7 +289,7 @@ public function getCreatedTime() { * {@inheritdoc} */ public function getLastAccessedTime() { return $this->getFieldValue('access', 'value'); return (int) $this->getFieldValue('access', 'value'); } /** Loading core/modules/user/tests/src/Kernel/UserEntityTest.php +18 −0 Original line number Diff line number Diff line Loading @@ -125,4 +125,22 @@ public function testPasswordProperty(): void { $this->assertEquals('password', $user->password); } /** * Tests that ::getLastAccessedTime() returns an integer for a loaded user. * * @legacy-covers ::getLastAccessedTime */ public function testGetLastAccessedTime(): void { $access = 100; /** @var \Drupal\user\Entity\User $user */ $user = User::create([ 'name' => $this->randomMachineName(), 'access' => $access, ]); $id = $user->save(); $loaded_user = User::load($id); $this->assertSame($access, $loaded_user->getLastAccessedTime()); } } core/tests/Drupal/Tests/Core/Session/UserSessionTest.php +13 −0 Original line number Diff line number Diff line Loading @@ -114,4 +114,17 @@ public function testNamePropertyDeprecation(): void { $this->assertEquals('bar', $user->foo); } /** * Tests that ::getLastAccessedTime() returns an integer. * * @legacy-covers ::getLastAccessedTime */ public function testGetLastAccessedTime(): void { $user = new UserSession([ 'access' => '1234567890', ]); $this->assertSame(1234567890, $user->getLastAccessedTime()); } } Loading
core/lib/Drupal/Core/Session/UserSession.php +2 −2 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ class UserSession implements AccountInterface { /** * The Unix timestamp when the user last accessed the site. * * @var string * @var int */ protected $access; Loading Loading @@ -194,7 +194,7 @@ public function getTimeZone() { * {@inheritdoc} */ public function getLastAccessedTime() { return $this->access; return (int) $this->access; } /** Loading
core/modules/user/src/Entity/User.php +1 −1 Original line number Diff line number Diff line Loading @@ -289,7 +289,7 @@ public function getCreatedTime() { * {@inheritdoc} */ public function getLastAccessedTime() { return $this->getFieldValue('access', 'value'); return (int) $this->getFieldValue('access', 'value'); } /** Loading
core/modules/user/tests/src/Kernel/UserEntityTest.php +18 −0 Original line number Diff line number Diff line Loading @@ -125,4 +125,22 @@ public function testPasswordProperty(): void { $this->assertEquals('password', $user->password); } /** * Tests that ::getLastAccessedTime() returns an integer for a loaded user. * * @legacy-covers ::getLastAccessedTime */ public function testGetLastAccessedTime(): void { $access = 100; /** @var \Drupal\user\Entity\User $user */ $user = User::create([ 'name' => $this->randomMachineName(), 'access' => $access, ]); $id = $user->save(); $loaded_user = User::load($id); $this->assertSame($access, $loaded_user->getLastAccessedTime()); } }
core/tests/Drupal/Tests/Core/Session/UserSessionTest.php +13 −0 Original line number Diff line number Diff line Loading @@ -114,4 +114,17 @@ public function testNamePropertyDeprecation(): void { $this->assertEquals('bar', $user->foo); } /** * Tests that ::getLastAccessedTime() returns an integer. * * @legacy-covers ::getLastAccessedTime */ public function testGetLastAccessedTime(): void { $user = new UserSession([ 'access' => '1234567890', ]); $this->assertSame(1234567890, $user->getLastAccessedTime()); } }