diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php index 0a6527a56d..410c0665eb 100644 --- a/tests/phpunit/tests/kses.php +++ b/tests/phpunit/tests/kses.php @@ -8,11 +8,27 @@ class Tests_Kses extends WP_UnitTestCase { /** + * @dataProvider data_wp_filter_post_kses_address * @ticket 20210 + * + * @param string $string Test string for kses. + * @param string $expect_string Expected result after passing through kses. */ - function test_wp_filter_post_kses_address() { + function test_wp_filter_post_kses_address( $string, $expect_string ) { global $allowedposttags; + $this->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', @@ -25,21 +41,43 @@ class Tests_Kses extends WP_UnitTestCase { '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."; - $this->assertSame( $expect_string, wp_kses( $string, $allowedposttags ) ); + + $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() { + 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', @@ -53,6 +91,8 @@ class Tests_Kses extends WP_UnitTestCase { 'download' => '', ); + $data = array(); + foreach ( $attributes as $name => $value ) { if ( $value ) { $attr = "$name='$value'"; @@ -63,8 +103,10 @@ class Tests_Kses extends WP_UnitTestCase { } $string = "I link this"; $expect_string = "I link this"; - $this->assertSame( $expect_string, wp_kses( $string, $allowedposttags ) ); + $data[] = array( $string, $expect_string ); } + + return $data; } /** @@ -122,11 +164,28 @@ class Tests_Kses extends WP_UnitTestCase { } /** + * @dataProvider data_wp_filter_post_kses_abbr * @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_abbr() { + function test_wp_filter_post_kses_abbr( $string, $expect_string ) { global $allowedposttags; + $this->assertSame( $expect_string, wp_kses( $string, $allowedposttags ) ); + } + + /** + * Data provider for data_wp_filter_post_kses_abbr. + * + * @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_abbr() { $attributes = array( 'class' => 'classname', 'id' => 'id', @@ -134,11 +193,15 @@ class Tests_Kses extends WP_UnitTestCase { 'title' => 'title', ); + $data = array(); + foreach ( $attributes as $name => $value ) { $string = "WP"; $expect_string = "WP"; - $this->assertSame( $expect_string, wp_kses( $string, $allowedposttags ) ); + $data[] = array( $string, $expect_string ); } + + return $data; } function test_feed_links() {