Changeset 48937 for trunk/tests/phpunit/tests/avatar.php
- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/avatar.php
r47554 r48937 12 12 public function test_get_avatar_url_gravatar_url() { 13 13 $url = get_avatar_url( 1 ); 14 $this->assert Equals( preg_match( '|^http?://[0-9]+.gravatar.com/avatar/[0-9a-f]{32}\?|', $url ), 1 );14 $this->assertSame( preg_match( '|^http?://[0-9]+.gravatar.com/avatar/[0-9a-f]{32}\?|', $url ), 1 ); 15 15 } 16 16 … … 20 20 public function test_get_avatar_url_size() { 21 21 $url = get_avatar_url( 1 ); 22 $this->assert Equals( preg_match( '|\?.*s=96|', $url ), 1 );22 $this->assertSame( preg_match( '|\?.*s=96|', $url ), 1 ); 23 23 24 24 $args = array( 'size' => 100 ); 25 25 $url = get_avatar_url( 1, $args ); 26 $this->assert Equals( preg_match( '|\?.*s=100|', $url ), 1 );26 $this->assertSame( preg_match( '|\?.*s=100|', $url ), 1 ); 27 27 } 28 28 … … 32 32 public function test_get_avatar_url_default() { 33 33 $url = get_avatar_url( 1 ); 34 $this->assert Equals( preg_match( '|\?.*d=mm|', $url ), 1 );34 $this->assertSame( preg_match( '|\?.*d=mm|', $url ), 1 ); 35 35 36 36 $args = array( 'default' => 'wavatar' ); 37 37 $url = get_avatar_url( 1, $args ); 38 $this->assert Equals( preg_match( '|\?.*d=wavatar|', $url ), 1 );39 40 $this->assert Equals( preg_match( '|\?.*f=y|', $url ), 0 );38 $this->assertSame( preg_match( '|\?.*d=wavatar|', $url ), 1 ); 39 40 $this->assertSame( preg_match( '|\?.*f=y|', $url ), 0 ); 41 41 $args = array( 'force_default' => true ); 42 42 $url = get_avatar_url( 1, $args ); 43 $this->assert Equals( preg_match( '|\?.*f=y|', $url ), 1 );43 $this->assertSame( preg_match( '|\?.*f=y|', $url ), 1 ); 44 44 } 45 45 … … 49 49 public function test_get_avatar_url_rating() { 50 50 $url = get_avatar_url( 1 ); 51 $this->assert Equals( preg_match( '|\?.*r=g|', $url ), 1 );51 $this->assertSame( preg_match( '|\?.*r=g|', $url ), 1 ); 52 52 53 53 $args = array( 'rating' => 'M' ); 54 54 $url = get_avatar_url( 1, $args ); 55 $this->assert Equals( preg_match( '|\?.*r=m|', $url ), 1 );55 $this->assertSame( preg_match( '|\?.*r=m|', $url ), 1 ); 56 56 } 57 57 … … 61 61 public function test_get_avatar_url_scheme() { 62 62 $url = get_avatar_url( 1 ); 63 $this->assert Equals( preg_match( '|^http://|', $url ), 1 );63 $this->assertSame( preg_match( '|^http://|', $url ), 1 ); 64 64 65 65 $args = array( 'scheme' => 'https' ); 66 66 $url = get_avatar_url( 1, $args ); 67 $this->assert Equals( preg_match( '|^https://|', $url ), 1 );67 $this->assertSame( preg_match( '|^https://|', $url ), 1 ); 68 68 69 69 $args = array( 'scheme' => 'lolcat' ); 70 70 $url = get_avatar_url( 1, $args ); 71 $this->assert Equals( preg_match( '|^lolcat://|', $url ), 0 );71 $this->assertSame( preg_match( '|^lolcat://|', $url ), 0 ); 72 72 } 73 73 … … 79 79 80 80 $url2 = get_avatar_url( WP_TESTS_EMAIL ); 81 $this->assert Equals( $url, $url2 );81 $this->assertSame( $url, $url2 ); 82 82 83 83 $url2 = get_avatar_url( md5( WP_TESTS_EMAIL ) . '@md5.gravatar.com' ); 84 $this->assert Equals( $url, $url2 );84 $this->assertSame( $url, $url2 ); 85 85 86 86 $user = get_user_by( 'id', 1 ); 87 87 $url2 = get_avatar_url( $user ); 88 $this->assert Equals( $url, $url2 );88 $this->assertSame( $url, $url2 ); 89 89 90 90 $post_id = self::factory()->post->create( array( 'post_author' => 1 ) ); 91 91 $post = get_post( $post_id ); 92 92 $url2 = get_avatar_url( $post ); 93 $this->assert Equals( $url, $url2 );93 $this->assertSame( $url, $url2 ); 94 94 95 95 $comment_id = self::factory()->comment->create( … … 101 101 $comment = get_comment( $comment_id ); 102 102 $url2 = get_avatar_url( $comment ); 103 $this->assert Equals( $url, $url2 );103 $this->assertSame( $url, $url2 ); 104 104 } 105 105 … … 115 115 remove_filter( 'pre_get_avatar_data', array( $this, 'pre_get_avatar_url_filter' ), 10 ); 116 116 117 $this->assert Equals( $url, $this->fake_url );117 $this->assertSame( $url, $this->fake_url ); 118 118 } 119 119 public function pre_get_avatar_url_filter( $args ) { … … 132 132 remove_filter( 'get_avatar_url', array( $this, 'get_avatar_url_filter' ), 10 ); 133 133 134 $this->assert Equals( $url, $this->fake_url );134 $this->assertSame( $url, $this->fake_url ); 135 135 } 136 136 public function get_avatar_url_filter( $url ) { … … 161 161 remove_filter( 'get_avatar_comment_types', array( $this, 'get_avatar_comment_types_filter' ), 10 ); 162 162 163 $this->assert Equals( $url, $url2 );163 $this->assertSame( $url, $url2 ); 164 164 } 165 165 public function get_avatar_comment_types_filter( $comment_types ) { … … 170 170 public function test_get_avatar() { 171 171 $img = get_avatar( 1 ); 172 $this->assert Equals( preg_match( "|^<img alt='[^']*' src='[^']*' srcset='[^']*' class='[^']*' height='[^']*' width='[^']*' loading='lazy'/>$|", $img ), 1 );172 $this->assertSame( preg_match( "|^<img alt='[^']*' src='[^']*' srcset='[^']*' class='[^']*' height='[^']*' width='[^']*' loading='lazy'/>$|", $img ), 1 ); 173 173 } 174 174 … … 176 176 $size = '100'; 177 177 $img = get_avatar( 1, $size ); 178 $this->assert Equals( preg_match( "|^<img .*height='$size'.*width='$size'|", $img ), 1 );178 $this->assertSame( preg_match( "|^<img .*height='$size'.*width='$size'|", $img ), 1 ); 179 179 } 180 180 … … 182 182 $alt = 'Mr Hyde'; 183 183 $img = get_avatar( 1, 96, '', $alt ); 184 $this->assert Equals( preg_match( "|^<img alt='$alt'|", $img ), 1 );184 $this->assertSame( preg_match( "|^<img alt='$alt'|", $img ), 1 ); 185 185 } 186 186 … … 188 188 $class = 'first'; 189 189 $img = get_avatar( 1, 96, '', '', array( 'class' => $class ) ); 190 $this->assert Equals( preg_match( "|^<img .*class='[^']*{$class}[^']*'|", $img ), 1 );190 $this->assertSame( preg_match( "|^<img .*class='[^']*{$class}[^']*'|", $img ), 1 ); 191 191 } 192 192 193 193 public function test_get_avatar_default_class() { 194 194 $img = get_avatar( 1, 96, '', '', array( 'force_default' => true ) ); 195 $this->assert Equals( preg_match( "|^<img .*class='[^']*avatar-default[^']*'|", $img ), 1 );195 $this->assertSame( preg_match( "|^<img .*class='[^']*avatar-default[^']*'|", $img ), 1 ); 196 196 } 197 197 … … 219 219 remove_filter( 'pre_get_avatar', array( $this, 'pre_get_avatar_filter' ), 10 ); 220 220 221 $this->assert Equals( $img, $this->fake_img );221 $this->assertSame( $img, $this->fake_img ); 222 222 } 223 223 public function pre_get_avatar_filter( $img ) { … … 235 235 remove_filter( 'get_avatar', array( $this, 'get_avatar_filter' ), 10 ); 236 236 237 $this->assert Equals( $img, $this->fake_url );237 $this->assertSame( $img, $this->fake_url ); 238 238 } 239 239 public function get_avatar_filter( $img ) {
Note: See TracChangeset
for help on using the changeset viewer.