Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,8 @@ protected function prepare_links( $comment ) {
array(
'count' => true,
'orderby' => 'none',
'type' => $comment->comment_type,
'status' => 'all',
)
);

Expand Down
34 changes: 34 additions & 0 deletions tests/phpunit/tests/rest-api/rest-comments-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -4069,4 +4069,38 @@ public function data_note_status_provider() {
'reopen' => array( 'reopen' ),
);
}

/**
* Test children link for note comment type.
*
* @ticket 64145
*/
public function test_get_note_with_children_link() {
$comment_id_1 = self::factory()->comment->create(
array(
'comment_approved' => 0,
'comment_post_ID' => self::$post_id,
'user_id' => self::$subscriber_id,
'comment_type' => 'note',
)
);

self::factory()->comment->create(
array(
'comment_approved' => 0,
'comment_parent' => $comment_id_1,
'comment_post_ID' => self::$post_id,
'user_id' => self::$subscriber_id,
'comment_type' => 'note',
)
);
wp_set_current_user( self::$admin_id );
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
$request->set_param( 'type', 'note' );
$request->set_param( 'context', 'edit' );
$response = rest_get_server()->dispatch( $request );
$this->assertSame( 200, $response->get_status() );

$this->assertArrayHasKey( 'children', $response->get_links() );
}
}