Code Duplication    Length = 16-27 lines in 3 locations

tests/Drupal/Tests/Driver/Kernel/Drupal8/Entity/UserTest.php 3 locations

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