| @@ 46-65 (lines=20) @@ | ||
| 43 | /** |
|
| 44 | * Test that a node can be created and deleted. |
|
| 45 | */ |
|
| 46 | public function testNodeCreateDelete() { |
|
| 47 | $title = $this->driver->getRandom()->string(); |
|
| 48 | $node = (object) [ |
|
| 49 | 'title' => $title, |
|
| 50 | 'type' => 'article', |
|
| 51 | ]; |
|
| 52 | $node = $this->driver->createNode($node); |
|
| 53 | ||
| 54 | $entities = $this->storage->loadByProperties(['title' => $title]); |
|
| 55 | $this->assertEquals(1, count($entities)); |
|
| 56 | ||
| 57 | // Check the id of the new node has been added to the returned object. |
|
| 58 | $entity = reset($entities); |
|
| 59 | $this->assertEquals($entity->id(), $node->nid); |
|
| 60 | ||
| 61 | // Check the node can be deleted. |
|
| 62 | $this->driver->nodeDelete($node); |
|
| 63 | $entities = $this->storage->loadByProperties(['title' => $title]); |
|
| 64 | $this->assertEquals(0, count($entities)); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Test that a node can be created specifying its author by name. |
|
| @@ 109-128 (lines=20) @@ | ||
| 106 | /** |
|
| 107 | * Test that a node can be created and deleted. |
|
| 108 | */ |
|
| 109 | public function testNodeCreateDeleteByWrapper() { |
|
| 110 | $title = $this->driver->getRandom()->string(); |
|
| 111 | $fields = [ |
|
| 112 | 'title' => $title, |
|
| 113 | 'type' => 'article', |
|
| 114 | ]; |
|
| 115 | $node = DriverEntityDrupal8::create($fields, $this->entityType)->save(); |
|
| 116 | ||
| 117 | $entities = $this->storage->loadByProperties(['title' => $title]); |
|
| 118 | $this->assertEquals(1, count($entities)); |
|
| 119 | ||
| 120 | // Check the id of the new node has been added to the returned object. |
|
| 121 | $entity = reset($entities); |
|
| 122 | $this->assertEquals($entity->id(), $node->nid); |
|
| 123 | ||
| 124 | // Check the node can be deleted. |
|
| 125 | $this->driver->nodeDelete($node); |
|
| 126 | $entities = $this->storage->loadByProperties(['title' => $title]); |
|
| 127 | $this->assertEquals(0, count($entities)); |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * Test that a node can be created specifying its author by name. |
|
| @@ 40-59 (lines=20) @@ | ||
| 37 | /** |
|
| 38 | * Test that a term can be created and deleted. |
|
| 39 | */ |
|
| 40 | public function testTermCreateDelete() { |
|
| 41 | $name = $this->randomString(); |
|
| 42 | $term = (object) [ |
|
| 43 | 'name' => $name, |
|
| 44 | 'vocabulary_machine_name' => 'testvocab', |
|
| 45 | ]; |
|
| 46 | $term = $this->driver->createTerm($term); |
|
| 47 | ||
| 48 | $entities = $this->storage->loadByProperties(['name' => $name]); |
|
| 49 | $this->assertEquals(1, count($entities)); |
|
| 50 | ||
| 51 | // Check the id of the new term has been added to the returned object. |
|
| 52 | $entity = reset($entities); |
|
| 53 | $this->assertEquals($entity->id(), $term->tid); |
|
| 54 | ||
| 55 | // Check the term can be deleted. |
|
| 56 | $this->driver->termDelete($term); |
|
| 57 | $entities = $this->storage->loadByProperties(['name' => $name]); |
|
| 58 | $this->assertEquals(0, count($entities)); |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * Test that a term can be created with a parent term. |
|
| @@ 93-112 (lines=20) @@ | ||
| 90 | /** |
|
| 91 | * Test that a term can be created and deleted. |
|
| 92 | */ |
|
| 93 | public function testTermCreateDeleteByWrapper() { |
|
| 94 | $name = $this->randomString(); |
|
| 95 | $fields = [ |
|
| 96 | 'name' => $name, |
|
| 97 | 'vocabulary' => 'testvocab', |
|
| 98 | ]; |
|
| 99 | $term = DriverEntityDrupal8::create($fields, $this->entityType)->save(); |
|
| 100 | ||
| 101 | $entities = $this->storage->loadByProperties(['name' => $name]); |
|
| 102 | $this->assertEquals(1, count($entities)); |
|
| 103 | ||
| 104 | // Check the id of the new term has been added to the returned object. |
|
| 105 | $entity = reset($entities); |
|
| 106 | $this->assertEquals($entity->id(), $term->tid); |
|
| 107 | ||
| 108 | // Check the term can be deleted. |
|
| 109 | $term->delete(); |
|
| 110 | $entities = $this->storage->loadByProperties(['name' => $name]); |
|
| 111 | $this->assertEquals(0, count($entities)); |
|
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| 115 | * Test that a term can be created with a parent term. |
|