Changeset 58822 for trunk/tests/phpunit/tests/avatar.php
- Timestamp:
- 07/29/2024 01:57:11 AM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/avatar.php
r56547 r58822 12 12 public function test_get_avatar_url_gravatar_url() { 13 13 $url = get_avatar_url( 1 ); 14 $this->assertSame( preg_match( '|^http ?://[0-9]+.gravatar.com/avatar/[0-9a-f]{32}\?|', $url ), 1 );14 $this->assertSame( preg_match( '|^https?://secure.gravatar.com/avatar/[0-9a-f]{32}\?|', $url ), 1 ); 15 15 } 16 16 … … 57 57 58 58 /** 59 * @ticket 21195 59 * Ensures the get_avatar_url always returns an HTTPS scheme for gravatars. 60 * 61 * @ticket 21195 62 * @ticket 37454 63 * 64 * @covers ::get_avatar_url 60 65 */ 61 66 public function test_get_avatar_url_scheme() { 62 67 $url = get_avatar_url( 1 ); 63 $this->assertSame( preg_match( '|^http ://|', $url ), 1);68 $this->assertSame( preg_match( '|^https://|', $url ), 1, 'Avatars should default to the HTTPS scheme' ); 64 69 65 70 $args = array( 'scheme' => 'https' ); 66 71 $url = get_avatar_url( 1, $args ); 67 $this->assertSame( preg_match( '|^https://|', $url ), 1 ); 72 $this->assertSame( preg_match( '|^https://|', $url ), 1, 'Requesting the HTTPS scheme should be respected' ); 73 74 $args = array( 'scheme' => 'http' ); 75 $url = get_avatar_url( 1, $args ); 76 $this->assertSame( preg_match( '|^https://|', $url ), 1, 'Requesting the HTTP scheme should return an HTTPS URL to avoid redirects' ); 68 77 69 78 $args = array( 'scheme' => 'lolcat' ); 70 79 $url = get_avatar_url( 1, $args ); 71 $this->assertSame( preg_match( '|^lolcat://|', $url ), 0 ); 80 $this->assertSame( preg_match( '|^lolcat://|', $url ), 0, 'Unrecognized schemes should be ignored' ); 81 $this->assertSame( preg_match( '|^https://|', $url ), 1, 'Unrecognized schemes should return an HTTPS URL' ); 72 82 } 73 83 … … 258 268 259 269 $this->assertTrue( is_avatar_comment_type( $comment_type ) ); 260 $this->assertMatchesRegularExpression( '|^http ?://[0-9]+.gravatar.com/avatar/[0-9a-f]{32}\?|', $actual_data['url'] );270 $this->assertMatchesRegularExpression( '|^https?://secure.gravatar.com/avatar/[0-9a-f]{32}\?|', $actual_data['url'] ); 261 271 } 262 272
Note: See TracChangeset
for help on using the changeset viewer.