
| Current Path : /var/www/html/german-vocational.cn/core/modules/user/tests/src/Kernel/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/german-vocational.cn/core/modules/user/tests/src/Kernel/UserSaveStatusTest.php |
<?php
namespace Drupal\Tests\user\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Drupal\user\Entity\User;
/**
* Tests user saving status.
*
* @group user
*/
class UserSaveStatusTest extends KernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['system', 'user', 'field'];
protected function setUp() {
parent::setUp();
$this->installEntitySchema('user');
}
/**
* Test SAVED_NEW and SAVED_UPDATED statuses for user entity type.
*/
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.");
}
}