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:
Tonya Mork
2021-11-04 15:22:47 +00:00
parent 80380cd374
commit 40ac5de838
327 changed files with 3656 additions and 3969 deletions

View File

@@ -27,7 +27,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
*
* @see WP_UnitTestCase::setup()
*/
function set_up() {
public function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
@@ -54,7 +54,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
/**
* Tear down the test case.
*/
function tear_down() {
public function tear_down() {
$this->setting = null;
parent::tear_down();
}
@@ -62,7 +62,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
/**
* Delete the $wp_customize global when cleaning up scope.
*/
function clean_up_global_scope() {
public function clean_up_global_scope() {
global $wp_customize;
$wp_customize = null;
parent::clean_up_global_scope();
@@ -77,7 +77,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
*
* @covers WP_Customize_Custom_CSS_Setting::__construct
*/
function test_construct() {
public function test_construct() {
$this->assertTrue( post_type_exists( 'custom_css' ) );
$this->assertSame( 'custom_css', $this->setting->type );
$this->assertSame( get_stylesheet(), $this->setting->stylesheet );
@@ -110,7 +110,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
* @covers WP_Customize_Custom_CSS_Setting::preview
* @covers WP_Customize_Custom_CSS_Setting::update
*/
function test_crud() {
public function test_crud() {
$this->setting->default = '/* Hello World */';
$this->assertSame( $this->setting->default, $this->setting->value() );
@@ -211,7 +211,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
*
* @ticket 39032
*/
function test_custom_css_revision_saved() {
public function test_custom_css_revision_saved() {
$inserted_css = 'body { background: black; }';
$updated_css = 'body { background: red; }';
@@ -245,7 +245,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
*
* @ticket 39259
*/
function test_get_custom_css_post_queries_after_failed_lookup() {
public function test_get_custom_css_post_queries_after_failed_lookup() {
set_theme_mod( 'custom_css_post_id', -1 );
$queries_before = get_num_queries();
wp_get_custom_css_post();
@@ -257,7 +257,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
*
* @ticket 39259
*/
function test_update_custom_css_updates_theme_mod() {
public function test_update_custom_css_updates_theme_mod() {
set_theme_mod( 'custom_css_post_id', -1 );
$post = wp_update_custom_css_post( 'body { background: blue; }' );
$this->assertSame( $post->ID, get_theme_mod( 'custom_css_post_id' ) );
@@ -268,7 +268,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
*
* @covers WP_Customize_Custom_CSS_Setting::value
*/
function test_value_filter() {
public function test_value_filter() {
add_filter( 'customize_value_custom_css', array( $this, 'filter_value' ), 10, 2 );
$this->setting->default = '/*default*/';
$this->assertSame( '/*default*//*filtered*/', $this->setting->value() );
@@ -297,7 +297,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
* @param WP_Customize_Setting $setting Setting.
* @return string
*/
function filter_value( $value, $setting ) {
public function filter_value( $value, $setting ) {
$this->assertInstanceOf( 'WP_Customize_Custom_CSS_Setting', $setting );
$value .= '/*filtered*/';
return $value;
@@ -308,7 +308,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
*
* @covers WP_Customize_Custom_CSS_Setting::update
*/
function test_update_filter() {
public function test_update_filter() {
$original_css = 'body { color:red; }';
$post_id = $this->factory()->post->create(
array(
@@ -343,7 +343,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
* @param string $args Args.
* @return array Data.
*/
function filter_update_custom_css_data( $data, $args ) {
public function filter_update_custom_css_data( $data, $args ) {
$this->assertIsArray( $data );
$this->assertSameSets( array( 'css', 'preprocessed' ), array_keys( $data ) );
$this->assertSame( '', $data['preprocessed'] );
@@ -366,7 +366,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
*
* @covers WP_Customize_Custom_CSS_Setting::validate
*/
function test_validate() {
public function test_validate() {
// Empty CSS throws no errors.
$result = $this->setting->validate( '' );