diff --git a/tests/phpunit/tests/comment/commentExcerpt.php b/tests/phpunit/tests/comment/commentExcerpt.php new file mode 100644 index 0000000000000..6f4142e495ec6 --- /dev/null +++ b/tests/phpunit/tests/comment/commentExcerpt.php @@ -0,0 +1,82 @@ +post->create(); + self::$comment = $factory->comment->create_and_get( + array( + 'comment_post_ID' => self::$post_id, + 'comment_content' => 'Short comment excerpt text.', + ) + ); + } + + public function tear_down() { + unset( $GLOBALS['comment'] ); + parent::tear_down(); + } + + /** + * @ticket 65819 + */ + public function test_comment_excerpt_echoes_excerpt() { + $this->expectOutputString( 'Short comment excerpt text.' ); + comment_excerpt( self::$comment->comment_ID ); + } + + /** + * @ticket 65819 + */ + public function test_comment_excerpt_accepts_comment_object() { + $this->expectOutputString( 'Short comment excerpt text.' ); + comment_excerpt( self::$comment ); + } + + /** + * @ticket 65819 + */ + public function test_comment_excerpt_uses_global_comment_when_unspecified() { + $GLOBALS['comment'] = self::$comment; + + $this->expectOutputString( 'Short comment excerpt text.' ); + comment_excerpt(); + } + + /** + * @ticket 65819 + */ + public function test_comment_excerpt_filter_can_modify_output() { + add_filter( + 'comment_excerpt', + static function () { + return 'Filtered excerpt.'; + } + ); + + $this->expectOutputString( 'Filtered excerpt.' ); + comment_excerpt( self::$comment->comment_ID ); + } +}