|
@@ 72-88 (lines=17) @@
|
| 69 |
|
/** |
| 70 |
|
* Test that a node can be created specifying its author by name. |
| 71 |
|
*/ |
| 72 |
|
public function testNodeCreateWithAuthorName() |
| 73 |
|
{ |
| 74 |
|
$title = $this->randomString(); |
| 75 |
|
$author = $this->createUser(); |
| 76 |
|
$authorName = $author->getUsername(); |
| 77 |
|
$node = (object) [ |
| 78 |
|
'title' => $title, |
| 79 |
|
'type' => 'article', |
| 80 |
|
'author' => $authorName, |
| 81 |
|
]; |
| 82 |
|
$node = $this->driver->createNode($node); |
| 83 |
|
|
| 84 |
|
$entities = $this->storage->loadByProperties(['title' => $title]); |
| 85 |
|
$this->assertEquals(1, count($entities)); |
| 86 |
|
$entity = reset($entities); |
| 87 |
|
$this->assertEquals($author->id(), $entity->getOwnerId()); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
/** |
| 91 |
|
* Test that a node can be created specifying its body field. |
|
@@ 138-154 (lines=17) @@
|
| 135 |
|
/** |
| 136 |
|
* Test that a node can be created specifying its author by name. |
| 137 |
|
*/ |
| 138 |
|
public function testNodeCreateWithAuthorNameByWrapper() |
| 139 |
|
{ |
| 140 |
|
$title = $this->randomString(); |
| 141 |
|
$author = $this->createUser(); |
| 142 |
|
$authorName = $author->getUsername(); |
| 143 |
|
$fields = [ |
| 144 |
|
'title' => $title, |
| 145 |
|
'type' => 'article', |
| 146 |
|
'author' => $authorName, |
| 147 |
|
]; |
| 148 |
|
$node = DriverEntityDrupal8::create($fields, $this->entityType)->save(); |
| 149 |
|
|
| 150 |
|
$entities = $this->storage->loadByProperties(['title' => $title]); |
| 151 |
|
$this->assertEquals(1, count($entities)); |
| 152 |
|
$entity = reset($entities); |
| 153 |
|
$this->assertEquals($author->id(), $entity->getOwnerId()); |
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
/** |
| 157 |
|
* Test that a node can be created specifying its body field. |