mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +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:
@@ -9,7 +9,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
public $sidebar_index;
|
||||
public $valid_sidebar;
|
||||
|
||||
function clean_up_global_scope() {
|
||||
public function clean_up_global_scope() {
|
||||
global $wp_widget_factory, $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates;
|
||||
|
||||
$wp_registered_sidebars = array();
|
||||
@@ -21,7 +21,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
parent::clean_up_global_scope();
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
global $wp_customize;
|
||||
|
||||
$wp_customize = null;
|
||||
@@ -33,7 +33,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
* @see register_widget()
|
||||
* @see unregister_widget()
|
||||
*/
|
||||
function test_register_and_unregister_widget_core_widget() {
|
||||
public function test_register_and_unregister_widget_core_widget() {
|
||||
global $wp_widget_factory;
|
||||
|
||||
$widget_class = 'WP_Widget_Search';
|
||||
@@ -52,7 +52,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
* @see unregister_widget()
|
||||
* @ticket 28216
|
||||
*/
|
||||
function test_register_and_unregister_widget_instance() {
|
||||
public function test_register_and_unregister_widget_instance() {
|
||||
global $wp_widget_factory, $wp_registered_widgets;
|
||||
|
||||
$this->assertEmpty( $wp_widget_factory->widgets );
|
||||
@@ -129,7 +129,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @group sidebar
|
||||
*/
|
||||
function test_register_sidebars_single() {
|
||||
public function test_register_sidebars_single() {
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
register_sidebars( 1, array( 'id' => 'wp-unit-test' ) );
|
||||
@@ -141,7 +141,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @group sidebar
|
||||
*/
|
||||
function test_register_sidebars_multiple() {
|
||||
public function test_register_sidebars_multiple() {
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
$result = array();
|
||||
@@ -163,7 +163,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @group sidebar
|
||||
*/
|
||||
function test_register_sidebar_with_no_id() {
|
||||
public function test_register_sidebar_with_no_id() {
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
$this->setExpectedIncorrectUsage( 'register_sidebar' );
|
||||
@@ -180,7 +180,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @group sidebar
|
||||
*/
|
||||
function test_unregister_sidebar_registered_with_no_id() {
|
||||
public function test_unregister_sidebar_registered_with_no_id() {
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
$this->setExpectedIncorrectUsage( 'register_sidebar' );
|
||||
@@ -199,7 +199,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @group sidebar
|
||||
*/
|
||||
function test_register_sidebar_with_string_id() {
|
||||
public function test_register_sidebar_with_string_id() {
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
$sidebar_id = 'wp-unit-test';
|
||||
@@ -211,7 +211,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @group sidebar
|
||||
*/
|
||||
function test_unregister_sidebar_with_string_id() {
|
||||
public function test_unregister_sidebar_with_string_id() {
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
$sidebar_id = 'wp-unit-tests';
|
||||
@@ -224,7 +224,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @group sidebar
|
||||
*/
|
||||
function test_register_sidebar_with_numeric_id() {
|
||||
public function test_register_sidebar_with_numeric_id() {
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
$sidebar_id = 2;
|
||||
@@ -236,7 +236,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @group sidebar
|
||||
*/
|
||||
function test_unregister_sidebar_with_numeric_id() {
|
||||
public function test_unregister_sidebar_with_numeric_id() {
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
$sidebar_id = 2;
|
||||
@@ -292,7 +292,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* Utility hook callback used to store a sidebar ID mid-function.
|
||||
*/
|
||||
function retrieve_sidebar_id( $index, $valid_sidebar ) {
|
||||
public function retrieve_sidebar_id( $index, $valid_sidebar ) {
|
||||
$this->sidebar_index = $index;
|
||||
$this->valid_sidebar = $valid_sidebar;
|
||||
}
|
||||
@@ -300,7 +300,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @group sidebar
|
||||
*/
|
||||
function test_dynamic_sidebar_using_sidebar_registered_with_no_id() {
|
||||
public function test_dynamic_sidebar_using_sidebar_registered_with_no_id() {
|
||||
$this->setExpectedIncorrectUsage( 'register_sidebar' );
|
||||
|
||||
// Incorrectly register a couple of sidebars for fun.
|
||||
@@ -319,7 +319,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @group sidebar
|
||||
*/
|
||||
function test_dynamic_sidebar_using_invalid_sidebar_id() {
|
||||
public function test_dynamic_sidebar_using_invalid_sidebar_id() {
|
||||
register_sidebar( array( 'id' => 'wp-unit-text' ) );
|
||||
|
||||
add_action( 'dynamic_sidebar_before', array( $this, 'retrieve_sidebar_id' ), 10, 2 );
|
||||
@@ -337,7 +337,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @group sidebar
|
||||
*/
|
||||
function test_dynamic_sidebar_numeric_id() {
|
||||
public function test_dynamic_sidebar_numeric_id() {
|
||||
$sidebar_id = 2;
|
||||
register_sidebar( array( 'id' => $sidebar_id ) );
|
||||
|
||||
@@ -351,7 +351,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @group sidebar
|
||||
*/
|
||||
function test_dynamic_sidebar_string_id() {
|
||||
public function test_dynamic_sidebar_string_id() {
|
||||
$sidebar_id = 'wp-unit-tests';
|
||||
register_sidebar( array( 'id' => $sidebar_id ) );
|
||||
|
||||
@@ -365,7 +365,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Widget_Search::form()
|
||||
*/
|
||||
function test_wp_widget_search_form() {
|
||||
public function test_wp_widget_search_form() {
|
||||
$widget = new WP_Widget_Search( 'foo', 'Foo' );
|
||||
ob_start();
|
||||
$args = array(
|
||||
@@ -387,7 +387,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Widget::form()
|
||||
*/
|
||||
function test_wp_widget_form() {
|
||||
public function test_wp_widget_form() {
|
||||
$widget = new WP_Widget( 'foo', 'Foo' );
|
||||
ob_start();
|
||||
$retval = $widget->form( array() );
|
||||
@@ -399,7 +399,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Widget::__construct()
|
||||
*/
|
||||
function test_wp_widget_constructor() {
|
||||
public function test_wp_widget_constructor() {
|
||||
$id_base = 'foo';
|
||||
$name = 'Foo';
|
||||
$foo_widget = new WP_Widget( $id_base, $name );
|
||||
@@ -430,7 +430,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
* @see WP_Widget::__construct()
|
||||
* @dataProvider data_wp_widget_classname
|
||||
*/
|
||||
function test_wp_widget_classname( $expected, $widget_class ) {
|
||||
public function test_wp_widget_classname( $expected, $widget_class ) {
|
||||
require_once DIR_TESTDATA . '/widgets/custom-widget-classes.php';
|
||||
|
||||
$widget = new $widget_class( '', 'Foo' );
|
||||
@@ -452,7 +452,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
function data_wp_widget_classname() {
|
||||
public function data_wp_widget_classname() {
|
||||
return array(
|
||||
array(
|
||||
'widget_search',
|
||||
@@ -473,7 +473,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
* @see WP_Widget::get_field_name()
|
||||
* @dataProvider data_wp_widget_get_field_name
|
||||
*/
|
||||
function test_wp_widget_get_field_name( $expected, $value_to_test ) {
|
||||
public function test_wp_widget_get_field_name( $expected, $value_to_test ) {
|
||||
$widget = new WP_Widget( 'foo', 'Foo' );
|
||||
$widget->_set( 2 );
|
||||
$this->assertSame( $expected, $widget->get_field_name( $value_to_test ) );
|
||||
@@ -493,7 +493,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
function data_wp_widget_get_field_name() {
|
||||
public function data_wp_widget_get_field_name() {
|
||||
return array(
|
||||
array(
|
||||
'widget-foo[2][title]',
|
||||
@@ -522,7 +522,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
* @see WP_Widget::get_field_id()
|
||||
* @dataProvider data_wp_widget_get_field_id
|
||||
*/
|
||||
function test_wp_widget_get_field_id( $expected, $value_to_test ) {
|
||||
public function test_wp_widget_get_field_id( $expected, $value_to_test ) {
|
||||
$widget = new WP_Widget( 'foo', 'Foo' );
|
||||
$widget->_set( 2 );
|
||||
$this->assertSame( $expected, $widget->get_field_id( $value_to_test ) );
|
||||
@@ -543,7 +543,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
function data_wp_widget_get_field_id() {
|
||||
public function data_wp_widget_get_field_id() {
|
||||
return array(
|
||||
array(
|
||||
'widget-foo-2-title',
|
||||
@@ -571,7 +571,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Widget::_register()
|
||||
*/
|
||||
function test_wp_widget__register() {
|
||||
public function test_wp_widget__register() {
|
||||
global $wp_registered_widgets;
|
||||
|
||||
$settings = get_option( 'widget_block' );
|
||||
@@ -593,7 +593,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Widget::is_preview()
|
||||
*/
|
||||
function test_wp_widget_is_preview() {
|
||||
public function test_wp_widget_is_preview() {
|
||||
global $wp_customize;
|
||||
|
||||
$widget = new WP_Widget( 'foo', 'Foo' );
|
||||
@@ -616,7 +616,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Widget::get_settings()
|
||||
*/
|
||||
function test_wp_widget_get_settings() {
|
||||
public function test_wp_widget_get_settings() {
|
||||
global $wp_registered_widgets;
|
||||
|
||||
$option_value = get_option( 'widget_block' );
|
||||
@@ -653,7 +653,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Widget::save_settings()
|
||||
*/
|
||||
function test_wp_widget_save_settings() {
|
||||
public function test_wp_widget_save_settings() {
|
||||
global $wp_registered_widgets;
|
||||
|
||||
wp_widgets_init();
|
||||
@@ -684,7 +684,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Widget::save_settings()
|
||||
*/
|
||||
function test_wp_widget_save_settings_delete() {
|
||||
public function test_wp_widget_save_settings_delete() {
|
||||
global $wp_registered_widgets;
|
||||
|
||||
wp_widgets_init();
|
||||
@@ -701,7 +701,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see wp_widget_control()
|
||||
*/
|
||||
function test_wp_widget_control() {
|
||||
public function test_wp_widget_control() {
|
||||
global $wp_registered_widgets;
|
||||
|
||||
update_option(
|
||||
@@ -779,7 +779,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_the_widget_custom_before_title_arg() {
|
||||
public function test_the_widget_custom_before_title_arg() {
|
||||
register_widget( 'WP_Widget_Text' );
|
||||
|
||||
ob_start();
|
||||
@@ -808,7 +808,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @see \the_widget()
|
||||
*/
|
||||
function test_the_widget_with_unregistered_widget() {
|
||||
public function test_the_widget_with_unregistered_widget() {
|
||||
$this->setExpectedIncorrectUsage( 'the_widget' );
|
||||
the_widget( 'Widget_Class' );
|
||||
}
|
||||
@@ -834,7 +834,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @param array $sidebars Sidebar slugs.
|
||||
*/
|
||||
function register_sidebars( $sidebars ) {
|
||||
private function register_sidebars( $sidebars ) {
|
||||
foreach ( $sidebars as $sidebar ) {
|
||||
register_sidebar( array( 'id' => $sidebar ) );
|
||||
}
|
||||
@@ -845,7 +845,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::retrieve_widgets
|
||||
*/
|
||||
function test_retrieve_widgets_with_theme_mod() {
|
||||
public function test_retrieve_widgets_with_theme_mod() {
|
||||
global $sidebars_widgets, $_wp_sidebars_widgets;
|
||||
|
||||
wp_widgets_init();
|
||||
@@ -908,7 +908,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::retrieve_widgets
|
||||
*/
|
||||
function test_retrieve_widgets_with_sidebars_widgets_matching_registered_sidebars() {
|
||||
public function test_retrieve_widgets_with_sidebars_widgets_matching_registered_sidebars() {
|
||||
global $sidebars_widgets;
|
||||
|
||||
wp_widgets_init();
|
||||
@@ -946,7 +946,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::retrieve_widgets
|
||||
*/
|
||||
function test_retrieve_widgets_with_sidebars_widgets_not_matching_registered_sidebars() {
|
||||
public function test_retrieve_widgets_with_sidebars_widgets_not_matching_registered_sidebars() {
|
||||
global $sidebars_widgets, $_wp_sidebars_widgets;
|
||||
|
||||
wp_widgets_init();
|
||||
@@ -1038,7 +1038,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::retrieve_widgets
|
||||
*/
|
||||
function test_retrieve_widgets_for_customizer() {
|
||||
public function test_retrieve_widgets_for_customizer() {
|
||||
global $sidebars_widgets, $_wp_sidebars_widgets;
|
||||
|
||||
wp_widgets_init();
|
||||
@@ -1082,7 +1082,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
$this->assertNotEquals( $sidebars_widgets, wp_get_sidebars_widgets() );
|
||||
}
|
||||
|
||||
function test_retrieve_widgets_with_single_widget() {
|
||||
public function test_retrieve_widgets_with_single_widget() {
|
||||
global $sidebars_widgets;
|
||||
|
||||
wp_widgets_init();
|
||||
@@ -1109,7 +1109,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::retrieve_widgets
|
||||
*/
|
||||
function test_retrieve_widgets_move_orphaned_widgets_to_inactive() {
|
||||
public function test_retrieve_widgets_move_orphaned_widgets_to_inactive() {
|
||||
global $sidebars_widgets;
|
||||
|
||||
wp_widgets_init();
|
||||
|
||||
Reference in New Issue
Block a user