Changeset 55562
- Timestamp:
- 03/19/2023 12:03:30 PM (2 years ago)
- Location:
- trunk/tests/phpunit/tests
- Files:
-
- 60 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/includesTemplate.php
r53371 r55562 223 223 * @covers ::settings_errors 224 224 * @global array $wp_settings_errors 225 * @dataProvider settings_errors_css_classes_provider225 * @dataProvider data_settings_errors_css_classes 226 226 */ 227 227 public function test_settings_errors_css_classes( $type, $expected ) { … … 242 242 } 243 243 244 public function settings_errors_css_classes_provider() {244 public function data_settings_errors_css_classes() { 245 245 return array( 246 246 array( 'error', 'notice-error' ), -
trunk/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php
r55337 r55562 74 74 * @param string $expected Expected in SQL query. 75 75 76 * @dataProvider data_ test_columns_should_be_sortable76 * @dataProvider data_columns_should_be_sortable 77 77 * @covers WP_Privacy_Requests_Table::prepare_items 78 78 * @ticket 43960 … … 126 126 * } 127 127 */ 128 public function data_ test_columns_should_be_sortable() {128 public function data_columns_should_be_sortable() { 129 129 return array( 130 130 // Default order (ID) DESC. -
trunk/tests/phpunit/tests/compat/mbStrlen.php
r55036 r55562 18 18 19 19 /** 20 * @dataProvider utf8_string_lengths20 * @dataProvider data_utf8_string_lengths 21 21 */ 22 22 public function test_mb_strlen( $input_string, $expected_character_length ) { … … 25 25 26 26 /** 27 * @dataProvider utf8_string_lengths27 * @dataProvider data_utf8_string_lengths 28 28 */ 29 29 public function test_mb_strlen_via_regex( $input_string, $expected_character_length ) { … … 34 34 35 35 /** 36 * @dataProvider utf8_string_lengths36 * @dataProvider data_utf8_string_lengths 37 37 */ 38 38 public function test_8bit_mb_strlen( $input_string, $expected_character_length, $expected_byte_length ) { … … 45 45 * @return array 46 46 */ 47 public function utf8_string_lengths() {47 public function data_utf8_string_lengths() { 48 48 return array( 49 49 array( -
trunk/tests/phpunit/tests/compat/mbSubstr.php
r55037 r55562 18 18 19 19 /** 20 * @dataProvider utf8_substrings20 * @dataProvider data_utf8_substrings 21 21 */ 22 22 public function test_mb_substr( $input_string, $start, $length, $expected_character_substring ) { … … 25 25 26 26 /** 27 * @dataProvider utf8_substrings27 * @dataProvider data_utf8_substrings 28 28 */ 29 29 public function test_mb_substr_via_regex( $input_string, $start, $length, $expected_character_substring ) { … … 34 34 35 35 /** 36 * @dataProvider utf8_substrings36 * @dataProvider data_utf8_substrings 37 37 */ 38 38 public function test_8bit_mb_substr( $input_string, $start, $length, $expected_character_substring, $expected_byte_substring ) { … … 45 45 * @return array 46 46 */ 47 public function utf8_substrings() {47 public function data_utf8_substrings() { 48 48 return array( 49 49 array( -
trunk/tests/phpunit/tests/date/dateI18n.php
r54230 r55562 204 204 * @ticket 25768 205 205 * 206 * @dataProvider d st_times206 * @dataProvider data_should_handle_dst 207 207 * 208 208 * @param string $time Time to test in Y-m-d H:i:s format. … … 220 220 } 221 221 222 public function d st_times() {222 public function data_should_handle_dst() { 223 223 return array( 224 224 'Before DST start' => array( '2019-03-31 02:59:00', 'Europe/Helsinki' ), -
trunk/tests/phpunit/tests/date/query.php
r55465 r55562 532 532 * @ticket 41782 533 533 * 534 * @dataProvider mysql_datetime_input_provider534 * @dataProvider data_build_mysql_datetime 535 535 * 536 536 * @param array|string $datetime Array or string date input. … … 547 547 } 548 548 549 public function mysql_datetime_input_provider() {549 public function data_build_mysql_datetime() { 550 550 return array( 551 551 array( '2019-06-04T08:18:24+03:00', '2019-06-04 05:18:24' ), … … 565 565 * @ticket 41782 566 566 * 567 * @dataProvider mysql_datetime_input_provider_custom_timezone567 * @dataProvider data_build_mysql_datetime_with_custom_timezone 568 568 * 569 569 * @param array|string $datetime Array or string date input. … … 583 583 } 584 584 585 public function mysql_datetime_input_provider_custom_timezone() {585 public function data_build_mysql_datetime_with_custom_timezone() { 586 586 return array( 587 587 array( '2019-06-04T08:18:24+03:00', '2019-06-04 08:18:24' ), -
trunk/tests/phpunit/tests/date/wpTimezone.php
r54230 r55562 23 23 * @ticket 24730 24 24 * 25 * @dataProvider timezone_offset_provider25 * @dataProvider data_should_convert_gmt_offset 26 26 * 27 27 * @param float $gmt_offset Numeric offset from UTC. … … 40 40 41 41 /** 42 * @ticket 2473043 */44 public function test_should_return_timezone_string() {45 update_option( 'timezone_string', 'Europe/Helsinki' );46 47 $this->assertSame( 'Europe/Helsinki', wp_timezone_string() );48 49 $timezone = wp_timezone();50 51 $this->assertSame( 'Europe/Helsinki', $timezone->getName() );52 }53 54 /**55 * Ensures that deprecated timezone strings are handled correctly.56 *57 * @ticket 5646858 */59 public function test_should_return_deprecated_timezone_string() {60 $tz_string = 'America/Buenos_Aires'; // This timezone was deprecated pre-PHP 5.6.61 update_option( 'timezone_string', $tz_string );62 63 $this->assertSame( $tz_string, wp_timezone_string() );64 65 $timezone = wp_timezone();66 67 $this->assertSame( $tz_string, $timezone->getName() );68 }69 70 /**71 42 * Data provider to test numeric offset conversion. 72 43 * 73 44 * @return array 74 45 */ 75 public function timezone_offset_provider() {46 public function data_should_convert_gmt_offset() { 76 47 return array( 77 48 array( -12, '-12:00' ), … … 135 106 ); 136 107 } 108 109 /** 110 * @ticket 24730 111 */ 112 public function test_should_return_timezone_string() { 113 update_option( 'timezone_string', 'Europe/Helsinki' ); 114 115 $this->assertSame( 'Europe/Helsinki', wp_timezone_string() ); 116 117 $timezone = wp_timezone(); 118 119 $this->assertSame( 'Europe/Helsinki', $timezone->getName() ); 120 } 121 122 /** 123 * Ensures that deprecated timezone strings are handled correctly. 124 * 125 * @ticket 56468 126 */ 127 public function test_should_return_deprecated_timezone_string() { 128 $tz_string = 'America/Buenos_Aires'; // This timezone was deprecated pre-PHP 5.6. 129 update_option( 'timezone_string', $tz_string ); 130 131 $this->assertSame( $tz_string, wp_timezone_string() ); 132 133 $timezone = wp_timezone(); 134 135 $this->assertSame( $tz_string, $timezone->getName() ); 136 } 137 137 } -
trunk/tests/phpunit/tests/db.php
r55151 r55562 579 579 * @param int|string $column The column index to retrieve. 580 580 * 581 * @dataProvider data_ test_get_col581 * @dataProvider data_get_col 582 582 * 583 583 * @ticket 45299 … … 613 613 * @type int|string $column The column index to retrieve. 614 614 */ 615 public function data_ test_get_col() {615 public function data_get_col() { 616 616 global $wpdb; 617 617 … … 2240 2240 2241 2241 /** 2242 * @dataProvider parse_db_host_data_provider2242 * @dataProvider data_parse_db_host 2243 2243 * @ticket 41722 2244 2244 * @ticket 54877 … … 2261 2261 } 2262 2262 2263 public function parse_db_host_data_provider() {2263 public function data_parse_db_host() { 2264 2264 return array( 2265 2265 array( -
trunk/tests/phpunit/tests/db/charset.php
r54384 r55562 774 774 * @ticket 21212 775 775 */ 776 public function data_ test_get_table_charset() {776 public function data_get_table_charset() { 777 777 $table_name = 'test_get_table_charset'; 778 778 … … 789 789 790 790 /** 791 * @dataProvider data_ test_get_table_charset791 * @dataProvider data_get_table_charset 792 792 * @ticket 21212 793 793 * … … 815 815 * @ticket 21212 816 816 */ 817 public function data_ test_get_column_charset() {817 public function data_get_column_charset() { 818 818 $table_name = 'test_get_column_charset'; 819 819 … … 830 830 831 831 /** 832 * @dataProvider data_ test_get_column_charset832 * @dataProvider data_get_column_charset 833 833 * @ticket 21212 834 834 * … … 857 857 858 858 /** 859 * @dataProvider data_ test_get_column_charset859 * @dataProvider data_get_column_charset 860 860 * @ticket 21212 861 861 * … … 884 884 885 885 /** 886 * @dataProvider data_ test_get_column_charset886 * @dataProvider data_get_column_charset 887 887 * @ticket 33501 888 888 * -
trunk/tests/phpunit/tests/feed/rss2.php
r54088 r55562 488 488 * @ticket 4575 489 489 * 490 * @dataProvider data_ test_get_feed_build_date490 * @dataProvider data_get_feed_build_date 491 491 */ 492 492 public function test_get_feed_build_date( $url, $element ) { … … 502 502 503 503 504 public function data_ test_get_feed_build_date() {504 public function data_get_feed_build_date() { 505 505 return array( 506 506 array( '/?feed=rss2', 'rss' ), -
trunk/tests/phpunit/tests/formatting/balanceTags.php
r54727 r55562 8 8 class Tests_Formatting_BalanceTags extends WP_UnitTestCase { 9 9 10 public function nestable_tags() { 11 return array( 12 array( 'article' ), 13 array( 'aside' ), 14 array( 'blockquote' ), 15 array( 'details' ), 16 array( 'div' ), 17 array( 'figure' ), 18 array( 'object' ), 19 array( 'q' ), 20 array( 'section' ), 21 array( 'span' ), 22 ); 23 } 24 25 // This is a complete(?) listing of valid single/self-closing tags. 26 public function single_tags() { 27 return array( 28 array( 'area' ), 29 array( 'base' ), 30 array( 'basefont' ), 31 array( 'br' ), 32 array( 'col' ), 33 array( 'command' ), 34 array( 'embed' ), 35 array( 'frame' ), 36 array( 'hr' ), 37 array( 'img' ), 38 array( 'input' ), 39 array( 'isindex' ), 40 array( 'link' ), 41 array( 'meta' ), 42 array( 'param' ), 43 array( 'source' ), 44 array( 'track' ), 45 array( 'wbr' ), 46 ); 47 } 48 49 public function supported_traditional_tag_names() { 10 /** 11 * @ticket 47014 12 * @dataProvider data_supported_traditional_tag_names 13 */ 14 public function test_detects_traditional_tag_names( $tag ) { 15 $normalized = strtolower( $tag ); 16 17 $this->assertSame( "<$normalized>inside</$normalized>", balanceTags( "<$tag>inside", true ) ); 18 } 19 20 public function data_supported_traditional_tag_names() { 50 21 return array( 51 22 array( 'a' ), … … 59 30 } 60 31 61 public function supported_custom_element_tag_names() { 32 /** 33 * @ticket 47014 34 * @dataProvider data_supported_custom_element_tag_names 35 */ 36 public function test_detects_supported_custom_element_tag_names( $tag ) { 37 $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) ); 38 } 39 40 public function data_supported_custom_element_tag_names() { 62 41 return array( 63 42 array( 'custom-element' ), … … 71 50 } 72 51 73 public function invalid_tag_names() { 52 /** 53 * @ticket 47014 54 * @dataProvider data_invalid_tag_names 55 */ 56 public function test_ignores_invalid_tag_names( $input, $output ) { 57 $this->assertSame( $output, balanceTags( $input, true ) ); 58 } 59 60 public function data_invalid_tag_names() { 74 61 return array( 75 62 array( '<0-day>inside', '<0-day>inside' ), // Can't start with a number - handled by the "<3" fix. … … 79 66 80 67 /** 68 * @ticket 47014 69 * @dataProvider data_unsupported_valid_tag_names 70 */ 71 public function test_ignores_unsupported_custom_tag_names( $tag ) { 72 $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) ); 73 } 74 75 /** 81 76 * These are valid custom elements but we don't support them yet. 82 77 * 83 78 * @see https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name 84 79 */ 85 public function unsupported_valid_tag_names() {80 public function data_unsupported_valid_tag_names() { 86 81 return array( 87 82 // We don't allow ending in a dash. … … 139 134 140 135 /** 136 * @ticket 47014 137 * @dataProvider data_supported_invalid_tag_names 138 */ 139 public function test_detects_supported_invalid_tag_names( $tag ) { 140 $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) ); 141 } 142 143 /** 141 144 * These are invalid custom elements but we support them right now in order to keep the parser simpler. 142 145 * 143 146 * @see https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name 144 147 */ 145 public function supported_invalid_tag_names() {148 public function data_supported_invalid_tag_names() { 146 149 return array( 147 150 // Reserved names for custom elements. … … 158 161 159 162 /** 160 * @ticket 47014161 * @dataProvider supported_traditional_tag_names162 */163 public function test_detects_traditional_tag_names( $tag ) {164 $normalized = strtolower( $tag );165 166 $this->assertSame( "<$normalized>inside</$normalized>", balanceTags( "<$tag>inside", true ) );167 }168 169 /**170 * @ticket 47014171 * @dataProvider supported_custom_element_tag_names172 */173 public function test_detects_supported_custom_element_tag_names( $tag ) {174 $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );175 }176 177 /**178 * @ticket 47014179 * @dataProvider invalid_tag_names180 */181 public function test_ignores_invalid_tag_names( $input, $output ) {182 $this->assertSame( $output, balanceTags( $input, true ) );183 }184 185 /**186 * @ticket 47014187 * @dataProvider unsupported_valid_tag_names188 */189 public function test_ignores_unsupported_custom_tag_names( $tag ) {190 $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) );191 }192 193 /**194 * @ticket 47014195 * @dataProvider supported_invalid_tag_names196 */197 public function test_detects_supported_invalid_tag_names( $tag ) {198 $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );199 }200 201 /**202 163 * If a recognized valid single tag appears unclosed, it should get self-closed 203 164 * 204 165 * @ticket 1597 205 * @dataProvider single_tags166 * @dataProvider data_single_tags 206 167 */ 207 168 public function test_selfcloses_unclosed_known_single_tags( $tag ) { … … 214 175 * 215 176 * @ticket 1597 216 * @dataProvider single_tags177 * @dataProvider data_single_tags 217 178 */ 218 179 public function test_selfcloses_known_single_tags_having_closing_tag( $tag ) { 219 180 $this->assertSame( "<$tag />", balanceTags( "<$tag></$tag>", true ) ); 181 } 182 183 // This is a complete(?) listing of valid single/self-closing tags. 184 public function data_single_tags() { 185 return array( 186 array( 'area' ), 187 array( 'base' ), 188 array( 'basefont' ), 189 array( 'br' ), 190 array( 'col' ), 191 array( 'command' ), 192 array( 'embed' ), 193 array( 'frame' ), 194 array( 'hr' ), 195 array( 'img' ), 196 array( 'input' ), 197 array( 'isindex' ), 198 array( 'link' ), 199 array( 'meta' ), 200 array( 'param' ), 201 array( 'source' ), 202 array( 'track' ), 203 array( 'wbr' ), 204 ); 220 205 } 221 206 … … 275 260 276 261 /** 277 * @dataProvider nestable_tags262 * @dataProvider data_nestable_tags 278 263 */ 279 264 public function test_balances_nestable_tags( $tag ) { … … 292 277 $this->assertSame( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); 293 278 } 279 } 280 281 public function data_nestable_tags() { 282 return array( 283 array( 'article' ), 284 array( 'aside' ), 285 array( 'blockquote' ), 286 array( 'details' ), 287 array( 'div' ), 288 array( 'figure' ), 289 array( 'object' ), 290 array( 'q' ), 291 array( 'section' ), 292 array( 'span' ), 293 ); 294 294 } 295 295 -
trunk/tests/phpunit/tests/formatting/convertSmilies.php
r54134 r55562 10 10 11 11 /** 12 * @dataProvider data_convert_standard_smilies 13 * 14 * Basic Validation Test to confirm that smilies are converted to image 15 * when use_smilies = 1 and not when use_smilies = 0 16 */ 17 public function test_convert_standard_smilies( $in_txt, $converted_txt ) { 18 // Standard smilies, use_smilies: ON. 19 update_option( 'use_smilies', 1 ); 20 21 smilies_init(); 22 23 $this->assertSame( $converted_txt, convert_smilies( $in_txt ) ); 24 25 // Standard smilies, use_smilies: OFF. 26 update_option( 'use_smilies', 0 ); 27 28 $this->assertSame( $in_txt, convert_smilies( $in_txt ) ); 29 } 30 31 /** 12 32 * Basic Test Content DataProvider 13 33 * 14 34 * array ( input_txt, converted_output_txt) 15 35 */ 16 public function get_smilies_input_output() {36 public function data_convert_standard_smilies() { 17 37 $includes_path = includes_url( 'images/smilies/' ); 18 38 … … 46 66 47 67 /** 48 * @dataProvider get_smilies_input_output 49 * 50 * Basic Validation Test to confirm that smilies are converted to image 51 * when use_smilies = 1 and not when use_smilies = 0 52 */ 53 public function test_convert_standard_smilies( $in_txt, $converted_txt ) { 54 // Standard smilies, use_smilies: ON. 55 update_option( 'use_smilies', 1 ); 56 57 smilies_init(); 58 59 $this->assertSame( $converted_txt, convert_smilies( $in_txt ) ); 60 61 // Standard smilies, use_smilies: OFF. 62 update_option( 'use_smilies', 0 ); 63 64 $this->assertSame( $in_txt, convert_smilies( $in_txt ) ); 65 } 66 67 /** 68 * Custom Smilies Test Content DataProvider 69 * 70 * array ( input_txt, converted_output_txt) 71 */ 72 public function get_custom_smilies_input_output() { 73 $includes_path = includes_url( 'images/smilies/' ); 74 75 return array( 76 array( 77 'Peter Brian Gabriel (born 13 February 1950) is a British singer, musician, and songwriter who rose to fame as the lead vocalist and flautist of the progressive rock group Genesis. :monkey:', 78 'Peter Brian Gabriel (born 13 February 1950) is a British singer, musician, and songwriter who rose to fame as the lead vocalist and flautist of the progressive rock group Genesis. <img src="' . $includes_path . 'icon_shock_the_monkey.gif" alt=":monkey:" class="wp-smiley" style="height: 1em; max-height: 1em;" />', 79 ), 80 array( 81 'Star Wars Jedi Knight :arrow: Jedi Academy is a first and third-person shooter action game set in the Star Wars universe. It was developed by Raven Software and published, distributed and marketed by LucasArts in North America and by Activision in the rest of the world. :nervou:', 82 'Star Wars Jedi Knight <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Jedi Academy is a first and third-person shooter action game set in the Star Wars universe. It was developed by Raven Software and published, distributed and marketed by LucasArts in North America and by Activision in the rest of the world. <img src="' . $includes_path . 'icon_nervou.gif" alt=":nervou:" class="wp-smiley" style="height: 1em; max-height: 1em;" />', 83 ), 84 array( 85 ':arrow: monkey: Lorem ipsum dolor sit amet enim. Etiam ullam :PP <br />corper. Suspendisse a pellentesque dui, non felis.<a> :arrow: :arrow</a>', 86 '<img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> monkey: Lorem ipsum dolor sit amet enim. Etiam ullam <img src="' . $includes_path . 'icon_tongue.gif" alt=":PP" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <br />corper. Suspendisse a pellentesque dui, non felis.<a> <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> :arrow</a>', 87 ), 88 ); 89 } 90 91 /** 92 * @dataProvider get_custom_smilies_input_output 68 * @dataProvider data_convert_custom_smilies 93 69 * 94 70 * Validate Custom Smilies are converted to images when use_smilies = 1 … … 125 101 } 126 102 103 /** 104 * Custom Smilies Test Content DataProvider 105 * 106 * array ( input_txt, converted_output_txt) 107 */ 108 public function data_convert_custom_smilies() { 109 $includes_path = includes_url( 'images/smilies/' ); 110 111 return array( 112 array( 113 'Peter Brian Gabriel (born 13 February 1950) is a British singer, musician, and songwriter who rose to fame as the lead vocalist and flautist of the progressive rock group Genesis. :monkey:', 114 'Peter Brian Gabriel (born 13 February 1950) is a British singer, musician, and songwriter who rose to fame as the lead vocalist and flautist of the progressive rock group Genesis. <img src="' . $includes_path . 'icon_shock_the_monkey.gif" alt=":monkey:" class="wp-smiley" style="height: 1em; max-height: 1em;" />', 115 ), 116 array( 117 'Star Wars Jedi Knight :arrow: Jedi Academy is a first and third-person shooter action game set in the Star Wars universe. It was developed by Raven Software and published, distributed and marketed by LucasArts in North America and by Activision in the rest of the world. :nervou:', 118 'Star Wars Jedi Knight <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Jedi Academy is a first and third-person shooter action game set in the Star Wars universe. It was developed by Raven Software and published, distributed and marketed by LucasArts in North America and by Activision in the rest of the world. <img src="' . $includes_path . 'icon_nervou.gif" alt=":nervou:" class="wp-smiley" style="height: 1em; max-height: 1em;" />', 119 ), 120 array( 121 ':arrow: monkey: Lorem ipsum dolor sit amet enim. Etiam ullam :PP <br />corper. Suspendisse a pellentesque dui, non felis.<a> :arrow: :arrow</a>', 122 '<img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> monkey: Lorem ipsum dolor sit amet enim. Etiam ullam <img src="' . $includes_path . 'icon_tongue.gif" alt=":PP" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <br />corper. Suspendisse a pellentesque dui, non felis.<a> <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> :arrow</a>', 123 ), 124 ); 125 } 126 127 /** 128 * Validate Conversion of Smilies is ignored in pre-determined tags 129 * pre, code, script, style 130 * 131 * @ticket 16448 132 * @dataProvider data_ignore_smilies_in_tags 133 */ 134 public function test_ignore_smilies_in_tags( $element ) { 135 $includes_path = includes_url( 'images/smilies/' ); 136 137 $in_str = 'Do we ingore smilies ;-) in ' . $element . ' tags <' . $element . ' class="foo">My Content Here :?: </' . $element . '>'; 138 $exp_str = "Do we ingore smilies \xf0\x9f\x98\x89 in $element tags <$element class=\"foo\">My Content Here :?: </$element>"; 139 140 // Standard smilies, use_smilies: ON. 141 update_option( 'use_smilies', 1 ); 142 smilies_init(); 143 144 $this->assertSame( $exp_str, convert_smilies( $in_str ) ); 145 146 // Standard smilies, use_smilies: OFF. 147 update_option( 'use_smilies', 0 ); 148 } 127 149 128 150 /** 129 151 * DataProvider of HTML elements/tags that smilie matches should be ignored in 130 152 */ 131 public function get_smilies_ignore_tags() {153 public function data_ignore_smilies_in_tags() { 132 154 return array( 133 155 array( 'pre' ), … … 140 162 141 163 /** 142 * Validate Conversion of Smilies is ignored in pre-determined tags 143 * pre, code, script, style 144 * 145 * @ticket 16448 146 * @dataProvider get_smilies_ignore_tags 147 */ 148 public function test_ignore_smilies_in_tags( $element ) { 149 $includes_path = includes_url( 'images/smilies/' ); 150 151 $in_str = 'Do we ingore smilies ;-) in ' . $element . ' tags <' . $element . ' class="foo">My Content Here :?: </' . $element . '>'; 152 $exp_str = "Do we ingore smilies \xf0\x9f\x98\x89 in $element tags <$element class=\"foo\">My Content Here :?: </$element>"; 153 154 // Standard smilies, use_smilies: ON. 155 update_option( 'use_smilies', 1 ); 156 smilies_init(); 157 158 $this->assertSame( $exp_str, convert_smilies( $in_str ) ); 159 160 // Standard smilies, use_smilies: OFF. 161 update_option( 'use_smilies', 0 ); 164 * Validate Combinations of Smilies separated by single space 165 * are converted correctly 166 * 167 * @ticket 20124 168 * @dataProvider data_smilies_combinations 169 */ 170 public function test_smilies_combinations( $in_txt, $converted_txt ) { 171 // Custom smilies, use_smilies: ON. 172 update_option( 'use_smilies', 1 ); 173 smilies_init(); 174 175 $this->assertSame( $converted_txt, convert_smilies( $in_txt ) ); 176 177 // Custom smilies, use_smilies: OFF. 178 update_option( 'use_smilies', 0 ); 179 180 $this->assertSame( $in_txt, convert_smilies( $in_txt ) ); 162 181 } 163 182 … … 165 184 * DataProvider of Smilie Combinations 166 185 */ 167 public function get_smilies_combinations() {186 public function data_smilies_combinations() { 168 187 $includes_path = includes_url( 'images/smilies/' ); 169 188 … … 197 216 198 217 /** 199 * Validate Combinations of Smilies separated by single space200 * are converted correctly201 *202 * @ticket 20124203 * @dataProvider get_smilies_combinations204 */205 public function test_smilies_combinations( $in_txt, $converted_txt ) {206 // Custom smilies, use_smilies: ON.207 update_option( 'use_smilies', 1 );208 smilies_init();209 210 $this->assertSame( $converted_txt, convert_smilies( $in_txt ) );211 212 // Custom smilies, use_smilies: OFF.213 update_option( 'use_smilies', 0 );214 215 $this->assertSame( $in_txt, convert_smilies( $in_txt ) );216 }217 218 /**219 * DataProvider of Single Smilies input and converted output220 */221 public function get_single_smilies_input_output() {222 $includes_path = includes_url( 'images/smilies/' );223 224 return array(225 array(226 '8-O :-(',227 '8-O :-(',228 ),229 array(230 '8O :) additional text here :)',231 '8O <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> additional text here <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" />',232 ),233 array(234 ':) :) :) :)',235 '<img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" />',236 ),237 );238 }239 240 /**241 218 * Validate Smilies are converted for single smilie in 242 219 * the $wpsmiliestrans global array 243 220 * 244 221 * @ticket 25303 245 * @dataProvider get_single_smilies_input_output222 * @dataProvider data_single_smilies_in_wpsmiliestrans 246 223 */ 247 224 public function test_single_smilies_in_wpsmiliestrans( $in_txt, $converted_txt ) { … … 273 250 } 274 251 275 public function get_spaces_around_smilies() { 252 /** 253 * DataProvider of Single Smilies input and converted output 254 */ 255 public function data_single_smilies_in_wpsmiliestrans() { 256 $includes_path = includes_url( 'images/smilies/' ); 257 258 return array( 259 array( 260 '8-O :-(', 261 '8-O :-(', 262 ), 263 array( 264 '8O :) additional text here :)', 265 '8O <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> additional text here <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" />', 266 ), 267 array( 268 ':) :) :) :)', 269 '<img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" />', 270 ), 271 ); 272 } 273 274 /** 275 * Check that $wp_smiliessearch pattern will match smilies 276 * between spaces, but never capture those spaces. 277 * 278 * Further check that spaces aren't randomly deleted 279 * or added when replacing the text with an image. 280 * 281 * @ticket 22692 282 * @dataProvider data_spaces_around_smilies 283 */ 284 public function test_spaces_around_smilies( $in_txt, $converted_txt ) { 285 // Standard smilies, use_smilies: ON. 286 update_option( 'use_smilies', 1 ); 287 288 smilies_init(); 289 290 $this->assertSame( $converted_txt, convert_smilies( $in_txt ) ); 291 292 // Standard smilies, use_smilies: OFF. 293 update_option( 'use_smilies', 0 ); 294 } 295 296 public function data_spaces_around_smilies() { 276 297 $nbsp = "\xC2\xA0"; 277 298 … … 290 311 ), 291 312 ); 292 }293 294 /**295 * Check that $wp_smiliessearch pattern will match smilies296 * between spaces, but never capture those spaces.297 *298 * Further check that spaces aren't randomly deleted299 * or added when replacing the text with an image.300 *301 * @ticket 22692302 * @dataProvider get_spaces_around_smilies303 */304 public function test_spaces_around_smilies( $in_txt, $converted_txt ) {305 // Standard smilies, use_smilies: ON.306 update_option( 'use_smilies', 1 );307 308 smilies_init();309 310 $this->assertSame( $converted_txt, convert_smilies( $in_txt ) );311 312 // Standard smilies, use_smilies: OFF.313 update_option( 'use_smilies', 0 );314 313 } 315 314 -
trunk/tests/phpunit/tests/formatting/date.php
r54230 r55562 131 131 * @ticket 31809 132 132 * 133 * @dataProvider timezone_provider134 * 135 * @covers ::get_gmt_from_date 136 */ 137 public function test_g mt_from_date_correct_time( $timezone_string, $gmt_offset ) {133 * @dataProvider data_timezone_provider 134 * 135 * @covers ::get_gmt_from_date 136 */ 137 public function test_get_gmt_from_date_correct_time( $timezone_string, $gmt_offset ) { 138 138 update_option( 'timezone_string', $timezone_string ); 139 139 update_option( 'gmt_offset', $gmt_offset ); … … 149 149 * @ticket 31809 150 150 * 151 * @dataProvider timezone_provider152 * 153 * @covers ::get_date_from_gmt 154 */ 155 public function test_ date_from_gmt_correct_time( $timezone_string, $gmt_offset ) {151 * @dataProvider data_timezone_provider 152 * 153 * @covers ::get_date_from_gmt 154 */ 155 public function test_get_date_from_gmt_correct_time( $timezone_string, $gmt_offset ) { 156 156 update_option( 'timezone_string', $timezone_string ); 157 157 update_option( 'gmt_offset', $gmt_offset ); … … 167 167 * @ticket 31809 168 168 * 169 * @dataProvider timezone_provider169 * @dataProvider data_timezone_provider 170 170 * 171 171 * @covers ::iso8601_to_datetime … … 231 231 * @return array 232 232 */ 233 public function timezone_provider() {233 public function data_timezone_provider() { 234 234 return array( 235 235 array( -
trunk/tests/phpunit/tests/formatting/ent2ncr.php
r53562 r55562 8 8 class Tests_Formatting_Ent2ncr extends WP_UnitTestCase { 9 9 /** 10 * @dataProvider entities10 * @dataProvider data_entities 11 11 */ 12 12 public function test_converts_named_entities_to_numeric_character_references( $entity, $ncr ) { … … 20 20 * Comments start with "###". 21 21 */ 22 public function entities() {22 public function data_entities() { 23 23 $entities = file( DIR_TESTDATA . '/formatting/entities.txt' ); 24 24 $data_provided = array(); -
trunk/tests/phpunit/tests/formatting/escXml.php
r53562 r55562 10 10 * Test basic escaping 11 11 * 12 * @dataProvider _test_esc_xml_basics_dataprovider12 * @dataProvider data_esc_xml_basics 13 13 * 14 14 * @param string $source The source string to be escaped. … … 28 28 * } 29 29 */ 30 public function _test_esc_xml_basics_dataprovider() {30 public function data_esc_xml_basics() { 31 31 return array( 32 32 // Simple string. … … 85 85 * Test that CDATA Sections are not escaped. 86 86 * 87 * @dataProvider _test_ignores_cdata_sections_dataprovider87 * @dataProvider data_ignores_cdata_sections 88 88 * 89 89 * @param string $source The source string to be escaped. … … 103 103 * } 104 104 */ 105 public function _test_ignores_cdata_sections_dataprovider() {105 public function data_ignores_cdata_sections() { 106 106 return array( 107 107 // basic CDATA Section containing chars that would otherwise be escaped if not in a CDATA Section -
trunk/tests/phpunit/tests/formatting/getBloginfo.php
r54728 r55562 9 9 10 10 /** 11 * @dataProvider locales11 * @dataProvider data_get_bloginfo_language 12 12 * @ticket 28303 13 13 */ … … 23 23 } 24 24 25 public function locales() {25 public function data_get_bloginfo_language() { 26 26 return array( 27 27 // Locale, language code. -
trunk/tests/phpunit/tests/formatting/getUrlInContent.php
r53562 r55562 9 9 10 10 /** 11 * Validate the get_url_in_content function 12 * 13 * @dataProvider data_get_url_in_content 14 */ 15 public function test_get_url_in_content( $in_str, $exp_str ) { 16 $this->assertSame( $exp_str, get_url_in_content( $in_str ) ); 17 } 18 19 /** 11 20 * URL Content Data Provider 12 21 * 13 22 * array ( input_txt, converted_output_txt ) 14 23 */ 15 public function get_input_output() {24 public function data_get_url_in_content() { 16 25 return array( 17 26 array( // Empty content. … … 41 50 ); 42 51 } 43 44 /**45 * Validate the get_url_in_content function46 *47 * @dataProvider get_input_output48 */49 public function test_get_url_in_content( $in_str, $exp_str ) {50 $this->assertSame( $exp_str, get_url_in_content( $in_str ) );51 }52 52 } -
trunk/tests/phpunit/tests/formatting/humanTimeDiff.php
r53562 r55562 12 12 * @group formatting 13 13 * @ticket 38773 14 * @dataProvider data_ test_human_time_diff14 * @dataProvider data_human_time_diff 15 15 */ 16 16 public function test_human_time_diff( $expected, $stopdate, $message ) { … … 20 20 21 21 // Data for test_human_time_diff. 22 public function data_ test_human_time_diff() {22 public function data_human_time_diff() { 23 23 return array( 24 24 array( -
trunk/tests/phpunit/tests/formatting/linksAddTarget.php
r53562 r55562 6 6 */ 7 7 class Tests_Formatting_LinksAddTarget extends WP_UnitTestCase { 8 9 /** 10 * Validate the normalize_whitespace function 11 * 12 * @dataProvider data_links_add_target 13 */ 14 public function test_links_add_target( $content, $target, $tags, $exp_str ) { 15 if ( true === is_null( $target ) ) { 16 $this->assertSame( $exp_str, links_add_target( $content ) ); 17 } elseif ( true === is_null( $tags ) ) { 18 $this->assertSame( $exp_str, links_add_target( $content, $target ) ); 19 } else { 20 $this->assertSame( $exp_str, links_add_target( $content, $target, $tags ) ); 21 } 22 } 23 8 24 /** 9 25 * Test Content DataProvider … … 11 27 * array ( input_txt, converted_output_txt) 12 28 */ 13 public function get_input_output() {29 public function data_links_add_target() { 14 30 return array( 15 31 array( … … 93 109 ); 94 110 } 95 96 /**97 * Validate the normalize_whitespace function98 *99 * @dataProvider get_input_output100 */101 public function test_normalize_whitespace( $content, $target, $tags, $exp_str ) {102 if ( true === is_null( $target ) ) {103 $this->assertSame( $exp_str, links_add_target( $content ) );104 } elseif ( true === is_null( $tags ) ) {105 $this->assertSame( $exp_str, links_add_target( $content, $target ) );106 } else {107 $this->assertSame( $exp_str, links_add_target( $content, $target, $tags ) );108 }109 }110 111 } -
trunk/tests/phpunit/tests/formatting/normalizeWhitespace.php
r53562 r55562 6 6 */ 7 7 class Tests_Formatting_NormalizeWhitespace extends WP_UnitTestCase { 8 9 /** 10 * Validate the normalize_whitespace function 11 * 12 * @dataProvider data_normalize_whitespace 13 */ 14 public function test_normalize_whitespace( $in_str, $exp_str ) { 15 $this->assertSame( $exp_str, normalize_whitespace( $in_str ) ); 16 } 17 8 18 /** 9 19 * WhitespaceTest Content DataProvider … … 11 21 * array( input_txt, converted_output_txt) 12 22 */ 13 public function get_input_output() {23 public function data_normalize_whitespace() { 14 24 return array( 15 25 array( … … 43 53 ); 44 54 } 45 46 /**47 * Validate the normalize_whitespace function48 *49 * @dataProvider get_input_output50 */51 public function test_normalize_whitespace( $in_str, $exp_str ) {52 $this->assertSame( $exp_str, normalize_whitespace( $in_str ) );53 }54 55 } -
trunk/tests/phpunit/tests/formatting/redirect.php
r53571 r55562 19 19 * @ticket 44317 20 20 * 21 * @dataProvider get_bad_status_codes21 * @dataProvider data_wp_redirect_bad_status_code 22 22 * 23 23 * @covers ::wp_redirect … … 32 32 } 33 33 34 public function get_bad_status_codes() {34 public function data_wp_redirect_bad_status_code() { 35 35 return array( 36 36 // Tests for bad arguments. … … 74 74 75 75 /** 76 * @dataProvider valid_url_provider76 * @dataProvider data_wp_validate_redirect_valid_url 77 77 * 78 78 * @covers ::wp_validate_redirect … … 82 82 } 83 83 84 /** 85 * @dataProvider invalid_url_provider 86 * 87 * @covers ::wp_validate_redirect 88 */ 89 public function test_wp_validate_redirect_invalid_url( $url ) { 90 $this->assertEquals( false, wp_validate_redirect( $url, false ) ); 91 } 92 93 public function valid_url_provider() { 84 public function data_wp_validate_redirect_valid_url() { 94 85 return array( 95 86 array( 'http://example.com', 'http://example.com' ), … … 107 98 } 108 99 109 public function invalid_url_provider() { 100 /** 101 * @dataProvider data_wp_validate_redirect_invalid_url 102 * 103 * @covers ::wp_validate_redirect 104 */ 105 public function test_wp_validate_redirect_invalid_url( $url ) { 106 $this->assertEquals( false, wp_validate_redirect( $url, false ) ); 107 } 108 109 public function data_wp_validate_redirect_invalid_url() { 110 110 return array( 111 111 // parse_url() fails. … … 177 177 /** 178 178 * @ticket 47980 179 * @dataProvider relative_url_provider179 * @dataProvider data_wp_validate_redirect_relative_url 180 180 * 181 181 * @covers ::wp_validate_redirect … … 212 212 * } 213 213 */ 214 public function relative_url_provider() {214 public function data_wp_validate_redirect_relative_url() { 215 215 return array( 216 216 array( -
trunk/tests/phpunit/tests/formatting/sanitizeOrderby.php
r53562 r55562 9 9 10 10 /** 11 * @dataProvider valid_orderbys11 * @dataProvider data_sanitize_sql_orderby_valid 12 12 */ 13 public function test_ valid( $orderby ) {13 public function test_sanitize_sql_orderby_valid( $orderby ) { 14 14 $this->assertSame( $orderby, sanitize_sql_orderby( $orderby ) ); 15 15 } 16 public function valid_orderbys() {16 public function data_sanitize_sql_orderby_valid() { 17 17 return array( 18 18 array( '1' ), … … 35 35 36 36 /** 37 * @dataProvider invalid_orderbys37 * @dataProvider data_sanitize_sql_orderby_invalid 38 38 */ 39 public function test_ invalid( $orderby ) {39 public function test_sanitize_sql_orderby_invalid( $orderby ) { 40 40 $this->assertFalse( sanitize_sql_orderby( $orderby ) ); 41 41 } 42 public function invalid_orderbys() {42 public function data_sanitize_sql_orderby_invalid() { 43 43 return array( 44 44 array( '' ), -
trunk/tests/phpunit/tests/formatting/sanitizeTextField.php
r55062 r55562 8 8 */ 9 9 class Tests_Formatting_SanitizeTextField extends WP_UnitTestCase { 10 11 /** 12 * @ticket 32257 13 * @dataProvider data_sanitize_text_field 14 */ 15 public function test_sanitize_text_field( $str, $expected ) { 16 if ( is_array( $expected ) ) { 17 $expected_oneline = $expected['oneline']; 18 $expected_multiline = $expected['multiline']; 19 } else { 20 $expected_oneline = $expected; 21 $expected_multiline = $expected; 22 } 23 $this->assertSame( $expected_oneline, sanitize_text_field( $str ) ); 24 $this->assertSameIgnoreEOL( $expected_multiline, sanitize_textarea_field( $str ) ); 25 26 } 27 10 28 public function data_sanitize_text_field() { 11 29 return array( … … 127 145 ); 128 146 } 129 130 /**131 * @ticket 32257132 * @dataProvider data_sanitize_text_field133 */134 public function test_sanitize_text_field( $str, $expected ) {135 if ( is_array( $expected ) ) {136 $expected_oneline = $expected['oneline'];137 $expected_multiline = $expected['multiline'];138 } else {139 $expected_oneline = $expected;140 $expected_multiline = $expected;141 }142 $this->assertSame( $expected_oneline, sanitize_text_field( $str ) );143 $this->assertSameIgnoreEOL( $expected_multiline, sanitize_textarea_field( $str ) );144 145 }146 147 } -
trunk/tests/phpunit/tests/formatting/sanitizeTrackbackUrls.php
r55064 r55562 9 9 /** 10 10 * @ticket 21624 11 * @dataProvider separators11 * @dataProvider data_sanitize_trackback_urls_with_multiple_urls 12 12 */ 13 13 public function test_sanitize_trackback_urls_with_multiple_urls( $separator ) { … … 18 18 } 19 19 20 public function separators() {20 public function data_sanitize_trackback_urls_with_multiple_urls() { 21 21 return array( 22 22 array( "\r\n\t " ), -
trunk/tests/phpunit/tests/formatting/seemsUtf8.php
r53562 r55562 11 11 * `seems_utf8` returns true for utf-8 strings, false otherwise. 12 12 * 13 * @dataProvider utf8_strings13 * @dataProvider data_seems_utf8_returns_true_for_utf8_strings 14 14 */ 15 public function test_ returns_true_for_utf8_strings( $utf8_string ) {15 public function test_seems_utf8_returns_true_for_utf8_strings( $utf8_string ) { 16 16 // From http://www.i18nguy.com/unicode-example.html 17 17 $this->assertTrue( seems_utf8( $utf8_string ) ); 18 18 } 19 19 20 public function utf8_strings() {20 public function data_seems_utf8_returns_true_for_utf8_strings() { 21 21 $utf8_strings = file( DIR_TESTDATA . '/formatting/utf-8/utf-8.txt' ); 22 22 foreach ( $utf8_strings as &$string ) { … … 28 28 29 29 /** 30 * @dataProvider big5_strings30 * @dataProvider data_seems_utf8_returns_false_for_non_utf8_strings 31 31 */ 32 public function test_ returns_false_for_non_utf8_strings( $big5_string ) {32 public function test_seems_utf8_returns_false_for_non_utf8_strings( $big5_string ) { 33 33 $this->assertFalse( seems_utf8( $big5_string ) ); 34 34 } 35 35 36 public function big5_strings() {36 public function data_seems_utf8_returns_false_for_non_utf8_strings() { 37 37 // Get data from formatting/big5.txt. 38 38 $big5_strings = file( DIR_TESTDATA . '/formatting/big5.txt' ); -
trunk/tests/phpunit/tests/formatting/urlencodeDeep.php
r53562 r55562 12 12 * Data Provider 13 13 */ 14 public function data_ test_values() {14 public function data_urlencode_deep() { 15 15 return array( 16 16 array( 'qwerty123456', 'qwerty123456' ), … … 25 25 * Validate the urlencode_deep function pair by pair 26 26 * 27 * @dataProvider data_ test_values27 * @dataProvider data_urlencode_deep 28 28 * 29 29 * @param string $actual … … 38 38 */ 39 39 public function test_urlencode_deep_should_encode_all_values_in_array() { 40 $data = $this->data_ test_values();40 $data = $this->data_urlencode_deep(); 41 41 42 42 $actual = wp_list_pluck( $data, 0 ); -
trunk/tests/phpunit/tests/functions.php
r55464 r55562 1768 1768 * 1769 1769 * @ticket 42016 1770 * @dataProvider data_ test_validate_file1770 * @dataProvider data_validate_file 1771 1771 * 1772 1772 * @param string $file File path. … … 1789 1789 * } 1790 1790 */ 1791 public function data_ test_validate_file() {1791 public function data_validate_file() { 1792 1792 return array( 1793 1793 … … 1911 1911 * Test stream URL validation. 1912 1912 * 1913 * @dataProvider data_ test_wp_is_stream1913 * @dataProvider data_wp_is_stream 1914 1914 * 1915 1915 * @param string $path The resource path or URL. … … 1934 1934 * } 1935 1935 */ 1936 public function data_ test_wp_is_stream() {1936 public function data_wp_is_stream() { 1937 1937 return array( 1938 1938 // Legitimate stream examples. … … 1955 1955 * 1956 1956 * @ticket 39667 1957 * @dataProvider data_ test_human_readable_duration1957 * @dataProvider data_human_readable_duration 1958 1958 * 1959 1959 * @param string $input Duration. … … 1974 1974 * } 1975 1975 */ 1976 public function data_ test_human_readable_duration() {1976 public function data_human_readable_duration() { 1977 1977 return array( 1978 1978 // Valid ii:ss cases. … … 2031 2031 /** 2032 2032 * @ticket 49404 2033 * @dataProvider data_ test_wp_is_json_media_type2033 * @dataProvider data_wp_is_json_media_type 2034 2034 */ 2035 2035 public function test_wp_is_json_media_type( $input, $expected ) { … … 2038 2038 2039 2039 2040 public function data_ test_wp_is_json_media_type() {2040 public function data_wp_is_json_media_type() { 2041 2041 return array( 2042 2042 array( 'application/ld+json', true ), -
trunk/tests/phpunit/tests/functions/doEnclose.php
r55337 r55562 29 29 * @since 5.3.0 30 30 * 31 * @dataProvider data_ test_do_enclose31 * @dataProvider data_do_enclose 32 32 */ 33 33 public function test_function_with_explicit_content_input( $content, $expected ) { … … 45 45 * @since 5.3.0 46 46 * 47 * @dataProvider data_ test_do_enclose47 * @dataProvider data_do_enclose 48 48 */ 49 49 public function test_function_with_implicit_content_input( $content, $expected ) { … … 73 73 * } 74 74 */ 75 public function data_ test_do_enclose() {75 public function data_do_enclose() { 76 76 return array( 77 77 'null' => array( … … 145 145 */ 146 146 public function test_function_should_delete_enclosed_link_when_no_longer_in_post_content() { 147 $data = $this->data_ test_do_enclose();147 $data = $this->data_do_enclose(); 148 148 149 149 // Create a post with a single movie link. … … 179 179 */ 180 180 public function test_function_should_support_post_object_input() { 181 $data = $this->data_ test_do_enclose();181 $data = $this->data_do_enclose(); 182 182 183 183 $post_object = self::factory()->post->create_and_get( … … 199 199 */ 200 200 public function test_function_enclosure_links_should_be_filterable() { 201 $data = $this->data_ test_do_enclose();201 $data = $this->data_do_enclose(); 202 202 203 203 $post_id = self::factory()->post->create( -
trunk/tests/phpunit/tests/functions/getStatusHeaderDesc.php
r52773 r55562 12 12 13 13 /** 14 * @dataProvider _status_strings14 * @dataProvider data_get_status_header_desc 15 15 * 16 16 * @param int $code HTTP status code. … … 26 26 * @return array 27 27 */ 28 public function _status_strings() {28 public function data_get_status_header_desc() { 29 29 return array( 30 30 array( 200, 'OK' ), -
trunk/tests/phpunit/tests/functions/isNewDay.php
r49006 r55562 12 12 /** 13 13 * @ticket 46627 14 * @dataProvider _data_is_new_date14 * @dataProvider data_is_new_date 15 15 * 16 16 * @param string $currentday_string The day of the current post in the loop. … … 27 27 } 28 28 29 public function _data_is_new_date() {29 public function data_is_new_date() { 30 30 return array( 31 31 array( '21.05.19', '21.05.19', 0 ), -
trunk/tests/phpunit/tests/functions/removeQueryArg.php
r49006 r55562 8 8 9 9 /** 10 * @dataProvider remove_query_arg_provider10 * @dataProvider data_remove_query_arg 11 11 */ 12 12 public function test_remove_query_arg( $keys_to_remove, $url, $expected ) { … … 17 17 } 18 18 19 public function remove_query_arg_provider() {19 public function data_remove_query_arg() { 20 20 return array( 21 21 array( 'foo', 'edit.php?foo=test1&baz=test1', 'edit.php?baz=test1' ), -
trunk/tests/phpunit/tests/functions/sizeFormat.php
r54855 r55562 13 13 class Tests_Functions_SizeFormat extends WP_UnitTestCase { 14 14 15 public function _data_size_format() {15 public function data_size_format() { 16 16 return array( 17 17 // Invalid values. … … 73 73 74 74 /** 75 * @dataProvider _data_size_format75 * @dataProvider data_size_format 76 76 * 77 77 * @param $bytes -
trunk/tests/phpunit/tests/functions/wpListFilter.php
r55076 r55562 10 10 11 11 /** 12 * @dataProvider data_ test_wp_list_filter12 * @dataProvider data_wp_list_filter 13 13 * 14 14 * @param array $input_list An array of objects to filter. … … 22 22 } 23 23 24 public function data_ test_wp_list_filter() {24 public function data_wp_list_filter() { 25 25 return array( 26 26 'string instead of array' => array( -
trunk/tests/phpunit/tests/functions/wpListPluck.php
r55341 r55562 205 205 206 206 /** 207 * @dataProvider data_ test_wp_list_pluck207 * @dataProvider data_wp_list_pluck 208 208 * 209 209 * @param array $input_list List of objects or arrays. … … 216 216 } 217 217 218 public function data_ test_wp_list_pluck() {218 public function data_wp_list_pluck() { 219 219 return array( 220 220 'arrays' => array( -
trunk/tests/phpunit/tests/functions/wpListSort.php
r55078 r55562 10 10 11 11 /** 12 * @dataProvider data_ test_wp_list_sort12 * @dataProvider data_wp_list_sort 13 13 * 14 14 * @param string|array $orderby Either the field name to order by or an array … … 20 20 } 21 21 22 public function data_ test_wp_list_sort() {22 public function data_wp_list_sort() { 23 23 return array( 24 24 'single orderby ascending' => array( … … 335 335 336 336 /** 337 * @dataProvider data_ test_wp_list_sort_preserve_keys337 * @dataProvider data_wp_list_sort_preserve_keys 338 338 * 339 339 * @param string|array $orderby Either the field name to order by or an array … … 345 345 } 346 346 347 public function data_ test_wp_list_sort_preserve_keys() {347 public function data_wp_list_sort_preserve_keys() { 348 348 return array( 349 349 'single orderby ascending' => array( -
trunk/tests/phpunit/tests/http/http.php
r55370 r55562 13 13 * @ticket 56231 14 14 * 15 * @dataProvider make_absolute_url_testcases15 * @dataProvider data_make_absolute_url 16 16 * 17 17 * @covers WP_Http::make_absolute_url … … 22 22 } 23 23 24 public function make_absolute_url_testcases() {24 public function data_make_absolute_url() { 25 25 // 0: The Location header, 1: The current URL, 3: The expected URL. 26 26 return array( … … 81 81 82 82 /** 83 * @dataProvider parse_url_testcases83 * @dataProvider data_wp_parse_url 84 84 * 85 85 * @covers ::wp_parse_url … … 90 90 } 91 91 92 public function parse_url_testcases() {92 public function data_wp_parse_url() { 93 93 // 0: The URL, 1: The expected resulting structure. 94 94 return array( … … 218 218 * @ticket 36356 219 219 * 220 * @dataProvider parse_url_component_testcases220 * @dataProvider data_wp_parse_url_with_component 221 221 * 222 222 * @covers ::wp_parse_url … … 227 227 } 228 228 229 public function parse_url_component_testcases() {229 public function data_wp_parse_url_with_component() { 230 230 // 0: The URL, 1: The requested component, 2: The expected resulting structure. 231 231 return array( … … 334 334 * @ticket 36356 335 335 * 336 * @dataProvider get_component_from_parsed_url_array_testcases336 * @dataProvider data_get_component_from_parsed_url_array 337 337 * 338 338 * @covers ::wp_parse_url … … 345 345 } 346 346 347 public function get_component_from_parsed_url_array_testcases() {347 public function data_get_component_from_parsed_url_array() { 348 348 // 0: A URL, 1: PHP URL constant, 2: The expected result. 349 349 return array( … … 376 376 * @ticket 36356 377 377 * 378 * @dataProvider wp_translate_php_url_constant_to_key_testcases378 * @dataProvider data_wp_translate_php_url_constant_to_key 379 379 * 380 380 * @covers ::_wp_translate_php_url_constant_to_key … … 385 385 } 386 386 387 public function wp_translate_php_url_constant_to_key_testcases() {387 public function data_wp_translate_php_url_constant_to_key() { 388 388 // 0: PHP URL constant, 1: The expected result. 389 389 return array( -
trunk/tests/phpunit/tests/image/editor.php
r54417 r55562 289 289 * 290 290 * @ticket 35725 291 * @dataProvider _test_wp_get_webp_info291 * @dataProvider data_wp_get_webp_info 292 292 * 293 293 */ … … 306 306 * Data provider for test_wp_get_webp_info(). 307 307 */ 308 public function _test_wp_get_webp_info() {308 public function data_wp_get_webp_info() { 309 309 return array( 310 310 // Standard JPEG. -
trunk/tests/phpunit/tests/kses.php
r55430 r55562 938 938 * @ticket 55966 939 939 * @ticket 56122 940 * @dataProvider data_ test_safecss_filter_attr940 * @dataProvider data_safecss_filter_attr 941 941 * 942 942 * @param string $css A string of CSS rules. … … 957 957 * } 958 958 */ 959 public function data_ test_safecss_filter_attr() {959 public function data_safecss_filter_attr() { 960 960 return array( 961 961 // Empty input, empty output. … … 1569 1569 * @ticket 37134 1570 1570 * 1571 * @dataProvider data_ test_safecss_filter_attr_filtered1571 * @dataProvider data_safecss_filter_attr_filtered 1572 1572 * 1573 1573 * @param string $css A string of CSS rules. … … 1590 1590 * } 1591 1591 */ 1592 public function data_ test_safecss_filter_attr_filtered() {1592 public function data_safecss_filter_attr_filtered() { 1593 1593 return array( 1594 1594 -
trunk/tests/phpunit/tests/l10n/loadScriptTextdomain.php
r54349 r55562 15 15 * @ticket 49145 16 16 * 17 * @dataProvider data_ test_resolve_relative_path17 * @dataProvider data_resolve_relative_path 18 18 */ 19 19 public function test_resolve_relative_path( $translation_path, $handle, $src, $textdomain, $filter = array() ) { … … 27 27 } 28 28 29 public function data_ test_resolve_relative_path() {29 public function data_resolve_relative_path() { 30 30 return array( 31 31 // @ticket 45528 -
trunk/tests/phpunit/tests/meta/isProtectedMeta.php
r54896 r55562 8 8 9 9 /** 10 * @dataProvider protected_data10 * @dataProvider data_is_protected_meta_true 11 11 */ 12 public function test_ protected( $key ) {12 public function test_is_protected_meta_true( $key ) { 13 13 $this->assertTrue( is_protected_meta( $key ) ); 14 14 } 15 15 16 public function protected_data() {16 public function data_is_protected_meta_true() { 17 17 $protected_keys = array( 18 18 array( '_wp_attachment' ), … … 30 30 31 31 /** 32 * @dataProvider unprotected_data32 * @dataProvider data_is_protected_meta_false 33 33 */ 34 public function test_ unprotected( $key ) {34 public function test_is_protected_meta_false( $key ) { 35 35 $this->assertFalse( is_protected_meta( $key ) ); 36 36 } 37 37 38 public function unprotected_data() {38 public function data_is_protected_meta_false() { 39 39 $unprotected_keys = array( 40 40 array( 'singleword' ), -
trunk/tests/phpunit/tests/oembed/filterResult.php
r52010 r55562 94 94 } 95 95 96 public function _data_oembed_test_strings() {96 public function data_wp_filter_pre_oembed_custom_result() { 97 97 return array( 98 98 array( … … 116 116 117 117 /** 118 * @dataProvider _data_oembed_test_strings118 * @dataProvider data_wp_filter_pre_oembed_custom_result 119 119 */ 120 120 public function test_wp_filter_pre_oembed_custom_result( $html, $expected ) { -
trunk/tests/phpunit/tests/option/sanitizeOption.php
r54229 r55562 7 7 8 8 /** 9 * @dataProvider data_sanitize_option 10 * 11 * @covers ::sanitize_option 12 */ 13 public function test_sanitize_option( $option_name, $sanitized, $original ) { 14 $this->assertSame( $sanitized, sanitize_option( $option_name, $original ) ); 15 } 16 /** 9 17 * Data provider to test all of the sanitize_option() case 10 18 * … … 13 21 * @return array 14 22 */ 15 public function sanitize_option_provider() {23 public function data_sanitize_option() { 16 24 return array( 17 25 array( 'admin_email', 'mail@example.com', 'mail@example.com' ), … … 87 95 88 96 /** 89 * @dataProvider sanitize_option_provider97 * @dataProvider data_sanitize_option_upload_path 90 98 * 91 99 * @covers ::sanitize_option 92 100 */ 93 public function test_sanitize_option ( $option_name, $sanitized, $original) {94 $this->assertSame( $ sanitized, sanitize_option( $option_name, $original) );101 public function test_sanitize_option_upload_path( $provided, $expected ) { 102 $this->assertSame( $expected, sanitize_option( 'upload_path', $provided ) ); 95 103 } 96 104 97 public function upload_path_provider() {105 public function data_sanitize_option_upload_path() { 98 106 return array( 99 107 array( '<a href="http://www.example.com">Link</a>', 'Link' ), … … 102 110 array( '\path\to\things', '\path\to\things' ), 103 111 ); 104 }105 106 /**107 * @dataProvider upload_path_provider108 *109 * @covers ::sanitize_option110 */111 public function test_sanitize_option_upload_path( $provided, $expected ) {112 $this->assertSame( $expected, sanitize_option( 'upload_path', $provided ) );113 112 } 114 113 … … 134 133 135 134 /** 136 * @dataProvider permalink_structure_provider135 * @dataProvider data_sanitize_option_permalink_structure 137 136 * 138 137 * @covers ::sanitize_option 139 138 * @covers ::get_settings_errors 140 139 */ 141 public function test_sanitize_ permalink_structure( $provided, $expected, $valid ) {140 public function test_sanitize_option_permalink_structure( $provided, $expected, $valid ) { 142 141 global $wp_settings_errors; 143 142 … … 160 159 } 161 160 162 public function permalink_structure_provider() {161 public function data_sanitize_option_permalink_structure() { 163 162 return array( 164 163 array( '', '', true ), -
trunk/tests/phpunit/tests/pomo/pluralForms.php
r48999 r55562 40 40 /** 41 41 * @ticket 41562 42 * @dataProvider data_locales 42 43 * @group external-http 43 44 */ 44 public function test_locales_provider() { 45 $locales = self::locales_provider(); 45 public function test_regression( $lang, $nplurals, $expression ) { 46 require_once dirname( dirname( __DIR__ ) ) . '/includes/plural-form-function.php'; 47 48 $parenthesized = self::parenthesize_plural_expression( $expression ); 49 $old_style = tests_make_plural_form_function( $nplurals, $parenthesized ); 50 $plural_forms = new Plural_Forms( $expression ); 51 52 $generated_old = array(); 53 $generated_new = array(); 54 55 foreach ( range( 0, 200 ) as $i ) { 56 $generated_old[] = $old_style( $i ); 57 $generated_new[] = $plural_forms->get( $i ); 58 } 59 60 $this->assertSame( $generated_old, $generated_new ); 61 } 62 63 /** 64 * @ticket 41562 65 * @group external-http 66 */ 67 public function test_locales_file_not_empty() { 68 $locales = self::data_locales(); 46 69 47 70 $this->assertNotEmpty( $locales, 'Unable to retrieve GP_Locales file' ); 48 71 } 49 72 50 public static function locales_provider() {73 public static function data_locales() { 51 74 if ( ! class_exists( 'GP_Locales' ) ) { 52 75 $filename = download_url( 'https://raw.githubusercontent.com/GlotPress/GlotPress-WP/develop/locales/locales.php' ); … … 71 94 /** 72 95 * @ticket 41562 73 * @dataProvider locales_provider 74 * @group external-http 75 */ 76 public function test_regression( $lang, $nplurals, $expression ) { 77 require_once dirname( dirname( __DIR__ ) ) . '/includes/plural-form-function.php'; 78 79 $parenthesized = self::parenthesize_plural_expression( $expression ); 80 $old_style = tests_make_plural_form_function( $nplurals, $parenthesized ); 81 $plural_forms = new Plural_Forms( $expression ); 82 83 $generated_old = array(); 84 $generated_new = array(); 85 86 foreach ( range( 0, 200 ) as $i ) { 87 $generated_old[] = $old_style( $i ); 88 $generated_new[] = $plural_forms->get( $i ); 89 } 90 91 $this->assertSame( $generated_old, $generated_new ); 92 } 93 94 public static function simple_provider() { 96 * @dataProvider data_simple 97 */ 98 public function test_simple( $expression, $expected ) { 99 $plural_forms = new Plural_Forms( $expression ); 100 $actual = array(); 101 foreach ( array_keys( $expected ) as $num ) { 102 $actual[ $num ] = $plural_forms->get( $num ); 103 } 104 105 $this->assertSame( $expected, $actual ); 106 } 107 108 public static function data_simple() { 95 109 return array( 96 110 array( … … 144 158 145 159 /** 146 * @ticket 41562 147 * @dataProvider simple_provider 148 */ 149 public function test_simple( $expression, $expected ) { 160 * Ensures that an exception is thrown when an invalid plural form is encountered. 161 * 162 * @ticket 41562 163 * @dataProvider data_exceptions 164 */ 165 public function test_exceptions( $expression, $expected_message, $call_get ) { 166 $this->expectException( 'Exception' ); 167 $this->expectExceptionMessage( $expected_message ); 168 150 169 $plural_forms = new Plural_Forms( $expression ); 151 $actual = array(); 152 foreach ( array_keys( $expected ) as $num ) { 153 $actual[ $num ] = $plural_forms->get( $num ); 154 } 155 156 $this->assertSame( $expected, $actual ); 170 if ( $call_get ) { 171 $plural_forms->get( 1 ); 172 } 157 173 } 158 174 … … 195 211 ), 196 212 ); 197 }198 199 /**200 * Ensures that an exception is thrown when an invalid plural form is encountered.201 *202 * @ticket 41562203 * @dataProvider data_exceptions204 */205 public function test_exceptions( $expression, $expected_message, $call_get ) {206 $this->expectException( 'Exception' );207 $this->expectExceptionMessage( $expected_message );208 209 $plural_forms = new Plural_Forms( $expression );210 if ( $call_get ) {211 $plural_forms->get( 1 );212 }213 213 } 214 214 -
trunk/tests/phpunit/tests/post/nav-menu.php
r55035 r55562 967 967 968 968 /** 969 * @ticket 43401 970 * @dataProvider data_iri_current_menu_item 971 */ 972 public function test_iri_current_menu_item( $custom_link, $current = true ) { 973 wp_update_nav_menu_item( 974 $this->menu_id, 975 0, 976 array( 977 'menu-item-status' => 'publish', 978 'menu-item-type' => 'custom', 979 'menu-item-url' => $custom_link, 980 ) 981 ); 982 983 $this->go_to( site_url( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82/' ) ); 984 985 $menu_items = wp_get_nav_menu_items( $this->menu_id ); 986 _wp_menu_item_classes_by_context( $menu_items ); 987 988 $classes = $menu_items[0]->classes; 989 990 if ( $current ) { 991 $this->assertContains( 'current-menu-item', $classes ); 992 } else { 993 $this->assertNotContains( 'current-menu-item', $classes ); 994 } 995 } 996 997 /** 969 998 * Provides IRI matching data for _wp_menu_item_classes_by_context() test. 970 999 */ 971 public function get_iri_current_menu_items() {1000 public function data_iri_current_menu_item() { 972 1001 return array( 973 1002 array( site_url( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82/' ) ), … … 981 1010 982 1011 /** 983 * @ticket 43401984 * @dataProvider get_iri_current_menu_items985 */986 public function test_iri_current_menu_item( $custom_link, $current = true ) {987 wp_update_nav_menu_item(988 $this->menu_id,989 0,990 array(991 'menu-item-status' => 'publish',992 'menu-item-type' => 'custom',993 'menu-item-url' => $custom_link,994 )995 );996 997 $this->go_to( site_url( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82/' ) );998 999 $menu_items = wp_get_nav_menu_items( $this->menu_id );1000 _wp_menu_item_classes_by_context( $menu_items );1001 1002 $classes = $menu_items[0]->classes;1003 1004 if ( $current ) {1005 $this->assertContains( 'current-menu-item', $classes );1006 } else {1007 $this->assertNotContains( 'current-menu-item', $classes );1008 }1009 }1010 1011 /**1012 1012 * @ticket 44005 1013 1013 * @group privacy -
trunk/tests/phpunit/tests/post/query.php
r53942 r55562 713 713 } 714 714 715 public function set_found_posts_provider() { 715 /** 716 * @ticket 42860 717 * 718 * @dataProvider data_set_found_posts_not_posts_as_an_array 719 */ 720 public function test_set_found_posts_not_posts_as_an_array( $posts, $expected ) { 721 $q = new WP_Query( 722 array( 723 'post_type' => 'wptests_pt', 724 'posts_per_page' => 1, 725 ) 726 ); 727 728 $q->posts = $posts; 729 730 $methd = new ReflectionMethod( 'WP_Query', 'set_found_posts' ); 731 $methd->setAccessible( true ); 732 $methd->invoke( $q, array( 'no_found_rows' => false ), array() ); 733 734 $this->assertSame( $expected, $q->found_posts ); 735 } 736 737 public function data_set_found_posts_not_posts_as_an_array() { 716 738 // Count return 0 for null, but 1 for other data you may not expect. 717 739 return array( … … 724 746 725 747 /** 726 * @ticket 42860727 *728 * @dataProvider set_found_posts_provider729 */730 public function test_set_found_posts_not_posts_as_an_array( $posts, $expected ) {731 $q = new WP_Query(732 array(733 'post_type' => 'wptests_pt',734 'posts_per_page' => 1,735 )736 );737 738 $q->posts = $posts;739 740 $methd = new ReflectionMethod( 'WP_Query', 'set_found_posts' );741 $methd->setAccessible( true );742 $methd->invoke( $q, array( 'no_found_rows' => false ), array() );743 744 $this->assertSame( $expected, $q->found_posts );745 }746 747 /**748 748 * @ticket 42469 749 749 */ -
trunk/tests/phpunit/tests/post/wpUniquePostSlug.php
r52010 r55562 129 129 130 130 /** 131 * @dataProvider allowed_post_statuses131 * @dataProvider data_allowed_post_statuses_should_not_be_forced_to_be_unique 132 132 */ 133 133 public function test_allowed_post_statuses_should_not_be_forced_to_be_unique( $status ) { … … 150 150 } 151 151 152 public function allowed_post_statuses() {152 public function data_allowed_post_statuses_should_not_be_forced_to_be_unique() { 153 153 return array( 154 154 array( 'draft' ), -
trunk/tests/phpunit/tests/rest-api.php
r55116 r55562 26 26 remove_filter( 'wp_rest_server_class', array( $this, 'filter_wp_rest_server_class' ) ); 27 27 parent::tear_down(); 28 } 29 30 public function filter_wp_rest_server_class( $class_name ) { 31 return 'Spy_REST_Server'; 28 32 } 29 33 … … 823 827 } 824 828 825 public function jsonp_callback_provider() { 829 /** 830 * @dataProvider data_jsonp_callback_check 831 */ 832 public function test_jsonp_callback_check( $callback, $expected ) { 833 $this->assertSame( $expected, wp_check_jsonp_callback( $callback ) ); 834 } 835 836 public function data_jsonp_callback_check() { 826 837 return array( 827 838 // Standard names. … … 842 853 843 854 /** 844 * @dataProvider jsonp_callback_provider845 */ 846 public function test_ jsonp_callback_check( $callback, $expected ) {847 $this->assert Same( $expected, wp_check_jsonp_callback( $callback) );848 } 849 850 public function rest_date_provider() {855 * @dataProvider data_rest_parse_date 856 */ 857 public function test_rest_parse_date( $date, $expected ) { 858 $this->assertEquals( $expected, rest_parse_date( $date ) ); 859 } 860 861 public function data_rest_parse_date() { 851 862 return array( 852 863 // Valid dates with timezones. … … 874 885 875 886 /** 876 * @dataProvider rest_date_provider877 */ 878 public function test_rest_parse_date ( $date, $expected ) {879 $this->assert Equals( $expected, rest_parse_date( $date ) );880 } 881 882 public function rest_date_force_utc_provider() {887 * @dataProvider data_rest_parse_date_force_utc 888 */ 889 public function test_rest_parse_date_force_utc( $date, $expected ) { 890 $this->assertSame( $expected, rest_parse_date( $date, true ) ); 891 } 892 893 public function data_rest_parse_date_force_utc() { 883 894 return array( 884 895 // Valid dates with timezones. … … 903 914 array( '2017', false ), 904 915 ); 905 }906 907 /**908 * @dataProvider rest_date_force_utc_provider909 */910 public function test_rest_parse_date_force_utc( $date, $expected ) {911 $this->assertSame( $expected, rest_parse_date( $date, true ) );912 }913 914 public function filter_wp_rest_server_class( $class_name ) {915 return 'Spy_REST_Server';916 916 } 917 917 … … 1784 1784 1785 1785 /** 1786 * @dataProvider rest_ensure_response_data_provider1786 * @dataProvider data_rest_ensure_response_returns_instance_of_wp_rest_response 1787 1787 * 1788 1788 * @param mixed $response The response passed to rest_ensure_response(). … … 1800 1800 * @return array 1801 1801 */ 1802 public function rest_ensure_response_data_provider() {1802 public function data_rest_ensure_response_returns_instance_of_wp_rest_response() { 1803 1803 return array( 1804 1804 array( null, null ), -
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r55457 r55562 136 136 } 137 137 138 public static function disposition_provider() { 138 /** 139 * @dataProvider data_parse_disposition 140 */ 141 public function test_parse_disposition( $header, $expected ) { 142 $header_list = array( $header ); 143 $parsed = WP_REST_Attachments_Controller::get_filename_from_disposition( $header_list ); 144 $this->assertSame( $expected, $parsed ); 145 } 146 147 public static function data_parse_disposition() { 139 148 return array( 140 149 // Types. … … 166 175 array( 'unknown; notfilename="foo.jpg"', null ), 167 176 ); 168 }169 170 /**171 * @dataProvider disposition_provider172 */173 public function test_parse_disposition( $header, $expected ) {174 $header_list = array( $header );175 $parsed = WP_REST_Attachments_Controller::get_filename_from_disposition( $header_list );176 $this->assertSame( $expected, $parsed );177 177 } 178 178 … … 1258 1258 } 1259 1259 1260 public static function attachment_roundtrip_provider() { 1260 /** 1261 * @dataProvider data_attachment_roundtrip_as_author 1262 * @requires function imagejpeg 1263 */ 1264 public function test_attachment_roundtrip_as_author( $raw, $expected ) { 1265 wp_set_current_user( self::$author_id ); 1266 $this->assertFalse( current_user_can( 'unfiltered_html' ) ); 1267 $this->verify_attachment_roundtrip( $raw, $expected ); 1268 } 1269 1270 public static function data_attachment_roundtrip_as_author() { 1261 1271 return array( 1262 1272 array( … … 1353 1363 ), 1354 1364 ); 1355 }1356 1357 /**1358 * @dataProvider attachment_roundtrip_provider1359 * @requires function imagejpeg1360 */1361 public function test_post_roundtrip_as_author( $raw, $expected ) {1362 wp_set_current_user( self::$author_id );1363 $this->assertFalse( current_user_can( 'unfiltered_html' ) );1364 $this->verify_attachment_roundtrip( $raw, $expected );1365 1365 } 1366 1366 -
trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php
r55457 r55562 1145 1145 } 1146 1146 1147 public function comment_dates_provider() {1147 public function data_comment_dates() { 1148 1148 return array( 1149 1149 'set date without timezone' => array( … … 1191 1191 1192 1192 /** 1193 * @dataProvider comment_dates_provider1193 * @dataProvider data_comment_dates 1194 1194 */ 1195 1195 public function test_create_comment_date( $params, $results ) { … … 2339 2339 2340 2340 /** 2341 * @dataProvider comment_dates_provider2341 * @dataProvider data_comment_dates 2342 2342 */ 2343 2343 public function test_update_comment_date( $params, $results ) { -
trunk/tests/phpunit/tests/rest-api/rest-post-meta-fields.php
r55457 r55562 2054 2054 * @ticket 43392 2055 2055 * @ticket 48363 2056 * @dataProvider _dp_meta_values_are_not_set_to_null_in_response_if_type_safely_serializable2056 * @dataProvider data_meta_values_are_not_set_to_null_in_response_if_type_safely_serializable 2057 2057 */ 2058 2058 public function test_meta_values_are_not_set_to_null_in_response_if_type_safely_serializable( $type, $stored, $expected ) { … … 2075 2075 } 2076 2076 2077 public function _dp_meta_values_are_not_set_to_null_in_response_if_type_safely_serializable() {2077 public function data_meta_values_are_not_set_to_null_in_response_if_type_safely_serializable() { 2078 2078 return array( 2079 2079 array( 'boolean', 'true', true ), -
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r55457 r55562 2358 2358 } 2359 2359 2360 public function post_dates_provider() {2360 public function data_post_dates() { 2361 2361 $all_statuses = array( 2362 2362 'draft', … … 2429 2429 2430 2430 /** 2431 * @dataProvider post_dates_provider2431 * @dataProvider data_post_dates 2432 2432 */ 2433 2433 public function test_create_post_date( $status, $params, $results ) { … … 3478 3478 3479 3479 /** 3480 * @dataProvider post_dates_provider3480 * @dataProvider data_post_dates 3481 3481 */ 3482 3482 public function test_update_post_date( $status, $params, $results ) { … … 4033 4033 } 4034 4034 4035 public static function post_roundtrip_provider() { 4035 /** 4036 * @dataProvider data_post_roundtrip_as_author 4037 */ 4038 public function test_post_roundtrip_as_author( $raw, $expected ) { 4039 wp_set_current_user( self::$author_id ); 4040 4041 $this->assertFalse( current_user_can( 'unfiltered_html' ) ); 4042 $this->verify_post_roundtrip( $raw, $expected ); 4043 } 4044 4045 public static function data_post_roundtrip_as_author() { 4036 4046 return array( 4037 4047 array( … … 4128 4138 ), 4129 4139 ); 4130 }4131 4132 /**4133 * @dataProvider post_roundtrip_provider4134 */4135 public function test_post_roundtrip_as_author( $raw, $expected ) {4136 wp_set_current_user( self::$author_id );4137 4138 $this->assertFalse( current_user_can( 'unfiltered_html' ) );4139 $this->verify_post_roundtrip( $raw, $expected );4140 4140 } 4141 4141 -
trunk/tests/phpunit/tests/rest-api/rest-request.php
r55457 r55562 58 58 } 59 59 60 public static function header_provider() { 60 /** 61 * @dataProvider data_header_canonicalization 62 * @param string $original Original header key. 63 * @param string $expected Expected canonicalized version. 64 */ 65 public function test_header_canonicalization( $original, $expected ) { 66 $this->assertSame( $expected, $this->request->canonicalize_header_name( $original ) ); 67 } 68 69 public static function data_header_canonicalization() { 61 70 return array( 62 71 array( 'Test', 'test' ), … … 70 79 71 80 /** 72 * @dataProvider header_provider 73 * @param string $original Original header key. 74 * @param string $expected Expected canonicalized version. 75 */ 76 public function test_header_canonicalization( $original, $expected ) { 77 $this->assertSame( $expected, $this->request->canonicalize_header_name( $original ) ); 78 } 79 80 public static function content_type_provider() { 81 return array( 82 // Check basic parsing. 83 array( 'application/x-wp-example', 'application/x-wp-example', 'application', 'x-wp-example', '' ), 84 array( 'application/x-wp-example; charset=utf-8', 'application/x-wp-example', 'application', 'x-wp-example', 'charset=utf-8' ), 85 86 // Check case insensitivity. 87 array( 'APPLICATION/x-WP-Example', 'application/x-wp-example', 'application', 'x-wp-example', '' ), 88 ); 89 } 90 91 /** 92 * @dataProvider content_type_provider 81 * @dataProvider data_content_type_parsing 93 82 * 94 83 * @param string $header Header value. … … 111 100 } 112 101 102 public static function data_content_type_parsing() { 103 return array( 104 // Check basic parsing. 105 array( 'application/x-wp-example', 'application/x-wp-example', 'application', 'x-wp-example', '' ), 106 array( 'application/x-wp-example; charset=utf-8', 'application/x-wp-example', 'application', 'x-wp-example', 'charset=utf-8' ), 107 108 // Check case insensitivity. 109 array( 'APPLICATION/x-WP-Example', 'application/x-wp-example', 'application', 'x-wp-example', '' ), 110 ); 111 } 112 113 113 protected function request_with_parameters() { 114 114 $this->request->set_url_params( … … 187 187 } 188 188 189 public static function alternate_json_content_type_provider() { 189 /** 190 * @ticket 49404 191 * @dataProvider data_alternate_json_content_type 192 * 193 * @param string $content_type The Content-Type header. 194 * @param string $source The source value. 195 * @param bool $accept_json The accept_json value. 196 */ 197 public function test_alternate_json_content_type( $content_type, $source, $accept_json ) { 198 $this->request_with_parameters(); 199 200 $this->request->set_method( 'POST' ); 201 $this->request->set_header( 'Content-Type', $content_type ); 202 $this->request->set_attributes( array( 'accept_json' => true ) ); 203 204 // Check that JSON takes precedence. 205 $this->assertSame( $source, $this->request->get_param( 'source' ) ); 206 $this->assertEquals( $accept_json, $this->request->get_param( 'has_json_params' ) ); 207 } 208 209 public static function data_alternate_json_content_type() { 190 210 return array( 191 211 array( 'application/ld+json', 'json', true ), … … 200 220 /** 201 221 * @ticket 49404 202 * @dataProvider alternate_json_content_type_provider222 * @dataProvider data_is_json_content_type 203 223 * 204 224 * @param string $content_type The Content-Type header. 205 * @param string $source The source value. 206 * @param bool $accept_json The accept_json value. 207 */ 208 public function test_alternate_json_content_type( $content_type, $source, $accept_json ) { 225 * @param bool $is_json The is_json value. 226 */ 227 public function test_is_json_content_type( $content_type, $is_json ) { 209 228 $this->request_with_parameters(); 210 229 211 $this->request->set_method( 'POST' );212 230 $this->request->set_header( 'Content-Type', $content_type ); 213 $this->request->set_attributes( array( 'accept_json' => true ) ); 214 215 // Check that JSON takes precedence. 216 $this->assertSame( $source, $this->request->get_param( 'source' ) ); 217 $this->assertEquals( $accept_json, $this->request->get_param( 'has_json_params' ) ); 218 } 219 220 public static function is_json_content_type_provider() { 231 232 // Check for JSON Content-Type. 233 $this->assertSame( $is_json, $this->request->is_json_content_type() ); 234 } 235 236 public static function data_is_json_content_type() { 221 237 return array( 222 238 array( 'application/ld+json', true ), … … 231 247 /** 232 248 * @ticket 49404 233 * @dataProvider is_json_content_type_provider234 *235 * @param string $content_type The Content-Type header.236 * @param bool $is_json The is_json value.237 */238 public function test_is_json_content_type( $content_type, $is_json ) {239 $this->request_with_parameters();240 241 $this->request->set_header( 'Content-Type', $content_type );242 243 // Check for JSON Content-Type.244 $this->assertSame( $is_json, $this->request->is_json_content_type() );245 }246 247 /**248 * @ticket 49404249 249 */ 250 250 public function test_content_type_cache() { … … 311 311 } 312 312 313 public function non_post_http_methods_with_request_body_provider() {314 return array(315 array( 'PUT' ),316 array( 'PATCH' ),317 array( 'DELETE' ),318 );319 }320 321 313 /** 322 314 * Tests that methods supporting request bodies have access to the … … 324 316 * other methods `WP_REST_Request` needs to parse the body for us. 325 317 * 326 * @dataProvider non_post_http_methods_with_request_body_provider318 * @dataProvider data_non_post_body_parameters 327 319 */ 328 320 public function test_non_post_body_parameters( $request_method ) { … … 346 338 } 347 339 340 public function data_non_post_body_parameters() { 341 return array( 342 array( 'PUT' ), 343 array( 'PATCH' ), 344 array( 'DELETE' ), 345 ); 346 } 347 348 348 public function test_parameters_for_json_put() { 349 349 $data = array( -
trunk/tests/phpunit/tests/rest-api/rest-server.php
r55457 r55562 50 50 } 51 51 52 public function filter_wp_rest_server_class() { 53 return 'Spy_REST_Server'; 54 } 55 52 56 public function test_envelope() { 53 57 $data = array( … … 1005 1009 1006 1010 /** 1007 * @dataProvider _dp_response_to_data_embedding1011 * @dataProvider data_response_to_data_embedding 1008 1012 */ 1009 1013 public function test_response_to_data_embedding( $expected, $embed ) { … … 1023 1027 } 1024 1028 1025 public function _dp_response_to_data_embedding() {1029 public function data_response_to_data_embedding() { 1026 1030 return array( 1027 1031 array( … … 1460 1464 $result = rest_get_server()->serve_request( '/test/data\\with\\slashes' ); 1461 1465 $this->assertSame( 'data\\with\\slashes', rest_get_server()->last_request->get_header( 'x_my_header' ) ); 1462 }1463 1464 public function filter_wp_rest_server_class() {1465 return 'Spy_REST_Server';1466 1466 } 1467 1467 -
trunk/tests/phpunit/tests/rest-api/wpRestTemplatesController.php
r55457 r55562 170 170 /** 171 171 * @ticket 54507 172 * @dataProvider get_template_endpoint_urls172 * @dataProvider data_get_item_works_with_a_single_slash 173 173 */ 174 174 public function test_get_item_works_with_a_single_slash( $endpoint_url ) { … … 204 204 } 205 205 206 public function get_template_endpoint_urls() {206 public function data_get_item_works_with_a_single_slash() { 207 207 return array( 208 208 array( '/wp/v2/templates/default/my_template' ), … … 376 376 /** 377 377 * @ticket 54507 378 * @dataProvider get_template_ids_to_sanitize378 * @dataProvider data_sanitize_template_id 379 379 */ 380 380 public function test_sanitize_template_id( $input_id, $sanitized_id ) { … … 386 386 } 387 387 388 public function get_template_ids_to_sanitize() {388 public function data_sanitize_template_id() { 389 389 return array( 390 390 array( 'tt1-blocks/index', 'tt1-blocks//index' ), -
trunk/tests/phpunit/tests/rewrite/rewriteTags.php
r51568 r55562 21 21 } 22 22 23 public function _invalid_rewrite_tags() {24 return array(25 array( 'foo', 'bar' ),26 array( '%', 'bar' ),27 array( '%a', 'bar' ),28 array( 'a%', 'bar' ),29 array( '%%', 'bar' ),30 array( '', 'bar' ),31 );32 }33 34 23 /** 35 * @dataProvider _invalid_rewrite_tags24 * @dataProvider data_add_rewrite_tag_invalid 36 25 * 37 26 * @param string $tag Rewrite tag. … … 45 34 $this->assertSameSets( $this->rewritereplace, $wp_rewrite->rewritereplace ); 46 35 $this->assertSameSets( $this->queryreplace, $wp_rewrite->queryreplace ); 36 } 37 38 public function data_add_rewrite_tag_invalid() { 39 return array( 40 array( 'foo', 'bar' ), 41 array( '%', 'bar' ), 42 array( '%a', 'bar' ), 43 array( 'a%', 'bar' ), 44 array( '%%', 'bar' ), 45 array( '', 'bar' ), 46 ); 47 47 } 48 48 -
trunk/tests/phpunit/tests/shortcode.php
r55119 r55562 405 405 } 406 406 407 public function data_test_strip_shortcodes() { 407 /** 408 * @ticket 10326 409 * 410 * @dataProvider data_strip_shortcodes 411 * 412 * @param string $expected Expected output. 413 * @param string $content Content to run strip_shortcodes() on. 414 */ 415 public function test_strip_shortcodes( $expected, $content ) { 416 $this->assertSame( $expected, strip_shortcodes( $content ) ); 417 } 418 419 public function data_strip_shortcodes() { 408 420 return array( 409 421 array( 'before', 'before[gallery]' ), … … 421 433 422 434 /** 423 * @ticket 10326424 *425 * @dataProvider data_test_strip_shortcodes426 *427 * @param string $expected Expected output.428 * @param string $content Content to run strip_shortcodes() on.429 */430 public function test_strip_shortcodes( $expected, $content ) {431 $this->assertSame( $expected, strip_shortcodes( $content ) );432 }433 434 /**435 435 * @ticket 37767 436 436 */ -
trunk/tests/phpunit/tests/sitemaps/functions.php
r52010 r55562 64 64 * Test get_sitemap_url() with plain permalinks. 65 65 * 66 * @dataProvider plain_permalinks_provider66 * @dataProvider data_get_sitemap_url_plain_permalinks 67 67 */ 68 68 public function test_get_sitemap_url_plain_permalinks( $name, $subtype_name, $page, $expected ) { … … 75 75 * Test get_sitemap_url() with pretty permalinks. 76 76 * 77 * @dataProvider pretty_permalinks_provider77 * @dataProvider data_get_sitemap_url_pretty_permalinks 78 78 */ 79 79 public function test_get_sitemap_url_pretty_permalinks( $name, $subtype_name, $page, $expected ) { … … 97 97 * } 98 98 */ 99 public function plain_permalinks_provider() {99 public function data_get_sitemap_url_plain_permalinks() { 100 100 return array( 101 101 array( 'posts', 'post', 1, home_url( '/?sitemap=posts&sitemap-subtype=post&paged=1' ) ), … … 129 129 * } 130 130 */ 131 public function pretty_permalinks_provider() {131 public function data_get_sitemap_url_pretty_permalinks() { 132 132 return array( 133 133 array( 'posts', 'post', 1, home_url( '/wp-sitemap-posts-post-1.xml' ) ), -
trunk/tests/phpunit/tests/term/wpGenerateTagCloud.php
r53687 r55562 9 9 * Testing when passed $tags array is empty 10 10 * 11 * @dataProvider empty_tags_data_provider11 * @dataProvider data_empty_tags 12 12 * 13 13 * @param $expected Expected output from `wp_generate_tag_cloud()`. … … 22 22 * Testing when no tags are found 23 23 * 24 * @dataProvider empty_tags_data_provider24 * @dataProvider data_empty_tags 25 25 * 26 26 * @param $expected Expected output from `wp_generate_tag_cloud()`. … … 42 42 * @return array 43 43 */ 44 public function empty_tags_data_provider() {44 public function data_empty_tags() { 45 45 return array( 46 46 // When 'format' => 'array', we should be getting an empty array back. -
trunk/tests/phpunit/tests/user/capabilities.php
r54865 r55562 1315 1315 } 1316 1316 1317 public function authorless_post_statuses() {1318 return array( array( 'draft' ), array( 'private' ), array( 'publish' ) );1319 }1320 1321 1317 /** 1322 1318 * @ticket 27020 1323 * @dataProvider authorless_post_statuses1319 * @dataProvider data_authorless_post 1324 1320 */ 1325 1321 public function test_authorless_post( $status ) { … … 1348 1344 $this->assertFalse( $contributor->has_cap( 'delete_post', $post ) ); 1349 1345 $this->assertSame( 'publish' === $status, $contributor->has_cap( 'read_post', $post ) ); 1346 } 1347 1348 public function data_authorless_post() { 1349 return array( array( 'draft' ), array( 'private' ), array( 'publish' ) ); 1350 1350 } 1351 1351 -
trunk/tests/phpunit/tests/user/query.php
r54889 r55562 187 187 188 188 /** 189 * @dataProvider orderby_should_convert_non_prefixed_keys_data189 * @dataProvider data_orderby_should_convert_non_prefixed_keys 190 190 */ 191 191 public function test_orderby_should_convert_non_prefixed_keys( $short_key, $full_key ) { … … 199 199 } 200 200 201 public function orderby_should_convert_non_prefixed_keys_data() {201 public function data_orderby_should_convert_non_prefixed_keys() { 202 202 return array( 203 203 array( 'nicename', 'user_nicename' ),
Note: See TracChangeset
for help on using the changeset viewer.