function UserSaveStatusTest::testUserSaveStatus in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/user/src/Tests/UserSaveStatusTest.php \Drupal\user\Tests\UserSaveStatusTest::testUserSaveStatus()
Test SAVED_NEW and SAVED_UPDATED statuses for user entity type.
File
- core/
modules/ user/ src/ Tests/ UserSaveStatusTest.php, line 35 - Contains \Drupal\user\Tests\UserSaveStatusTest.
Class
- UserSaveStatusTest
- Tests user saving status.
Namespace
Drupal\user\TestsCode
function testUserSaveStatus() {
// Create a new user.
$values = array(
'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.");
}