assertSame( $expect_string, wp_kses( $string, $allowedposttags ) ); } /** * Data provider for test_wp_filter_post_kses_address. * * @return array[] Arguments { * @type string $string Test string for kses. * @type string $expect_string Expected result after passing through kses. * } */ function data_wp_filter_post_kses_address() { $attributes = array( 'class' => 'classname', 'id' => 'id', 'style' => array( 'color: red;', 'color: red', 'color: red; text-align:center', 'color: red; text-align:center;', ), 'title' => 'title', ); $data = array(); foreach ( $attributes as $name => $values ) { foreach ( (array) $values as $value ) { $string = "
1 WordPress Avenue, The Internet.
"; $expect_string = "
1 WordPress Avenue, The Internet.
"; $data[] = array( $string, $expect_string ); } } return $data; } /** * @dataProvider data_wp_filter_post_kses_a * @ticket 20210 * * @param string $string Test string for kses. * @param string $expect_string Expected result after passing through kses. * @return void */ function test_wp_filter_post_kses_a( $string, $expect_string ) { global $allowedposttags; $this->assertSame( $expect_string, wp_kses( $string, $allowedposttags ) ); } /** * Data provider for test_wp_filter_post_kses_a. * * @return array[] Arguments { * @type string $string Test string for kses. * @type string $expect_string Expected result after passing through kses. * } */ function data_wp_filter_post_kses_a() { $attributes = array( 'class' => 'classname', 'id' => 'id', 'style' => 'color: red;', 'title' => 'title', 'href' => 'http://example.com', 'rel' => 'related', 'rev' => 'revision', 'name' => 'name', 'target' => '_blank', 'download' => '', ); $data = array(); foreach ( $attributes as $name => $value ) { if ( $value ) { $attr = "$name='$value'"; $expected_attr = "$name='" . trim( $value, ';' ) . "'"; } else { $attr = $name; $expected_attr = $name; } $string = "I link this"; $expect_string = "I link this"; $data[] = array( $string, $expect_string ); } return $data; } /** * Test video tag. * * @ticket 50167 * @ticket 29826 * @dataProvider data_wp_kses_video * * @param string $source Source HTML. * @param string $context Context to use for parsing source. * @param string $expected Expected output following KSES parsing. */ function test_wp_kses_video( $source, $context, $expected ) { $actual = wp_kses( $source, $context ); $this->assertSame( $expected, $actual ); } /** * Data provider for test_wp_kses_video * * @return array[] Array containing test data { * @type string $source Source HTML. * @type string $context Context to use for parsing source. * @type string $expected Expected output following KSES parsing. * } */ function data_wp_kses_video() { return array( // Set 0: Valid post object params in post context. array( '