Skip to content

Commit

Permalink
Shortcode: Fix the test-class.gravatar.php tests (#38582)
Browse files Browse the repository at this point in the history
* Shortcode: Fix the test-class.gravatar.php tests

* changelog

* Format url by wptexturize
  • Loading branch information
arthur791004 authored Jul 29, 2024
1 parent 4a18455 commit 58f6ee2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/fix-test-class-gravatar
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Shortcode: Fix the test-class.gravatar.php tests
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ public function test_shortcodes_gravatar() {
* @since 4.5.0
*/
public function test_shortcodes_gravatar_image() {
$content = "[gravatar email='[email protected]' size='48']";
$email = '[email protected]';
$size = 48;
$content = "[gravatar email='$email' size='$size']";

$shortcode_content = do_shortcode( $content );
$this->assertStringContainsString( "<img alt='' src='http://2.gravatar.com/avatar/572c3489ea700045927076136a969e27?s=48&#038;d=mm&#038;r=g'", $shortcode_content );
$this->assertStringContainsString( "class='avatar avatar-48 photo' height='48' width='48'", $shortcode_content );
$avatar_url = wptexturize( get_avatar_url( $email, array( 'size' => $size ) ) );
$this->assertStringContainsString( "<img alt='' src='$avatar_url'", $shortcode_content );
$this->assertStringContainsString( "class='avatar avatar-$size photo' height='$size' width='$size'", $shortcode_content );
}

/**
Expand Down Expand Up @@ -76,8 +79,9 @@ public function test_shortcodes_gravatar_profile() {
add_filter( 'pre_http_request', $http_request_filter, 10, 1 );

$shortcode_content = do_shortcode( $content );
$avatar_url = wptexturize( get_avatar_url( $email, array( 'size' => 96 ) ) );
$this->assertStringContainsString( '<div class="grofile vcard" id="grofile-embed-0">', $shortcode_content );
$this->assertStringContainsString( '<img src="http://2.gravatar.com/avatar/572c3489ea700045927076136a969e27?s=96&#038;d=mm&#038;r=g" width="96" height="96" class="no-grav gravatar photo"', $shortcode_content );
$this->assertStringContainsString( "<img src=\"$avatar_url\" width=\"96\" height=\"96\" class=\"no-grav gravatar photo\"", $shortcode_content );

remove_filter( 'pre_http_request', $http_request_filter, 10, 1 );
}
Expand All @@ -88,6 +92,7 @@ public function test_shortcodes_gravatar_profile() {
* @since 4.5.0
*/
public function test_shortcodes_gravatar_user_id() {
$email = '[email protected]';
$user = self::factory()->user->create_and_get( array( 'user_email' => '[email protected]' ) );
$content = "[gravatar_profile who='$user->ID']";
wp_set_current_user( $user->ID );
Expand All @@ -106,7 +111,8 @@ public function test_shortcodes_gravatar_user_id() {
add_filter( 'pre_http_request', $http_request_filter, 10, 1 );

$shortcode_content = do_shortcode( $content );
$this->assertStringContainsString( '<img src="http://2.gravatar.com/avatar/572c3489ea700045927076136a969e27?s=96&#038;d=mm&#038;r=g" width="96" height="96" class="no-grav gravatar photo"', $shortcode_content );
$avatar_url = wptexturize( get_avatar_url( $email, array( 'size' => 96 ) ) );
$this->assertStringContainsString( "<img src=\"$avatar_url\" width=\"96\" height=\"96\" class=\"no-grav gravatar photo\"", $shortcode_content );

remove_filter( 'pre_http_request', $http_request_filter, 10, 1 );
}
Expand Down

0 comments on commit 58f6ee2

Please sign in to comment.