mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Coding Standards: Add visibility to methods in tests/phpunit/tests/.
Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods. Adds a `private` visibility to helper methods within test classes. Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit. Props costdev, jrf, hellofromTonya. Fixes #54177. git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -30,7 +30,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
/**
|
||||
* Checks that the main classes are loaded.
|
||||
*/
|
||||
function test_rest_api_active() {
|
||||
public function test_rest_api_active() {
|
||||
$this->assertTrue( class_exists( 'WP_REST_Server' ) );
|
||||
$this->assertTrue( class_exists( 'WP_REST_Request' ) );
|
||||
$this->assertTrue( class_exists( 'WP_REST_Response' ) );
|
||||
@@ -41,7 +41,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
* The rest_api_init hook should have been registered with init, and should
|
||||
* have a default priority of 10.
|
||||
*/
|
||||
function test_init_action_added() {
|
||||
public function test_init_action_added() {
|
||||
$this->assertSame( 10, has_action( 'init', 'rest_api_init' ) );
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
/**
|
||||
* The rest_route query variable should be registered.
|
||||
*/
|
||||
function test_rest_route_query_var() {
|
||||
public function test_rest_route_query_var() {
|
||||
rest_api_init();
|
||||
$this->assertContains( 'rest_route', $GLOBALS['wp']->public_query_vars );
|
||||
}
|
||||
@@ -933,7 +933,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
$this->assertSame( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true ) );
|
||||
}
|
||||
|
||||
function test_rest_preload_api_request_with_method() {
|
||||
public function test_rest_preload_api_request_with_method() {
|
||||
$rest_server = $GLOBALS['wp_rest_server'];
|
||||
$GLOBALS['wp_rest_server'] = null;
|
||||
|
||||
@@ -957,7 +957,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 51636
|
||||
*/
|
||||
function test_rest_preload_api_request_removes_trailing_slashes() {
|
||||
public function test_rest_preload_api_request_removes_trailing_slashes() {
|
||||
$rest_server = $GLOBALS['wp_rest_server'];
|
||||
$GLOBALS['wp_rest_server'] = null;
|
||||
|
||||
@@ -982,7 +982,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 40614
|
||||
*/
|
||||
function test_rest_ensure_request_accepts_path_string() {
|
||||
public function test_rest_ensure_request_accepts_path_string() {
|
||||
$request = rest_ensure_request( '/wp/v2/posts' );
|
||||
$this->assertInstanceOf( 'WP_REST_Request', $request );
|
||||
$this->assertSame( '/wp/v2/posts', $request->get_route() );
|
||||
@@ -990,13 +990,13 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider _dp_rest_parse_embed_param
|
||||
* @dataProvider data_rest_parse_embed_param
|
||||
*/
|
||||
public function test_rest_parse_embed_param( $expected, $embed ) {
|
||||
$this->assertSame( $expected, rest_parse_embed_param( $embed ) );
|
||||
}
|
||||
|
||||
public function _dp_rest_parse_embed_param() {
|
||||
public function data_rest_parse_embed_param() {
|
||||
return array(
|
||||
array( true, '' ),
|
||||
array( true, null ),
|
||||
@@ -1019,7 +1019,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 48819
|
||||
*
|
||||
* @dataProvider _dp_rest_filter_response_by_context
|
||||
* @dataProvider data_rest_filter_response_by_context
|
||||
*/
|
||||
public function test_rest_filter_response_by_context( $schema, $data, $expected ) {
|
||||
$this->assertSame( $expected, rest_filter_response_by_context( $data, $schema, 'view' ) );
|
||||
@@ -1106,7 +1106,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
$this->assertTrue( $registered );
|
||||
}
|
||||
|
||||
public function _dp_rest_filter_response_by_context() {
|
||||
public function data_rest_filter_response_by_context() {
|
||||
return array(
|
||||
'default' => array(
|
||||
array(
|
||||
@@ -1777,7 +1777,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function test_rest_ensure_response_accepts_wp_error_and_returns_wp_error() {
|
||||
public function test_rest_ensure_response_accepts_wp_error_and_returns_wp_error() {
|
||||
$response = rest_ensure_response( new WP_Error() );
|
||||
$this->assertInstanceOf( 'WP_Error', $response );
|
||||
}
|
||||
@@ -1788,7 +1788,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
* @param mixed $response The response passed to rest_ensure_response().
|
||||
* @param mixed $expected_data The expected data a response should include.
|
||||
*/
|
||||
function test_rest_ensure_response_returns_instance_of_wp_rest_response( $response, $expected_data ) {
|
||||
public function test_rest_ensure_response_returns_instance_of_wp_rest_response( $response, $expected_data ) {
|
||||
$response_object = rest_ensure_response( $response );
|
||||
$this->assertInstanceOf( 'WP_REST_Response', $response_object );
|
||||
$this->assertSame( $expected_data, $response_object->get_data() );
|
||||
@@ -1799,7 +1799,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function rest_ensure_response_data_provider() {
|
||||
public function rest_ensure_response_data_provider() {
|
||||
return array(
|
||||
array( null, null ),
|
||||
array( array( 'chocolate' => 'cookies' ), array( 'chocolate' => 'cookies' ) ),
|
||||
@@ -2009,7 +2009,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50300
|
||||
*
|
||||
* @dataProvider _dp_rest_is_object
|
||||
* @dataProvider data_rest_is_object
|
||||
*
|
||||
* @param bool $expected Expected result of the check.
|
||||
* @param mixed $value The value to check.
|
||||
@@ -2024,7 +2024,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public function _dp_rest_is_object() {
|
||||
public function data_rest_is_object() {
|
||||
return array(
|
||||
array(
|
||||
true,
|
||||
@@ -2072,7 +2072,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50300
|
||||
*
|
||||
* @dataProvider _dp_rest_sanitize_object
|
||||
* @dataProvider data_rest_sanitize_object
|
||||
*
|
||||
* @param array $expected Expected sanitized version.
|
||||
* @param mixed $value The value to sanitize.
|
||||
@@ -2082,7 +2082,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
$this->assertSame( $expected, $sanitized );
|
||||
}
|
||||
|
||||
public function _dp_rest_sanitize_object() {
|
||||
public function data_rest_sanitize_object() {
|
||||
return array(
|
||||
array(
|
||||
array(),
|
||||
@@ -2130,7 +2130,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50300
|
||||
*
|
||||
* @dataProvider _dp_rest_is_array
|
||||
* @dataProvider data_rest_is_array
|
||||
*
|
||||
* @param bool $expected Expected result of the check.
|
||||
* @param mixed $value The value to check.
|
||||
@@ -2145,7 +2145,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public function _dp_rest_is_array() {
|
||||
public function data_rest_is_array() {
|
||||
return array(
|
||||
array(
|
||||
true,
|
||||
@@ -2201,7 +2201,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50300
|
||||
*
|
||||
* @dataProvider _dp_rest_sanitize_array
|
||||
* @dataProvider data_rest_sanitize_array
|
||||
*
|
||||
* @param array $expected Expected sanitized version.
|
||||
* @param mixed $value The value to sanitize.
|
||||
@@ -2211,7 +2211,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
$this->assertSame( $expected, $sanitized );
|
||||
}
|
||||
|
||||
public function _dp_rest_sanitize_array() {
|
||||
public function data_rest_sanitize_array() {
|
||||
return array(
|
||||
array(
|
||||
array(),
|
||||
@@ -2271,7 +2271,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 51146
|
||||
*
|
||||
* @dataProvider _dp_rest_is_integer
|
||||
* @dataProvider data_rest_is_integer
|
||||
*
|
||||
* @param bool $expected Expected result of the check.
|
||||
* @param mixed $value The value to check.
|
||||
@@ -2286,7 +2286,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public function _dp_rest_is_integer() {
|
||||
public function data_rest_is_integer() {
|
||||
return array(
|
||||
array(
|
||||
true,
|
||||
@@ -2334,7 +2334,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50300
|
||||
*
|
||||
* @dataProvider _dp_get_best_type_for_value
|
||||
* @dataProvider data_get_best_type_for_value
|
||||
*
|
||||
* @param string $expected The expected best type.
|
||||
* @param mixed $value The value to test.
|
||||
@@ -2344,7 +2344,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
$this->assertSame( $expected, rest_get_best_type_for_value( $value, $types ) );
|
||||
}
|
||||
|
||||
public function _dp_get_best_type_for_value() {
|
||||
public function data_get_best_type_for_value() {
|
||||
return array(
|
||||
array(
|
||||
'array',
|
||||
|
||||
Reference in New Issue
Block a user