| @@ 93-108 (lines=16) @@ | ||
| 90 | /** |
|
| 91 | * Test that a node can be created specifying its body field. |
|
| 92 | */ |
|
| 93 | public function testNodeCreateWithBody() |
|
| 94 | { |
|
| 95 | $title = $this->randomString(); |
|
| 96 | $body = $this->randomString(); |
|
| 97 | $node = (object) [ |
|
| 98 | 'title' => $title, |
|
| 99 | 'type' => 'article', |
|
| 100 | 'body' => $body, |
|
| 101 | ]; |
|
| 102 | $node = $this->driver->createNode($node); |
|
| 103 | ||
| 104 | $entities = $this->storage->loadByProperties(['title' => $title]); |
|
| 105 | $this->assertEquals(1, count($entities)); |
|
| 106 | $entity = reset($entities); |
|
| 107 | $this->assertEquals($body, $entity->get('body')->value); |
|
| 108 | } |
|
| 109 | ||
| 110 | /** |
|
| 111 | * Test that a node can be created and deleted. |
|
| @@ 159-174 (lines=16) @@ | ||
| 156 | /** |
|
| 157 | * Test that a node can be created specifying its body field. |
|
| 158 | */ |
|
| 159 | public function testNodeCreateWithBodyByWrapper() |
|
| 160 | { |
|
| 161 | $title = $this->randomString(); |
|
| 162 | $body = $this->randomString(); |
|
| 163 | $fields = [ |
|
| 164 | 'title' => $title, |
|
| 165 | 'type' => 'article', |
|
| 166 | 'body' => $body, |
|
| 167 | ]; |
|
| 168 | $node = DriverEntityDrupal8::create($fields, $this->entityType)->save(); |
|
| 169 | ||
| 170 | $entities = $this->storage->loadByProperties(['title' => $title]); |
|
| 171 | $this->assertEquals(1, count($entities)); |
|
| 172 | $entity = reset($entities); |
|
| 173 | $this->assertEquals($body, $entity->get('body')->value); |
|
| 174 | } |
|
| 175 | ||
| 176 | /** |
|
| 177 | * Test the created and changed fields on a node. |
|