Skip to content

Commit 11abe93

Browse files
committed
Add dedicated test for get_comment
1 parent 2bb1e65 commit 11abe93

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/phpunit/tests/comment.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,4 +1896,20 @@ public function test_wp_trash_comment_only_top_level_notes_trigger_child_deletio
18961896
// Verify the sibling note is NOT trashed (no cascade since child is not top-level).
18971897
$this->assertSame( '1', get_comment( $sibling_note )->comment_approved );
18981898
}
1899+
1900+
/**
1901+
* @ticket 61244
1902+
*
1903+
* @covers ::get_comment
1904+
*/
1905+
public function test_get_comment_filter() {
1906+
$comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
1907+
1908+
$comment = get_comment( $comment_id );
1909+
$this->assertInstanceOf( WP_Comment::class, $comment );
1910+
$this->assertSame( $comment_id, (int) $comment->comment_ID, 'Expected the same comment.' );
1911+
1912+
add_filter( 'get_comment', '__return_null' );
1913+
$this->assertNull( get_comment( $comment_id ), 'Expected get_comment() to return null when get_comment filter returns null.' );
1914+
}
18991915
}

0 commit comments

Comments
 (0)