From 62b4465532c6773ee93c01eedee38e22a2e9cc03 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 9 Jan 2019 06:19:53 +0000 Subject: [PATCH] Comments: Add new tests missed in [44499]. Props dshanske, birgire. Fixes #44033. git-svn-id: https://develop.svn.wordpress.org/trunk@44502 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/comment/isAvatarCommentType.php | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 tests/phpunit/tests/comment/isAvatarCommentType.php diff --git a/tests/phpunit/tests/comment/isAvatarCommentType.php b/tests/phpunit/tests/comment/isAvatarCommentType.php new file mode 100644 index 0000000000..9e0111cc04 --- /dev/null +++ b/tests/phpunit/tests/comment/isAvatarCommentType.php @@ -0,0 +1,81 @@ +assertSame( $expected, is_avatar_comment_type( $comment_type ) ); + } + + /** + * Dataprovider for `is_avatar_comment_type()`. + * + * @since 5.1.0 + * + * @return array { + * @type array { + * @type string Comment type. + * @type bool Expected values. + * } + * } + */ + public function data_is_avatar_comment_type() { + return array( + array( null, false ), + array( '', false ), + array( 'non-existing-comment-type', false ), + array( 'comment', true ), + ); + } + + /** + * The function should be filterable with the `get_avatar_comment_types` filter. + * + * @since 5.1.0 + */ + public function test_function_should_be_filterable() { + $this->assertFalse( is_avatar_comment_type( 'review' ) ); + + add_filter( 'get_avatar_comment_types', array( $this, '_filter_avatar_comment_types' ) ); + $actual_comment = is_avatar_comment_type( 'comment' ); + $actual_review = is_avatar_comment_type( 'review' ); + remove_filter( 'get_avatar_comment_types', array( $this, '_filter_avatar_comment_types' ) ); + + $this->assertTrue( $actual_comment ); + $this->assertTrue( $actual_review ); + } + + /** + * Filters callback that modifies the list of allowed comment types for retrieving avatars. + * + * @since 5.1.0 + * + * @param array $types An array of content types. + * @return array $types An array of content types. + */ + public function _filter_avatar_comment_types( $types ) { + $types[] = 'review'; + return $types; + } + +}