From 8f5999fe47d4dc48161d6a10f27652fea9d84940 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sat, 8 Oct 2016 00:29:20 +0000 Subject: [PATCH] HTTP API: Convert the POST redirect test to use a dataProvider in order for its speed to be more accurately measured. See #38237 git-svn-id: https://develop.svn.wordpress.org/trunk@38757 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/http/base.php | 44 ++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php index e1e5b0747c..d28c0a68e9 100644 --- a/tests/phpunit/tests/http/base.php +++ b/tests/phpunit/tests/http/base.php @@ -269,26 +269,40 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { /** * Test POST redirection methods * + * @dataProvider data_post_redirect_to_method_300 + * * @ticket 17588 */ - function test_post_redirect_to_method_300() { + function test_post_redirect_to_method_300( $response_code, $method ) { $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?post-redirect-to-method=1'; - // Test 300 - POST to POST - $res = wp_remote_post( add_query_arg( 'response_code', 300, $url ), array( 'timeout' => 30 ) ); - $this->assertEquals( 'POST', wp_remote_retrieve_body( $res ) ); + $res = wp_remote_post( add_query_arg( 'response_code', $response_code, $url ), array( 'timeout' => 30 ) ); + $this->assertEquals( $method, wp_remote_retrieve_body( $res ) ); + } - // Test 301 - POST to POST - $res = wp_remote_post( add_query_arg( 'response_code', 301, $url ), array( 'timeout' => 30 ) ); - $this->assertEquals( 'POST', wp_remote_retrieve_body( $res ) ); - - // Test 302 - POST to GET - $res = wp_remote_post( add_query_arg( 'response_code', 302, $url ), array( 'timeout' => 30 ) ); - $this->assertEquals( 'GET', wp_remote_retrieve_body( $res ) ); - - // Test 303 - POST to GET - $res = wp_remote_post( add_query_arg( 'response_code', 303, $url ), array( 'timeout' => 30 ) ); - $this->assertEquals( 'GET', wp_remote_retrieve_body( $res ) ); + public function data_post_redirect_to_method_300() { + return array( + // Test 300 - POST to POST + array( + 300, + 'POST', + ), + // Test 301 - POST to POST + array( + 301, + 'POST', + ), + // Test 302 - POST to GET + array( + 302, + 'GET', + ), + // Test 303 - POST to GET + array( + 303, + 'GET', + ), + ); } /**