Changeset 52010 for trunk/tests/phpunit/tests/kses.php
- Timestamp:
- 11/04/2021 03:22:47 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/kses.php
r51963 r52010 15 15 * @param string $expect_string Expected result after passing through kses. 16 16 */ 17 function test_wp_filter_post_kses_address( $string, $expect_string ) {17 public function test_wp_filter_post_kses_address( $string, $expect_string ) { 18 18 global $allowedposttags; 19 19 … … 29 29 * } 30 30 */ 31 function data_wp_filter_post_kses_address() {31 public function data_wp_filter_post_kses_address() { 32 32 $attributes = array( 33 33 'class' => 'classname', … … 64 64 * @return void 65 65 */ 66 function test_wp_filter_post_kses_a( $string, $expect_string ) {66 public function test_wp_filter_post_kses_a( $string, $expect_string ) { 67 67 global $allowedposttags; 68 68 … … 78 78 * } 79 79 */ 80 function data_wp_filter_post_kses_a() {80 public function data_wp_filter_post_kses_a() { 81 81 $attributes = array( 82 82 'class' => 'classname', … … 121 121 * @param string $expected Expected output following KSES parsing. 122 122 */ 123 function test_wp_kses_video( $source, $context, $expected ) {123 public function test_wp_kses_video( $source, $context, $expected ) { 124 124 $actual = wp_kses( $source, $context ); 125 125 $this->assertSame( $expected, $actual ); … … 135 135 * } 136 136 */ 137 function data_wp_kses_video() {137 public function data_wp_kses_video() { 138 138 return array( 139 139 // Set 0: Valid post object params in post context. … … 172 172 * @return void 173 173 */ 174 function test_wp_filter_post_kses_abbr( $string, $expect_string ) {174 public function test_wp_filter_post_kses_abbr( $string, $expect_string ) { 175 175 global $allowedposttags; 176 176 … … 186 186 * } 187 187 */ 188 function data_wp_filter_post_kses_abbr() {188 public function data_wp_filter_post_kses_abbr() { 189 189 $attributes = array( 190 190 'class' => 'classname', … … 205 205 } 206 206 207 function test_feed_links() {207 public function test_feed_links() { 208 208 global $allowedposttags; 209 209 … … 239 239 } 240 240 241 function test_wp_kses_bad_protocol() {241 public function test_wp_kses_bad_protocol() { 242 242 $bad = array( 243 243 'dummy:alert(1)', … … 475 475 } 476 476 477 function _wp_kses_allowed_html_filter( $html, $context ) {477 public function wp_kses_allowed_html_filter( $html, $context ) { 478 478 if ( 'post' === $context ) { 479 479 return array( 'a' => array( 'href' => true ) ); … … 524 524 $this->assertSame( $custom_tags, wp_kses_allowed_html( $custom_tags ) ); 525 525 526 add_filter( 'wp_kses_allowed_html', array( $this, ' _wp_kses_allowed_html_filter' ), 10, 2 );526 add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html_filter' ), 10, 2 ); 527 527 528 528 $this->assertSame( array( 'a' => array( 'href' => true ) ), wp_kses_allowed_html( 'post' ) ); 529 529 $this->assertSame( array( 'a' => array( 'href' => false ) ), wp_kses_allowed_html( 'data' ) ); 530 530 531 remove_filter( 'wp_kses_allowed_html', array( $this, ' _wp_kses_allowed_html_filter' ) );531 remove_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html_filter' ) ); 532 532 $this->assertSame( $allowedposttags, wp_kses_allowed_html( 'post' ) ); 533 533 $this->assertSame( $allowedtags, wp_kses_allowed_html( 'data' ) ); 534 534 } 535 535 536 function test_hyphenated_tag() {536 public function test_hyphenated_tag() { 537 537 $string = '<hyphenated-tag attribute="value" otherattribute="value2">Alot of hyphens.</hyphenated-tag>'; 538 538 $custom_tags = array( … … 569 569 * @dataProvider data_ctrl_removal 570 570 */ 571 function test_ctrl_removal( $input, $output ) {571 public function test_ctrl_removal( $input, $output ) { 572 572 global $allowedposttags; 573 573 … … 575 575 } 576 576 577 function data_ctrl_removal() {577 public function data_ctrl_removal() { 578 578 return array( 579 579 array( … … 606 606 * @dataProvider data_slash_zero_removal 607 607 */ 608 function test_slash_zero_removal( $input, $output ) {608 public function test_slash_zero_removal( $input, $output ) { 609 609 global $allowedposttags; 610 610 … … 612 612 } 613 613 614 function data_slash_zero_removal() {614 public function data_slash_zero_removal() { 615 615 return array( 616 616 array( … … 658 658 * @dataProvider data_hair_parse 659 659 */ 660 function test_hair_parse( $input, $output ) {660 public function test_hair_parse( $input, $output ) { 661 661 return $this->assertSame( $output, wp_kses_hair_parse( $input ) ); 662 662 } 663 663 664 function data_hair_parse() {664 public function data_hair_parse() { 665 665 return array( 666 666 array( … … 724 724 * @dataProvider data_attr_parse 725 725 */ 726 function test_attr_parse( $input, $output ) {726 public function test_attr_parse( $input, $output ) { 727 727 return $this->assertSame( $output, wp_kses_attr_parse( $input ) ); 728 728 } 729 729 730 function data_attr_parse() {730 public function data_attr_parse() { 731 731 return array( 732 732 array( … … 782 782 * @dataProvider data_one_attr 783 783 */ 784 function test_one_attr( $element, $input, $output ) {784 public function test_one_attr( $element, $input, $output ) { 785 785 return $this->assertSame( $output, wp_kses_one_attr( $input, $element ) ); 786 786 } 787 787 788 function data_one_attr() {788 public function data_one_attr() { 789 789 return array( 790 790 array( … … 859 859 * @ticket 34063 860 860 */ 861 function test_bdo() {861 public function test_bdo() { 862 862 global $allowedposttags; 863 863 … … 870 870 * @ticket 35079 871 871 */ 872 function test_ol_reversed() {872 public function test_ol_reversed() { 873 873 global $allowedposttags; 874 874 … … 881 881 * @ticket 40680 882 882 */ 883 function test_wp_kses_attr_no_attributes_allowed_with_empty_array() {883 public function test_wp_kses_attr_no_attributes_allowed_with_empty_array() { 884 884 $element = 'foo'; 885 885 $attribute = 'title="foo" class="bar"'; … … 891 891 * @ticket 40680 892 892 */ 893 function test_wp_kses_attr_no_attributes_allowed_with_true() {893 public function test_wp_kses_attr_no_attributes_allowed_with_true() { 894 894 $element = 'foo'; 895 895 $attribute = 'title="foo" class="bar"'; … … 901 901 * @ticket 40680 902 902 */ 903 function test_wp_kses_attr_single_attribute_is_allowed() {903 public function test_wp_kses_attr_single_attribute_is_allowed() { 904 904 $element = 'foo'; 905 905 $attribute = 'title="foo" class="bar"'; … … 911 911 * @ticket 43312 912 912 */ 913 function test_wp_kses_attr_no_attributes_allowed_with_false() {913 public function test_wp_kses_attr_no_attributes_allowed_with_false() { 914 914 $element = 'foo'; 915 915 $attribute = 'title="foo" class="bar"'; … … 1117 1117 * @ticket 33121 1118 1118 */ 1119 function test_wp_kses_attr_data_attribute_is_allowed() {1119 public function test_wp_kses_attr_data_attribute_is_allowed() { 1120 1120 $test = '<div data-foo="foo" data-bar="bar" datainvalid="gone" data--invaild="gone" data-also-invaild-="gone" data-two-hyphens="remains">Pens and pencils</div>'; 1121 1121 $expected = '<div data-foo="foo" data-bar="bar" data-two-hyphens="remains">Pens and pencils</div>'; … … 1129 1129 * @ticket 33121 1130 1130 */ 1131 function test_wildcard_requires_hyphen_after_prefix() {1131 public function test_wildcard_requires_hyphen_after_prefix() { 1132 1132 $allowed_html = array( 1133 1133 'div' => array( … … 1150 1150 * @ticket 33121 1151 1151 */ 1152 function test_wildcard_allows_two_hyphens() {1152 public function test_wildcard_allows_two_hyphens() { 1153 1153 $allowed_html = array( 1154 1154 'div' => array( … … 1172 1172 * @ticket 33121 1173 1173 */ 1174 function test_wildcard_attribute_prefixes( $wildcard_attribute, $expected ) {1174 public function test_wildcard_attribute_prefixes( $wildcard_attribute, $expected ) { 1175 1175 $allowed_html = array( 1176 1176 'div' => array( … … 1193 1193 * [1] The outcome of `wp_kses_attr_check` for the prefix. 1194 1194 */ 1195 function data_wildcard_attribute_prefixes() {1195 public function data_wildcard_attribute_prefixes() { 1196 1196 return array( 1197 1197 // Ends correctly. … … 1219 1219 * @param $expected string The sanitized style attribute. 1220 1220 */ 1221 function test_kses_style_attr_with_url( $input, $expected ) {1221 public function test_kses_style_attr_with_url( $input, $expected ) { 1222 1222 $actual = safecss_filter_attr( $input ); 1223 1223 … … 1230 1230 * @return array Nested array of input, expected pairs. 1231 1231 */ 1232 function data_kses_style_attr_with_url() {1232 public function data_kses_style_attr_with_url() { 1233 1233 return array( 1234 1234 /* … … 1463 1463 * @ticket 50731 1464 1464 */ 1465 function test_wp_kses_img_tag_standard_attributes() {1465 public function test_wp_kses_img_tag_standard_attributes() { 1466 1466 $html = array( 1467 1467 '<img', … … 1485 1485 * @ticket 53156 1486 1486 */ 1487 function test_wp_kses_main_tag_standard_attributes() {1487 public function test_wp_kses_main_tag_standard_attributes() { 1488 1488 $test = array( 1489 1489 '<main',
Note: See TracChangeset
for help on using the changeset viewer.