|
@@ 33-59 (lines=27) @@
|
| 30 |
|
/** |
| 31 |
|
* Test that a user can be created and deleted. |
| 32 |
|
*/ |
| 33 |
|
public function testUserCreateDelete() { |
| 34 |
|
$name = $this->randomString(); |
| 35 |
|
$user = (object) [ |
| 36 |
|
'name' => $name, |
| 37 |
|
]; |
| 38 |
|
$user = $this->driver->userCreate($user); |
| 39 |
|
|
| 40 |
|
$entities = $this->storage->loadByProperties(['name' => $name]); |
| 41 |
|
$this->assertEquals(1, count($entities)); |
| 42 |
|
|
| 43 |
|
// Status should be set to 1 by default. |
| 44 |
|
$entity = reset($entities); |
| 45 |
|
$this->assertEquals(1, $entity->status->value); |
| 46 |
|
|
| 47 |
|
// Looks like we forget to return the user object from userCreate, |
| 48 |
|
// so none of the code below works. But then how does userDelete ever work? |
| 49 |
|
/* // Check the id of the new user has been added to the returned object. |
| 50 |
|
$entity = reset($entities); |
| 51 |
|
$this->assertEquals($entity->id(), $user->uid); |
| 52 |
|
|
| 53 |
|
// Check the node can be deleted. |
| 54 |
|
$this->driver->userDelete($user); |
| 55 |
|
$entities = $this->storage->loadByProperties(['name' => $name]); |
| 56 |
|
$this->assertEquals(0, count($entities));*/ |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
/** |
| 60 |
|
* Test that a blocked user can be created. |
| 61 |
|
*/ |
| 62 |
|
public function testUserCreateBlocked() { |
|
@@ 62-77 (lines=16) @@
|
| 59 |
|
/** |
| 60 |
|
* Test that a blocked user can be created. |
| 61 |
|
*/ |
| 62 |
|
public function testUserCreateBlocked() { |
| 63 |
|
$name = $this->randomString(); |
| 64 |
|
$user = (object) [ |
| 65 |
|
'name' => $name, |
| 66 |
|
'status' => 0, |
| 67 |
|
]; |
| 68 |
|
$user = $this->driver->userCreate($user); |
| 69 |
|
|
| 70 |
|
$entities = $this->storage->loadByProperties(['name' => $name]); |
| 71 |
|
$this->assertEquals(1, count($entities)); |
| 72 |
|
|
| 73 |
|
// Status should be set to 0 as explicitly specified. |
| 74 |
|
$entity = reset($entities); |
| 75 |
|
$this->assertEquals(0, $entity->status->value); |
| 76 |
|
} |
| 77 |
|
|
| 78 |
|
/** |
| 79 |
|
* Test that a user can be given a role, using role label or machine name. |
| 80 |
|
*/ |
|
@@ 143-158 (lines=16) @@
|
| 140 |
|
/** |
| 141 |
|
* Test that a blocked user can be created. |
| 142 |
|
*/ |
| 143 |
|
public function testUserCreateBlockedByWrapper() { |
| 144 |
|
$name = $this->randomString(); |
| 145 |
|
$fields = [ |
| 146 |
|
'name' => $name, |
| 147 |
|
'status' => 0, |
| 148 |
|
]; |
| 149 |
|
$user = DriverEntityDrupal8::create($fields, $this->entityType)->save(); |
| 150 |
|
|
| 151 |
|
$entities = $this->storage->loadByProperties(['name' => $name]); |
| 152 |
|
$this->assertEquals(1, count($entities)); |
| 153 |
|
|
| 154 |
|
// Status should be set to 0 as explicitly specified. |
| 155 |
|
$entity = reset($entities); |
| 156 |
|
$this->assertEquals(0, $entity->status->value); |
| 157 |
|
} |
| 158 |
|
|
| 159 |
|
/** |
| 160 |
|
* Test that a user can be given a role, using role label or machine name. |
| 161 |
|
*/ |