Mercurial > hg > isophonics-drupal-site
comparison core/modules/user/tests/src/Kernel/UserSaveStatusTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\user\Kernel; | |
4 | |
5 use Drupal\KernelTests\KernelTestBase; | |
6 use Drupal\user\Entity\User; | |
7 | |
8 /** | |
9 * Tests user saving status. | |
10 * | |
11 * @group user | |
12 */ | |
13 class UserSaveStatusTest extends KernelTestBase { | |
14 | |
15 /** | |
16 * Modules to enable. | |
17 * | |
18 * @var array | |
19 */ | |
20 public static $modules = ['system', 'user', 'field']; | |
21 | |
22 protected function setUp() { | |
23 parent::setUp(); | |
24 $this->installEntitySchema('user'); | |
25 } | |
26 | |
27 /** | |
28 * Test SAVED_NEW and SAVED_UPDATED statuses for user entity type. | |
29 */ | |
30 public function testUserSaveStatus() { | |
31 // Create a new user. | |
32 $values = [ | |
33 'uid' => 1, | |
34 'name' => $this->randomMachineName(), | |
35 ]; | |
36 $user = User::create($values); | |
37 | |
38 // Test SAVED_NEW. | |
39 $return = $user->save(); | |
40 $this->assertEqual($return, SAVED_NEW, "User was saved with SAVED_NEW status."); | |
41 | |
42 // Test SAVED_UPDATED. | |
43 $user->name = $this->randomMachineName(); | |
44 $return = $user->save(); | |
45 $this->assertEqual($return, SAVED_UPDATED, "User was saved with SAVED_UPDATED status."); | |
46 } | |
47 | |
48 } |