|
@@ 61-85 (lines=25) @@
|
| 58 |
|
/** |
| 59 |
|
* Test that a comment can be created and deleted. |
| 60 |
|
*/ |
| 61 |
|
public function testCommentCreateDelete() |
| 62 |
|
{ |
| 63 |
|
// Create a comment on a test user. |
| 64 |
|
$user = $this->createUser(); |
| 65 |
|
$subject = $this->randomString(); |
| 66 |
|
$comment = (object) [ |
| 67 |
|
'subject' => $subject, |
| 68 |
|
'entity_type' => 'user', |
| 69 |
|
'entity_id' => $user->getUsername(), |
| 70 |
|
'step_bundle' => 'testcomment' |
| 71 |
|
]; |
| 72 |
|
$comment = $this->driver->createEntity('comment', $comment); |
| 73 |
|
|
| 74 |
|
$entities = $this->storage->loadByProperties(['subject' => $subject]); |
| 75 |
|
$this->assertEquals(1, count($entities)); |
| 76 |
|
|
| 77 |
|
// Check the id of the new comment has been added to the returned object. |
| 78 |
|
$entity = reset($entities); |
| 79 |
|
$this->assertEquals($entity->id(), $comment->id); |
| 80 |
|
|
| 81 |
|
// Check the comment can be deleted. |
| 82 |
|
$this->driver->entityDelete('comment', $comment); |
| 83 |
|
$entities = $this->storage->loadByProperties(['subject' => $subject]); |
| 84 |
|
$this->assertEquals(0, count($entities)); |
| 85 |
|
} |
| 86 |
|
|
| 87 |
|
/** |
| 88 |
|
* Test that a comment can be created and deleted. |
|
@@ 90-115 (lines=26) @@
|
| 87 |
|
/** |
| 88 |
|
* Test that a comment can be created and deleted. |
| 89 |
|
*/ |
| 90 |
|
public function testCommentCreateDeleteByWrapper() |
| 91 |
|
{ |
| 92 |
|
// Create a comment on a test user. |
| 93 |
|
$user = $this->createUser(); |
| 94 |
|
$subject = $this->randomString(); |
| 95 |
|
|
| 96 |
|
$fields = [ |
| 97 |
|
'subject' => $subject, |
| 98 |
|
'entity_type' => 'user', |
| 99 |
|
'entity_id' => $user->getUsername(), |
| 100 |
|
'comment_type' => 'testcomment' |
| 101 |
|
]; |
| 102 |
|
$comment = DriverEntityDrupal8::create($fields, $this->entityType)->save(); |
| 103 |
|
|
| 104 |
|
$entities = $this->storage->loadByProperties(['subject' => $subject]); |
| 105 |
|
$this->assertEquals(1, count($entities)); |
| 106 |
|
|
| 107 |
|
// Check the id of the new comment has been added to the returned object. |
| 108 |
|
$entity = reset($entities); |
| 109 |
|
$this->assertEquals($entity->id(), $comment->id); |
| 110 |
|
|
| 111 |
|
// Check the comment can be deleted. |
| 112 |
|
$comment->delete(); |
| 113 |
|
$entities = $this->storage->loadByProperties(['subject' => $subject]); |
| 114 |
|
$this->assertEquals(0, count($entities)); |
| 115 |
|
} |
| 116 |
|
} |
| 117 |
|
|