Changeset 41201 for branches/4.8/tests/phpunit/tests/formatting/Emoji.php
- Timestamp:
- 08/01/2017 09:15:07 PM (8 years ago)
- Location:
- branches/4.8
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
tests/phpunit/tests/formatting/Emoji.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/4.8
- Property svn:mergeinfo changed
/trunk reverse-merged: 41043,41045-41046
- Property svn:mergeinfo changed
-
branches/4.8/tests/phpunit/tests/formatting/Emoji.php
r41069 r41201 3 3 /** 4 4 * @group formatting 5 * @group emoji6 5 */ 7 6 class Tests_Formatting_Emoji extends WP_UnitTestCase { 8 9 private $png_cdn = 'https://s.w.org/images/core/emoji/2.3/72x72/';10 private $svn_cdn = 'https://s.w.org/images/core/emoji/2.3/svg/';11 12 7 /** 13 8 * @ticket 36525 14 9 */ 15 10 public function test_unfiltered_emoji_cdns() { 11 $png_cdn = 'https://s.w.org/images/core/emoji/2.3/72x72/'; 12 $svn_cdn = 'https://s.w.org/images/core/emoji/2.3/svg/'; 13 16 14 $output = get_echo( '_print_emoji_detection_script' ); 17 15 18 $this->assertContains( wp_json_encode( $ this->png_cdn ), $output );19 $this->assertContains( wp_json_encode( $ this->svn_cdn ), $output );16 $this->assertContains( wp_json_encode( $png_cdn ), $output ); 17 $this->assertContains( wp_json_encode( $svn_cdn ), $output ); 20 18 } 21 19 … … 28 26 */ 29 27 public function test_filtered_emoji_svn_cdn() { 28 $png_cdn = 'https://s.w.org/images/core/emoji/2.3/72x72/'; 29 $svn_cdn = 'https://s.w.org/images/core/emoji/2.3/svg/'; 30 30 31 $filtered_svn_cdn = $this->_filtered_emoji_svn_cdn(); 31 32 … … 34 35 $output = get_echo( '_print_emoji_detection_script' ); 35 36 36 $this->assertContains( wp_json_encode( $ this->png_cdn ), $output );37 $this->assertNotContains( wp_json_encode( $ this->svn_cdn ), $output );37 $this->assertContains( wp_json_encode( $png_cdn ), $output ); 38 $this->assertNotContains( wp_json_encode( $svn_cdn ), $output ); 38 39 $this->assertContains( wp_json_encode( $filtered_svn_cdn ), $output ); 39 40 … … 49 50 */ 50 51 public function test_filtered_emoji_png_cdn() { 52 $png_cdn = 'https://s.w.org/images/core/emoji/2.3/72x72/'; 53 $svn_cdn = 'https://s.w.org/images/core/emoji/2.3/svg/'; 54 51 55 $filtered_png_cdn = $this->_filtered_emoji_png_cdn(); 52 56 … … 56 60 57 61 $this->assertContains( wp_json_encode( $filtered_png_cdn ), $output ); 58 $this->assertNotContains( wp_json_encode( $ this->png_cdn ), $output );59 $this->assertContains( wp_json_encode( $ this->svn_cdn ), $output );62 $this->assertNotContains( wp_json_encode( $png_cdn ), $output ); 63 $this->assertContains( wp_json_encode( $svn_cdn ), $output ); 60 64 61 65 remove_filter( 'emoji_url', array( $this, '_filtered_emoji_png_cdn' ) ); 62 66 } 63 67 64 /**65 * @ticket 3529366 */67 public function test_wp_emoji_regex_returns_regexen() {68 $default = wp_emoji_regex();69 $this->assertNotEmpty( $default );70 71 $codepoints = wp_emoji_regex( 'codepoints' );72 $this->assertNotEmpty( $codepoints );73 74 $this->assertSame( $default, $codepoints );75 76 $entities = wp_emoji_regex( 'entities' );77 $this->assertNotEmpty( $entities );78 79 $this->assertNotSame( $default, $entities );80 }81 82 public function data_wp_encode_emoji() {83 return array(84 array(85 // Not emoji86 '’',87 '’',88 ),89 array(90 // Simple emoji91 '🙂',92 '🙂',93 ),94 array(95 // Skin tone, gender, ZWJ, emoji selector96 '👮🏼♀️',97 '👮🏼‍♀️',98 ),99 array(100 // Unicode 10101 '🧚',102 '🧚',103 ),104 );105 }106 107 /**108 * @ticket 35293109 * @dataProvider data_wp_encode_emoji110 */111 public function test_wp_encode_emoji( $emoji, $expected ) {112 $this->assertSame( $expected, wp_encode_emoji( $emoji ) );113 }114 115 public function data_wp_staticize_emoji() {116 $data = array(117 array(118 // Not emoji119 '’',120 '’',121 ),122 array(123 // Simple emoji124 '🙂',125 '<img src="' . $this->png_cdn . '1f642.png" alt="" class="wp-smiley" style="height: 1em; max-height: 1em;" />',126 ),127 array(128 // Skin tone, gender, ZWJ, emoji selector129 '👮🏼♀️',130 '<img src="' . $this->png_cdn . '1f46e-1f3fc-200d-2640-fe0f.png" alt="" class="wp-smiley" style="height: 1em; max-height: 1em;" />',131 ),132 array(133 // Unicode 10134 '🧚',135 '<img src="' . $this->png_cdn . '1f9da.png" alt="" class="wp-smiley" style="height: 1em; max-height: 1em;" />',136 ),137 );138 139 // Older versions of PHP don't html_entity_decode() emoji, so we need to make sure they're testing in the expected form.140 foreach ( $data as $key => $datum ) {141 $emoji = html_entity_decode( wp_encode_emoji( $datum[0] ) );142 $data[ $key ][1] = str_replace( 'alt=""', 'alt="' . $emoji . '"', $datum[1] );143 }144 145 return $data;146 }147 148 /**149 * @ticket 35293150 * @dataProvider data_wp_staticize_emoji151 */152 public function test_wp_staticize_emoji( $emoji, $expected ) {153 $this->assertSame( $expected, wp_staticize_emoji( $emoji ) );154 }155 68 }
Note: See TracChangeset
for help on using the changeset viewer.