mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Comments: Add a new is_avatar_comment_type() function.
This function splits the `get_avatar_comment_types` filter out of `get_avatar_data()`. Props dshanske, birgire. Fixes #44033. git-svn-id: https://develop.svn.wordpress.org/trunk@44499 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -240,4 +240,44 @@ class Tests_Avatar extends WP_UnitTestCase {
|
||||
return $this->fakeURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* The `get_avatar_data()` function should return gravatar url when comment type allowed to retrieve avatars.
|
||||
*
|
||||
* @ticket 44033
|
||||
*/
|
||||
public function test_get_avatar_data_should_return_gravatar_url_when_input_avatar_comment_type() {
|
||||
$comment_type = 'comment';
|
||||
$comment = self::factory()->comment->create_and_get(
|
||||
array(
|
||||
'comment_author_email' => 'commenter@example.com',
|
||||
'comment_type' => $comment_type,
|
||||
)
|
||||
);
|
||||
|
||||
$actual_data = get_avatar_data( $comment );
|
||||
|
||||
$this->assertTrue( is_avatar_comment_type( $comment_type ) );
|
||||
$this->assertRegexp( '|^http?://[0-9]+.gravatar.com/avatar/[0-9a-f]{32}\?|', $actual_data['url'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* The `get_avatar_data()` function should return invalid url when comment type not allowed to retrieve avatars.
|
||||
*
|
||||
* @ticket 44033
|
||||
*/
|
||||
public function test_get_avatar_data_should_return_invalid_url_when_input_not_avatar_comment_type() {
|
||||
$comment_type = 'review';
|
||||
$comment = self::factory()->comment->create_and_get(
|
||||
array(
|
||||
'comment_author_email' => 'commenter@example.com',
|
||||
'comment_type' => $comment_type,
|
||||
)
|
||||
);
|
||||
|
||||
$actual_data = get_avatar_data( $comment );
|
||||
|
||||
$this->assertFalse( is_avatar_comment_type( $comment_type ) );
|
||||
$this->assertFalse( $actual_data['url'] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user