Code Duplication    Length = 21-22 lines in 3 locations

tests/Drupal/Tests/Driver/Kernel/Drupal8/Entity/NodeTest.php 1 location

@@ 113-133 (lines=21) @@
110
  /**
111
   * Test that a node can be created and deleted.
112
   */
113
    public function testNodeCreateDeleteByWrapper()
114
    {
115
        $title = $this->driver->getRandom()->string();
116
        $fields = [
117
        'title' => $title,
118
        'type' => 'article',
119
        ];
120
        $node = DriverEntityDrupal8::create($fields, $this->entityType)->save();
121
122
        $entities = $this->storage->loadByProperties(['title' => $title]);
123
        $this->assertEquals(1, count($entities));
124
125
        // Check the id of the new node has been added to the returned object.
126
        $entity = reset($entities);
127
        $this->assertEquals($entity->id(), $node->nid);
128
129
        // Check the node can be deleted.
130
        $this->driver->nodeDelete($node);
131
        $entities = $this->storage->loadByProperties(['title' => $title]);
132
        $this->assertEquals(0, count($entities));
133
    }
134
135
  /**
136
   * Test that a node can be created specifying its author by name.

tests/Drupal/Tests/Driver/Kernel/Drupal8/Entity/TaxonomyTermTest.php 2 locations

@@ 41-61 (lines=21) @@
38
  /**
39
   * Test that a term can be created and deleted.
40
   */
41
    public function testTermCreateDelete()
42
    {
43
        $name = $this->randomString();
44
        $term = (object) [
45
        'name' => $name,
46
        'vocabulary_machine_name' => 'testvocab',
47
        ];
48
        $term = $this->driver->createTerm($term);
49
50
        $entities = $this->storage->loadByProperties(['name' => $name]);
51
        $this->assertEquals(1, count($entities));
52
53
        // Check the id of the new term has been added to the returned object.
54
        $entity = reset($entities);
55
        $this->assertEquals($entity->id(), $term->tid);
56
57
        // Check the term can be deleted.
58
        $this->driver->termDelete($term);
59
        $entities = $this->storage->loadByProperties(['name' => $name]);
60
        $this->assertEquals(0, count($entities));
61
    }
62
63
  /**
64
   * Test that a term can be created with a parent term.
@@ 97-118 (lines=22) @@
94
  /**
95
   * Test that a term can be created and deleted.
96
   */
97
    public function testTermCreateDeleteByWrapper()
98
    {
99
      return;
100
        $name = $this->randomString();
101
        $fields = [
102
        'name' => $name,
103
        'vocabulary' => 'testvocab',
104
        ];
105
        $term = DriverEntityDrupal8::create($fields, $this->entityType)->save();
106
107
        $entities = $this->storage->loadByProperties(['name' => $name]);
108
        $this->assertEquals(1, count($entities));
109
110
        // Check the id of the new term has been added to the returned object.
111
        $entity = reset($entities);
112
        $this->assertEquals($entity->id(), $term->tid);
113
114
        // Check the term can be deleted.
115
        $term->delete();
116
        $entities = $this->storage->loadByProperties(['name' => $name]);
117
        $this->assertEquals(0, count($entities));
118
    }
119
120
  /**
121
   * Test that a term can be created with a parent term.