Skip to content

Commit 7ddeb34

Browse files
authored
Fix and test create handler (#1095)
* Fix and test comment code This fixes missing function definition and adds some tests * fix phpcs issue * fix PHPCS issue
1 parent 96feed2 commit 7ddeb34

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

includes/handler/class-create.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Activitypub\Collection\Interactions;
1111

1212
use function Activitypub\is_self_ping;
13+
use function Activitypub\is_activity_reply;
1314
use function Activitypub\is_activity_public;
1415
use function Activitypub\object_id_to_comment;
1516

tests/includes/handler/class-test-create.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,25 @@ public function test_handle_create_non_public_rejected() {
121121
$converted = Create::handle_create( $object, $this->user_id );
122122
$this->assertNull( $converted );
123123
}
124+
125+
/**
126+
* Test handle create.
127+
*
128+
* @covers ::handle_create
129+
*/
130+
public function test_handle_create_public_accepted() {
131+
$object = $this->create_test_object();
132+
Create::handle_create( $object, $this->user_id );
133+
134+
$args = array(
135+
'type' => 'comment',
136+
'post_id' => $this->post_id,
137+
);
138+
139+
$query = new \WP_Comment_Query( $args );
140+
$result = $query->comments;
141+
142+
$this->assertInstanceOf( 'WP_Comment', $result[0] );
143+
$this->assertEquals( 'example', $result[0]->comment_content );
144+
}
124145
}

0 commit comments

Comments
 (0)