function UserSaveStatusTest::testUserSaveStatus
Same name in other branches
- 9 core/modules/user/tests/src/Kernel/UserSaveStatusTest.php \Drupal\Tests\user\Kernel\UserSaveStatusTest::testUserSaveStatus()
- 10 core/modules/user/tests/src/Kernel/UserSaveStatusTest.php \Drupal\Tests\user\Kernel\UserSaveStatusTest::testUserSaveStatus()
- 11.x core/modules/user/tests/src/Kernel/UserSaveStatusTest.php \Drupal\Tests\user\Kernel\UserSaveStatusTest::testUserSaveStatus()
Test SAVED_NEW and SAVED_UPDATED statuses for user entity type.
File
-
core/
modules/ user/ tests/ src/ Kernel/ UserSaveStatusTest.php, line 30
Class
- UserSaveStatusTest
- Tests user saving status.
Namespace
Drupal\Tests\user\KernelCode
public function testUserSaveStatus() {
// Create a new user.
$values = [
'uid' => 1,
'name' => $this->randomMachineName(),
];
$user = User::create($values);
// Test SAVED_NEW.
$return = $user->save();
$this->assertEqual($return, SAVED_NEW, "User was saved with SAVED_NEW status.");
// Test SAVED_UPDATED.
$user->name = $this->randomMachineName();
$return = $user->save();
$this->assertEqual($return, SAVED_UPDATED, "User was saved with SAVED_UPDATED status.");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.