mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-02-24 09:42:45 +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:
parent
80380cd374
commit
40ac5de838
@ -10,7 +10,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @covers ::do_action
|
||||
*/
|
||||
function test_simple_action() {
|
||||
public function test_simple_action() {
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
|
||||
@ -30,7 +30,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @covers ::remove_action
|
||||
*/
|
||||
function test_remove_action() {
|
||||
public function test_remove_action() {
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
|
||||
@ -52,7 +52,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @covers ::has_action
|
||||
*/
|
||||
function test_has_action() {
|
||||
public function test_has_action() {
|
||||
$tag = __FUNCTION__;
|
||||
$func = __FUNCTION__ . '_func';
|
||||
|
||||
@ -71,7 +71,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::do_action
|
||||
*/
|
||||
function test_multiple_actions() {
|
||||
public function test_multiple_actions() {
|
||||
$a1 = new MockAction();
|
||||
$a2 = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
@ -92,7 +92,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::do_action
|
||||
*/
|
||||
function test_action_args_1() {
|
||||
public function test_action_args_1() {
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
@ -112,7 +112,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::do_action
|
||||
*/
|
||||
function test_action_args_2() {
|
||||
public function test_action_args_2() {
|
||||
$a1 = new MockAction();
|
||||
$a2 = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
@ -146,7 +146,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::do_action
|
||||
*/
|
||||
function test_action_args_3() {
|
||||
public function test_action_args_3() {
|
||||
$a1 = new MockAction();
|
||||
$a2 = new MockAction();
|
||||
$a3 = new MockAction();
|
||||
@ -185,7 +185,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::do_action
|
||||
*/
|
||||
function test_action_args_with_php4_syntax() {
|
||||
public function test_action_args_with_php4_syntax() {
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
$val = new stdClass();
|
||||
@ -199,7 +199,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
$this->assertSame( array( $val ), array_pop( $argsvar ) );
|
||||
}
|
||||
|
||||
function test_action_priority() {
|
||||
public function test_action_priority() {
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
|
||||
@ -231,7 +231,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @covers ::did_action
|
||||
*/
|
||||
function test_did_action() {
|
||||
public function test_did_action() {
|
||||
$tag1 = 'action1';
|
||||
$tag2 = 'action2';
|
||||
|
||||
@ -255,7 +255,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @covers ::do_action
|
||||
*/
|
||||
function test_all_action() {
|
||||
public function test_all_action() {
|
||||
$a = new MockAction();
|
||||
$tag1 = __FUNCTION__ . '_1';
|
||||
$tag2 = __FUNCTION__ . '_2';
|
||||
@ -282,7 +282,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @covers ::remove_action
|
||||
*/
|
||||
function test_remove_all_action() {
|
||||
public function test_remove_all_action() {
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
|
||||
@ -305,7 +305,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @covers ::do_action_ref_array
|
||||
*/
|
||||
function test_action_ref_array() {
|
||||
public function test_action_ref_array() {
|
||||
$obj = new stdClass();
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
@ -326,7 +326,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::do_action
|
||||
*/
|
||||
function test_action_keyed_array() {
|
||||
public function test_action_keyed_array() {
|
||||
$a = new MockAction();
|
||||
|
||||
$tag = __FUNCTION__;
|
||||
@ -353,13 +353,13 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @covers ::remove_action
|
||||
*/
|
||||
function test_action_self_removal() {
|
||||
public function test_action_self_removal() {
|
||||
add_action( 'test_action_self_removal', array( $this, 'action_self_removal' ) );
|
||||
do_action( 'test_action_self_removal' );
|
||||
$this->assertSame( 1, did_action( 'test_action_self_removal' ) );
|
||||
}
|
||||
|
||||
function action_self_removal() {
|
||||
public function action_self_removal() {
|
||||
remove_action( 'test_action_self_removal', array( $this, 'action_self_removal' ) );
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::do_action
|
||||
*/
|
||||
function test_action_recursion() {
|
||||
public function test_action_recursion() {
|
||||
$tag = __FUNCTION__;
|
||||
$a = new MockAction();
|
||||
$b = new MockAction();
|
||||
@ -385,7 +385,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @covers ::do_action
|
||||
*/
|
||||
function action_that_causes_recursion( $tag ) {
|
||||
public function action_that_causes_recursion( $tag ) {
|
||||
static $recursing = false;
|
||||
if ( ! $recursing ) {
|
||||
$recursing = true;
|
||||
@ -401,7 +401,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
* @covers ::remove_action
|
||||
* @covers ::add_action
|
||||
*/
|
||||
function test_action_callback_manipulation_while_running() {
|
||||
public function test_action_callback_manipulation_while_running() {
|
||||
$tag = __FUNCTION__;
|
||||
$a = new MockAction();
|
||||
$b = new MockAction();
|
||||
@ -423,7 +423,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
$this->assertSame( 1, $e->get_call_count(), 'callback added by later priority callback should not get called' );
|
||||
}
|
||||
|
||||
function action_that_manipulates_a_running_hook( $tag, $mocks ) {
|
||||
public function action_that_manipulates_a_running_hook( $tag, $mocks ) {
|
||||
remove_action( $tag, array( $mocks[1], 'action' ), 12, 2 );
|
||||
add_action( $tag, array( $mocks[2], 'action' ), 12, 2 );
|
||||
add_action( $tag, array( $mocks[3], 'action' ), 13, 2 );
|
||||
@ -438,7 +438,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::remove_filter
|
||||
*/
|
||||
function test_remove_anonymous_callback() {
|
||||
public function test_remove_anonymous_callback() {
|
||||
$tag = __FUNCTION__;
|
||||
$a = new MockAction();
|
||||
add_action( $tag, array( $a, 'action' ), 12, 1 );
|
||||
@ -475,7 +475,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
* @covers WP_Hook::offsetSet
|
||||
* @covers WP_Hook::offsetUnset
|
||||
*/
|
||||
function test_array_access_of_wp_filter_global() {
|
||||
public function test_array_access_of_wp_filter_global() {
|
||||
global $wp_filter;
|
||||
$tag = __FUNCTION__;
|
||||
|
||||
@ -503,7 +503,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::current_action
|
||||
*/
|
||||
function test_current_action() {
|
||||
public function test_current_action() {
|
||||
global $wp_current_filter;
|
||||
$wp_current_filter[] = 'first';
|
||||
$wp_current_filter[] = 'second'; // Let's say a second action was invoked.
|
||||
@ -516,7 +516,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::doing_filter
|
||||
*/
|
||||
function test_doing_filter() {
|
||||
public function test_doing_filter() {
|
||||
global $wp_current_filter;
|
||||
$wp_current_filter = array(); // Set to an empty array first.
|
||||
|
||||
@ -537,7 +537,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::doing_filter
|
||||
*/
|
||||
function test_doing_action() {
|
||||
public function test_doing_action() {
|
||||
global $wp_current_filter;
|
||||
$wp_current_filter = array(); // Set to an empty array first.
|
||||
|
||||
@ -558,7 +558,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::doing_filter
|
||||
*/
|
||||
function test_doing_filter_real() {
|
||||
public function test_doing_filter_real() {
|
||||
$this->assertFalse( doing_filter() ); // No filter is passed in, and no filter is being processed.
|
||||
$this->assertFalse( doing_filter( 'testing' ) ); // Filter is passed in but not being processed.
|
||||
|
||||
@ -575,7 +575,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
$this->assertFalse( doing_filter( 'testing' ) ); // No longer doing this filter.
|
||||
}
|
||||
|
||||
function apply_testing_filter() {
|
||||
public function apply_testing_filter() {
|
||||
$this->apply_testing_filter = true;
|
||||
|
||||
$this->assertTrue( doing_filter() );
|
||||
@ -596,7 +596,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
$this->assertFalse( doing_filter( 'testing_nested' ) );
|
||||
}
|
||||
|
||||
function apply_testing_nested_filter() {
|
||||
public function apply_testing_nested_filter() {
|
||||
$this->apply_testing_nested_filter = true;
|
||||
$this->assertTrue( doing_filter() );
|
||||
$this->assertTrue( doing_filter( 'testing' ) );
|
||||
|
||||
@ -10,7 +10,7 @@ class Tests_Actions_Callbacks extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::add_action
|
||||
*/
|
||||
function test_callback_representations() {
|
||||
public function test_callback_representations() {
|
||||
$tag = __FUNCTION__;
|
||||
|
||||
$this->assertFalse( has_action( $tag ) );
|
||||
|
||||
@ -14,7 +14,7 @@ class Tests_Actions_Closures extends WP_UnitTestCase {
|
||||
* @covers ::has_action
|
||||
* @covers ::do_action
|
||||
*/
|
||||
function test_action_closure() {
|
||||
public function test_action_closure() {
|
||||
$tag = 'test_action_closure';
|
||||
$closure = static function( $a, $b ) {
|
||||
$GLOBALS[ $a ] = $b;
|
||||
|
||||
@ -11,7 +11,7 @@ class Tests_Admin_IncludesFile extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::get_home_path
|
||||
*/
|
||||
function test_get_home_path() {
|
||||
public function test_get_home_path() {
|
||||
$home = get_option( 'home' );
|
||||
$siteurl = get_option( 'siteurl' );
|
||||
$sfn = $_SERVER['SCRIPT_FILENAME'];
|
||||
|
||||
@ -12,7 +12,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
|
||||
self::_restore_mu_plugins();
|
||||
}
|
||||
|
||||
function test_get_plugin_data() {
|
||||
public function test_get_plugin_data() {
|
||||
$data = get_plugin_data( DIR_TESTDATA . '/plugins/hello.php' );
|
||||
|
||||
$default_headers = array(
|
||||
@ -35,7 +35,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_menu_page_url() {
|
||||
public function test_menu_page_url() {
|
||||
$current_user = get_current_user_id();
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
update_option( 'siteurl', 'http://example.com' );
|
||||
@ -77,7 +77,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
|
||||
*
|
||||
* @dataProvider data_submenu_position
|
||||
*/
|
||||
function test_submenu_position( $position, $expected_position ) {
|
||||
public function test_submenu_position( $position, $expected_position ) {
|
||||
global $submenu;
|
||||
global $menu;
|
||||
$current_user = get_current_user_id();
|
||||
@ -125,7 +125,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
|
||||
*
|
||||
* @dataProvider data_submenu_position
|
||||
*/
|
||||
function test_submenu_helpers_position( $position, $expected_position ) {
|
||||
public function test_submenu_helpers_position( $position, $expected_position ) {
|
||||
global $submenu;
|
||||
global $menu;
|
||||
|
||||
@ -227,7 +227,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
function submenus_to_add() {
|
||||
private function submenus_to_add() {
|
||||
return array(
|
||||
array( 'Submenu Position', 'Submenu Position', 'manage_options', 'sub-page', '' ),
|
||||
array( 'Submenu Position 2', 'Submenu Position 2', 'manage_options', 'sub-page2', '' ),
|
||||
@ -249,7 +249,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
function data_submenu_position() {
|
||||
public function data_submenu_position() {
|
||||
$menu_count = count( $this->submenus_to_add() );
|
||||
return array(
|
||||
array( null, $menu_count ), // Insert at the end of the menu if null is passed. Default behavior.
|
||||
@ -268,7 +268,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 48599
|
||||
*/
|
||||
function test_position_when_parent_slug_child_slug_are_the_same() {
|
||||
public function test_position_when_parent_slug_child_slug_are_the_same() {
|
||||
global $submenu, $menu;
|
||||
|
||||
// Reset menus.
|
||||
@ -300,7 +300,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 48599
|
||||
*/
|
||||
function test_passing_string_as_position_fires_doing_it_wrong() {
|
||||
public function test_passing_string_as_position_fires_doing_it_wrong() {
|
||||
$this->setExpectedIncorrectUsage( 'add_submenu_page' );
|
||||
global $submenu, $menu;
|
||||
|
||||
@ -324,7 +324,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
|
||||
$this->assertSame( 'submenu_page_1', $submenu['main_slug'][1][2] );
|
||||
}
|
||||
|
||||
function test_is_plugin_active_true() {
|
||||
public function test_is_plugin_active_true() {
|
||||
activate_plugin( 'hello.php' );
|
||||
$test = is_plugin_active( 'hello.php' );
|
||||
$this->assertTrue( $test );
|
||||
@ -332,19 +332,19 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
|
||||
deactivate_plugins( 'hello.php' );
|
||||
}
|
||||
|
||||
function test_is_plugin_active_false() {
|
||||
public function test_is_plugin_active_false() {
|
||||
deactivate_plugins( 'hello.php' );
|
||||
$test = is_plugin_active( 'hello.php' );
|
||||
$this->assertFalse( $test );
|
||||
}
|
||||
|
||||
function test_is_plugin_inactive_true() {
|
||||
public function test_is_plugin_inactive_true() {
|
||||
deactivate_plugins( 'hello.php' );
|
||||
$test = is_plugin_inactive( 'hello.php' );
|
||||
$this->assertTrue( $test );
|
||||
}
|
||||
|
||||
function test_is_plugin_inactive_false() {
|
||||
public function test_is_plugin_inactive_false() {
|
||||
activate_plugin( 'hello.php' );
|
||||
$test = is_plugin_inactive( 'hello.php' );
|
||||
$this->assertFalse( $test );
|
||||
|
||||
@ -26,7 +26,7 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
|
||||
self::$post_id = $factory->post->create();
|
||||
}
|
||||
|
||||
function test__wp_translate_postdata_cap_checks_contributor() {
|
||||
public function test__wp_translate_postdata_cap_checks_contributor() {
|
||||
wp_set_current_user( self::$contributor_id );
|
||||
|
||||
// Create new draft post.
|
||||
@ -76,7 +76,7 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
|
||||
$this->assertSame( 'Sorry, you are not allowed to edit posts as this user.', $_results->get_error_message() );
|
||||
}
|
||||
|
||||
function test__wp_translate_postdata_cap_checks_editor() {
|
||||
public function test__wp_translate_postdata_cap_checks_editor() {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
|
||||
// Create new draft post.
|
||||
@ -131,7 +131,7 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 25272
|
||||
*/
|
||||
function test_edit_post_auto_draft() {
|
||||
public function test_edit_post_auto_draft() {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
$post = self::factory()->post->create_and_get( array( 'post_status' => 'auto-draft' ) );
|
||||
$this->assertSame( 'auto-draft', $post->post_status );
|
||||
@ -789,7 +789,7 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
|
||||
$this->assertSame( $p, post_exists( $title, $content, $date ) );
|
||||
}
|
||||
|
||||
function test_use_block_editor_for_post() {
|
||||
public function test_use_block_editor_for_post() {
|
||||
$this->assertFalse( use_block_editor_for_post( -1 ) );
|
||||
$bogus_post_id = $this->factory()->post->create(
|
||||
array(
|
||||
@ -822,7 +822,7 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
|
||||
remove_filter( 'use_block_editor_for_post', '__return_true' );
|
||||
}
|
||||
|
||||
function test_get_block_editor_server_block_settings() {
|
||||
public function test_get_block_editor_server_block_settings() {
|
||||
$name = 'core/test';
|
||||
$settings = array(
|
||||
'icon' => 'text',
|
||||
|
||||
@ -91,7 +91,7 @@ class Tests_Admin_IncludesSchema extends WP_UnitTestCase {
|
||||
* @ticket 44893
|
||||
* @dataProvider data_populate_options
|
||||
*/
|
||||
function test_populate_options( $options, $expected ) {
|
||||
public function test_populate_options( $options, $expected ) {
|
||||
global $wpdb;
|
||||
|
||||
$orig_options = $wpdb->options;
|
||||
@ -183,7 +183,7 @@ class Tests_Admin_IncludesSchema extends WP_UnitTestCase {
|
||||
* @group ms-required
|
||||
* @dataProvider data_populate_site_meta
|
||||
*/
|
||||
function test_populate_site_meta( $meta, $expected ) {
|
||||
public function test_populate_site_meta( $meta, $expected ) {
|
||||
global $wpdb;
|
||||
|
||||
$orig_blogmeta = $wpdb->blogmeta;
|
||||
@ -227,7 +227,7 @@ class Tests_Admin_IncludesSchema extends WP_UnitTestCase {
|
||||
* @group multisite
|
||||
* @dataProvider data_populate_network_meta
|
||||
*/
|
||||
function test_populate_network_meta( $meta, $expected ) {
|
||||
public function test_populate_network_meta( $meta, $expected ) {
|
||||
global $wpdb;
|
||||
|
||||
$orig_sitemeta = $wpdb->sitemeta;
|
||||
|
||||
@ -155,12 +155,12 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase {
|
||||
),
|
||||
);
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
unset( $GLOBALS['wp_taxonomies']['old-or-new'] );
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
function test_set_current_screen_with_hook_suffix() {
|
||||
public function test_set_current_screen_with_hook_suffix() {
|
||||
global $current_screen;
|
||||
|
||||
foreach ( $this->core_screens as $hook_name => $screen ) {
|
||||
@ -228,7 +228,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_post_type_as_hookname() {
|
||||
public function test_post_type_as_hookname() {
|
||||
$screen = convert_to_screen( 'page' );
|
||||
$this->assertSame( $screen->post_type, 'page' );
|
||||
$this->assertSame( $screen->base, 'post' );
|
||||
@ -236,7 +236,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase {
|
||||
$this->assertTrue( $screen->is_block_editor );
|
||||
}
|
||||
|
||||
function test_post_type_with_special_suffix_as_hookname() {
|
||||
public function test_post_type_with_special_suffix_as_hookname() {
|
||||
register_post_type( 'value-add' );
|
||||
$screen = convert_to_screen( 'value-add' ); // The '-add' part is key.
|
||||
$this->assertSame( $screen->post_type, 'value-add' );
|
||||
@ -251,7 +251,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase {
|
||||
$this->assertFalse( $screen->is_block_editor ); // Post types do not support `show_in_rest` by default.
|
||||
}
|
||||
|
||||
function test_taxonomy_with_special_suffix_as_hookname() {
|
||||
public function test_taxonomy_with_special_suffix_as_hookname() {
|
||||
register_taxonomy( 'old-or-new', 'post' );
|
||||
$screen = convert_to_screen( 'edit-old-or-new' ); // The '-new' part is key.
|
||||
$this->assertSame( $screen->taxonomy, 'old-or-new' );
|
||||
@ -260,7 +260,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase {
|
||||
$this->assertFalse( $screen->is_block_editor );
|
||||
}
|
||||
|
||||
function test_post_type_with_edit_prefix() {
|
||||
public function test_post_type_with_edit_prefix() {
|
||||
register_post_type( 'edit-some-thing' );
|
||||
$screen = convert_to_screen( 'edit-some-thing' );
|
||||
$this->assertSame( $screen->post_type, 'edit-some-thing' );
|
||||
@ -275,7 +275,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase {
|
||||
$this->assertFalse( $screen->is_block_editor ); // Post types do not support `show_in_rest` by default.
|
||||
}
|
||||
|
||||
function test_post_type_edit_collisions() {
|
||||
public function test_post_type_edit_collisions() {
|
||||
register_post_type( 'comments' );
|
||||
register_post_type( 'tags' );
|
||||
|
||||
@ -295,7 +295,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase {
|
||||
$this->assertSame( $screen->base, 'post' );
|
||||
}
|
||||
|
||||
function test_help_tabs() {
|
||||
public function test_help_tabs() {
|
||||
$tab = __FUNCTION__;
|
||||
$tab_args = array(
|
||||
'title' => 'Help!',
|
||||
@ -331,7 +331,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 19828
|
||||
*/
|
||||
function test_help_tabs_priority() {
|
||||
public function test_help_tabs_priority() {
|
||||
$tab_1 = 'tab1';
|
||||
$tab_1_args = array(
|
||||
'title' => 'Help!',
|
||||
@ -427,7 +427,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 25799
|
||||
*/
|
||||
function test_options() {
|
||||
public function test_options() {
|
||||
$option = __FUNCTION__;
|
||||
$option_args = array(
|
||||
'label' => 'Option',
|
||||
@ -451,7 +451,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase {
|
||||
$this->assertSame( $screen->get_options(), array() );
|
||||
}
|
||||
|
||||
function test_in_admin() {
|
||||
public function test_in_admin() {
|
||||
set_current_screen( 'edit.php' );
|
||||
$this->assertTrue( get_current_screen()->in_admin() );
|
||||
$this->assertTrue( get_current_screen()->in_admin( 'site' ) );
|
||||
|
||||
@ -4,27 +4,27 @@
|
||||
*/
|
||||
class Tests_Admin_IncludesTheme extends WP_UnitTestCase {
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
$this->theme_root = DIR_TESTDATA . '/themedir1';
|
||||
|
||||
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
|
||||
$GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
|
||||
|
||||
add_filter( 'theme_root', array( $this, '_theme_root' ) );
|
||||
add_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
|
||||
add_filter( 'template_root', array( $this, '_theme_root' ) );
|
||||
add_filter( 'theme_root', array( $this, 'filter_theme_root' ) );
|
||||
add_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) );
|
||||
add_filter( 'template_root', array( $this, 'filter_theme_root' ) );
|
||||
|
||||
// Clear caches.
|
||||
wp_clean_themes_cache();
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
|
||||
remove_filter( 'theme_root', array( $this, '_theme_root' ) );
|
||||
remove_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
|
||||
remove_filter( 'template_root', array( $this, '_theme_root' ) );
|
||||
remove_filter( 'theme_root', array( $this, 'filter_theme_root' ) );
|
||||
remove_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) );
|
||||
remove_filter( 'template_root', array( $this, 'filter_theme_root' ) );
|
||||
|
||||
wp_clean_themes_cache();
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
@ -32,7 +32,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
// Replace the normal theme root directory with our premade test directory.
|
||||
function _theme_root( $dir ) {
|
||||
public function filter_theme_root( $dir ) {
|
||||
return $this->theme_root;
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase {
|
||||
* @expectedDeprecated get_theme
|
||||
* @expectedDeprecated get_themes
|
||||
*/
|
||||
function test_page_templates() {
|
||||
public function test_page_templates() {
|
||||
$theme = get_theme( 'Page Template Theme' );
|
||||
$this->assertNotEmpty( $theme );
|
||||
|
||||
@ -75,7 +75,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 18375
|
||||
*/
|
||||
function test_page_templates_different_post_types() {
|
||||
public function test_page_templates_different_post_types() {
|
||||
$theme = wp_get_theme( 'page-templates' );
|
||||
$this->assertNotEmpty( $theme );
|
||||
|
||||
@ -101,7 +101,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 38766
|
||||
*/
|
||||
function test_page_templates_for_post_types_with_trailing_periods() {
|
||||
public function test_page_templates_for_post_types_with_trailing_periods() {
|
||||
$theme = wp_get_theme( 'page-templates' );
|
||||
$this->assertNotEmpty( $theme );
|
||||
|
||||
@ -133,7 +133,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 38696
|
||||
*/
|
||||
function test_page_templates_child_theme() {
|
||||
public function test_page_templates_child_theme() {
|
||||
$theme = wp_get_theme( 'page-templates-child' );
|
||||
$this->assertNotEmpty( $theme );
|
||||
|
||||
@ -216,7 +216,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase {
|
||||
* @group external-http
|
||||
* @ticket 28121
|
||||
*/
|
||||
function test_get_theme_featured_list_api() {
|
||||
public function test_get_theme_featured_list_api() {
|
||||
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$featured_list_api = get_theme_feature_list( true );
|
||||
$this->assertNonEmptyMultidimensionalArray( $featured_list_api );
|
||||
@ -230,7 +230,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase {
|
||||
* @group external-http
|
||||
* @ticket 28121
|
||||
*/
|
||||
function test_get_theme_featured_list_hardcoded() {
|
||||
public function test_get_theme_featured_list_hardcoded() {
|
||||
$featured_list_hardcoded = get_theme_feature_list( false );
|
||||
$this->assertNonEmptyMultidimensionalArray( $featured_list_hardcoded );
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21117
|
||||
*/
|
||||
function test_content_post_type() {
|
||||
public function test_content_post_type() {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
|
||||
register_post_type( 'content', array( 'show_in_admin_bar' => true ) );
|
||||
@ -51,7 +51,7 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21117
|
||||
*/
|
||||
function test_merging_existing_meta_values() {
|
||||
public function test_merging_existing_meta_values() {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
|
||||
$admin_bar = new WP_Admin_Bar;
|
||||
|
||||
@ -94,7 +94,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
|
||||
* @param array $allcaps An array of all the user's capabilities.
|
||||
* @return array All caps.
|
||||
*/
|
||||
function filter_user_has_cap( $allcaps ) {
|
||||
public function filter_user_has_cap( $allcaps ) {
|
||||
$allcaps = array_merge( $allcaps, $this->overridden_caps );
|
||||
return $allcaps;
|
||||
}
|
||||
@ -105,7 +105,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::save
|
||||
*/
|
||||
function test_save_failures() {
|
||||
public function test_save_failures() {
|
||||
global $wp_customize;
|
||||
$wp_customize = new WP_Customize_Manager();
|
||||
$wp_customize->register_controls();
|
||||
@ -272,7 +272,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::save
|
||||
*/
|
||||
function test_save_success_publish_create() {
|
||||
public function test_save_success_publish_create() {
|
||||
$wp_customize = $this->set_up_valid_state();
|
||||
|
||||
$_POST['customize_changeset_status'] = 'publish';
|
||||
@ -301,7 +301,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::save
|
||||
*/
|
||||
function test_save_success_publish_edit() {
|
||||
public function test_save_success_publish_edit() {
|
||||
$uuid = wp_generate_uuid4();
|
||||
|
||||
$post_id = $this->factory()->post->create(
|
||||
@ -340,7 +340,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
|
||||
* @ticket 38943
|
||||
* @covers WP_Customize_Manager::save
|
||||
*/
|
||||
function test_success_save_post_date() {
|
||||
public function test_success_save_post_date() {
|
||||
$uuid = wp_generate_uuid4();
|
||||
$post_id = $this->factory()->post->create(
|
||||
array(
|
||||
|
||||
@ -80,7 +80,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
* @param string $role The role we're checking caps against.
|
||||
* @param array $expected_results Expected results.
|
||||
*/
|
||||
function test_ajax_load_available_items_cap_check( $role, $expected_results ) {
|
||||
public function test_ajax_load_available_items_cap_check( $role, $expected_results ) {
|
||||
|
||||
if ( 'administrator' !== $role ) {
|
||||
// If we're not an admin, we should get a wp_die( -1 ).
|
||||
@ -122,7 +122,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
function data_ajax_load_available_items_cap_check() {
|
||||
public function data_ajax_load_available_items_cap_check() {
|
||||
return array(
|
||||
array(
|
||||
'subscriber',
|
||||
@ -158,7 +158,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
* @param array $post_args POST args.
|
||||
* @param mixed $expected_results Expected results.
|
||||
*/
|
||||
function test_ajax_load_available_items_error_messages( $post_args, $expected_results ) {
|
||||
public function test_ajax_load_available_items_error_messages( $post_args, $expected_results ) {
|
||||
|
||||
$_POST = array_merge(
|
||||
array(
|
||||
@ -192,7 +192,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
function data_ajax_load_available_items_error_messages() {
|
||||
public function data_ajax_load_available_items_error_messages() {
|
||||
return array(
|
||||
// Testing empty obj_type and type.
|
||||
array(
|
||||
@ -268,7 +268,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
* @param array $post_args POST args.
|
||||
* @param array $success_status Success status.
|
||||
*/
|
||||
function test_ajax_load_available_items_success_status( $post_args, $success_status ) {
|
||||
public function test_ajax_load_available_items_success_status( $post_args, $success_status ) {
|
||||
|
||||
$_POST = array_merge(
|
||||
array(
|
||||
@ -302,7 +302,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
function data_ajax_load_available_items_success_status() {
|
||||
public function data_ajax_load_available_items_success_status() {
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
@ -358,7 +358,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
*
|
||||
* @param array $post_args POST args.
|
||||
*/
|
||||
function test2_ajax_load_available_items_structure( $post_args ) {
|
||||
public function test2_ajax_load_available_items_structure( $post_args ) {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$expected_keys = array(
|
||||
@ -436,7 +436,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
function data_ajax_load_available_items_structure() {
|
||||
public function data_ajax_load_available_items_structure() {
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
@ -467,7 +467,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
* @param string $role Role.
|
||||
* @param array $expected_results Expected results.
|
||||
*/
|
||||
function test_ajax_search_available_items_caps_check( $role, $expected_results ) {
|
||||
public function test_ajax_search_available_items_caps_check( $role, $expected_results ) {
|
||||
|
||||
if ( 'administrator' !== $role ) {
|
||||
// If we're not an admin, we should get a wp_die( -1 ).
|
||||
@ -510,7 +510,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
function data_ajax_search_available_items_caps_check() {
|
||||
public function data_ajax_search_available_items_caps_check() {
|
||||
return array(
|
||||
array(
|
||||
'subscriber',
|
||||
@ -546,7 +546,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
* @param array $post_args POST args.
|
||||
* @param array $expected_results Expected results.
|
||||
*/
|
||||
function test_ajax_search_available_items_results( $post_args, $expected_results ) {
|
||||
public function test_ajax_search_available_items_results( $post_args, $expected_results ) {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
self::factory()->post->create_many( 5, array( 'post_title' => 'Test Post' ) );
|
||||
@ -602,7 +602,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
function data_ajax_search_available_items_results() {
|
||||
public function data_ajax_search_available_items_results() {
|
||||
return array(
|
||||
array(
|
||||
array(),
|
||||
@ -639,7 +639,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
*
|
||||
* @covers WP_Customize_Nav_Menus::ajax_insert_auto_draft_post
|
||||
*/
|
||||
function test_ajax_insert_auto_draft_post_success() {
|
||||
public function test_ajax_insert_auto_draft_post_success() {
|
||||
$_POST = wp_slash(
|
||||
array(
|
||||
'customize-menus-nonce' => wp_create_nonce( 'customize-menus' ),
|
||||
@ -669,7 +669,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
*
|
||||
* @covers WP_Customize_Nav_Menus::ajax_insert_auto_draft_post
|
||||
*/
|
||||
function test_ajax_insert_auto_draft_failures() {
|
||||
public function test_ajax_insert_auto_draft_failures() {
|
||||
// No nonce.
|
||||
$_POST = array();
|
||||
$this->_last_response = '';
|
||||
|
||||
@ -80,7 +80,7 @@ class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase {
|
||||
/**
|
||||
* @ticket 33154
|
||||
*/
|
||||
function test_editor_can_edit_orphan_comments() {
|
||||
public function test_editor_can_edit_orphan_comments() {
|
||||
global $wpdb;
|
||||
|
||||
// Become an editor.
|
||||
|
||||
@ -13,7 +13,7 @@ class Tests_Ajax_Manage_Themes extends WP_Ajax_UnitTestCase {
|
||||
private $orig_theme_dir;
|
||||
private $theme_root;
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
$this->theme_root = DIR_TESTDATA . '/themedir1';
|
||||
@ -30,7 +30,7 @@ class Tests_Ajax_Manage_Themes extends WP_Ajax_UnitTestCase {
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
|
||||
remove_filter( 'theme_root', array( $this, 'filter_theme_root' ) );
|
||||
remove_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) );
|
||||
@ -144,7 +144,7 @@ class Tests_Ajax_Manage_Themes extends WP_Ajax_UnitTestCase {
|
||||
/**
|
||||
* @group ms-excluded
|
||||
*/
|
||||
function test_uppercase_theme_slug() {
|
||||
public function test_uppercase_theme_slug() {
|
||||
$this->_setRole( 'administrator' );
|
||||
|
||||
$_POST['_ajax_nonce'] = wp_create_nonce( 'updates' );
|
||||
|
||||
@ -264,7 +264,7 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase {
|
||||
/**
|
||||
* Blocks comments from being saved on 'pre_comment_approved', by returning WP_Error.
|
||||
*/
|
||||
function _pre_comment_approved_filter( $approved, $commentdata ) {
|
||||
public function _pre_comment_approved_filter( $approved, $commentdata ) {
|
||||
return new WP_Error( 'comment_wrong', 'pre_comment_approved filter fails for new comment.', 403 );
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ class Tests_Attachment_Slashes extends WP_UnitTestCase {
|
||||
self::$author_id = $factory->user->create( array( 'role' => 'editor' ) );
|
||||
}
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
wp_set_current_user( self::$author_id );
|
||||
@ -31,7 +31,7 @@ class Tests_Attachment_Slashes extends WP_UnitTestCase {
|
||||
/**
|
||||
* Tests the model function that expects slashed data.
|
||||
*/
|
||||
function test_wp_insert_attachment() {
|
||||
public function test_wp_insert_attachment() {
|
||||
$post_id = wp_insert_attachment(
|
||||
array(
|
||||
'post_status' => 'publish',
|
||||
|
||||
@ -32,7 +32,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
self::$wp_hasher = new PasswordHash( 8, true );
|
||||
}
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
$this->user = clone self::$_user;
|
||||
@ -49,12 +49,12 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
function test_auth_cookie_valid() {
|
||||
public function test_auth_cookie_valid() {
|
||||
$cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'auth' );
|
||||
$this->assertSame( self::$user_id, wp_validate_auth_cookie( $cookie, 'auth' ) );
|
||||
}
|
||||
|
||||
function test_auth_cookie_invalid() {
|
||||
public function test_auth_cookie_invalid() {
|
||||
// 3600 or less and +3600 may occur in wp_validate_auth_cookie(),
|
||||
// as an ajax test may have defined DOING_AJAX, failing the test.
|
||||
|
||||
@ -70,7 +70,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
$this->assertFalse( wp_validate_auth_cookie( self::$user_id, 'auth' ), 'altered cookie' );
|
||||
}
|
||||
|
||||
function test_auth_cookie_scheme() {
|
||||
public function test_auth_cookie_scheme() {
|
||||
// Arbitrary scheme name.
|
||||
$cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'foo' );
|
||||
$this->assertSame( self::$user_id, wp_validate_auth_cookie( $cookie, 'foo' ) );
|
||||
@ -83,7 +83,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 23494
|
||||
*/
|
||||
function test_password_trimming() {
|
||||
public function test_password_trimming() {
|
||||
$passwords_to_test = array(
|
||||
'a password with no trailing or leading spaces',
|
||||
'a password with trailing spaces ',
|
||||
@ -108,7 +108,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 24973
|
||||
*/
|
||||
function test_wp_hash_password_trimming() {
|
||||
public function test_wp_hash_password_trimming() {
|
||||
|
||||
$password = ' pass with leading whitespace';
|
||||
$this->assertTrue( wp_check_password( 'pass with leading whitespace', wp_hash_password( $password ) ) );
|
||||
@ -129,7 +129,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 29217
|
||||
*/
|
||||
function test_wp_verify_nonce_with_empty_arg() {
|
||||
public function test_wp_verify_nonce_with_empty_arg() {
|
||||
$this->assertFalse( wp_verify_nonce( '' ) );
|
||||
$this->assertFalse( wp_verify_nonce( null ) );
|
||||
}
|
||||
@ -137,14 +137,14 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 29542
|
||||
*/
|
||||
function test_wp_verify_nonce_with_integer_arg() {
|
||||
public function test_wp_verify_nonce_with_integer_arg() {
|
||||
$this->assertFalse( wp_verify_nonce( 1 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 24030
|
||||
*/
|
||||
function test_wp_nonce_verify_failed() {
|
||||
public function test_wp_nonce_verify_failed() {
|
||||
$nonce = substr( md5( uniqid() ), 0, 10 );
|
||||
$count = did_action( $this->nonce_failure_hook );
|
||||
|
||||
@ -156,7 +156,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 24030
|
||||
*/
|
||||
function test_wp_nonce_verify_success() {
|
||||
public function test_wp_nonce_verify_success() {
|
||||
$nonce = wp_create_nonce( 'nonce_test_action' );
|
||||
$count = did_action( $this->nonce_failure_hook );
|
||||
|
||||
@ -202,7 +202,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
unset( $_REQUEST['_wpnonce'] );
|
||||
}
|
||||
|
||||
function test_password_length_limit() {
|
||||
public function test_password_length_limit() {
|
||||
$limit = str_repeat( 'a', 4096 );
|
||||
|
||||
wp_set_password( $limit, self::$user_id );
|
||||
@ -252,7 +252,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 45746
|
||||
*/
|
||||
function test_user_activation_key_is_saved() {
|
||||
public function test_user_activation_key_is_saved() {
|
||||
$user = get_userdata( $this->user->ID );
|
||||
$key = get_password_reset_key( $user );
|
||||
|
||||
@ -266,7 +266,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 32429
|
||||
*/
|
||||
function test_user_activation_key_is_checked() {
|
||||
public function test_user_activation_key_is_checked() {
|
||||
global $wpdb;
|
||||
|
||||
$key = wp_generate_password( 20, false );
|
||||
@ -304,7 +304,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 32429
|
||||
*/
|
||||
function test_expired_user_activation_key_is_rejected() {
|
||||
public function test_expired_user_activation_key_is_rejected() {
|
||||
global $wpdb;
|
||||
|
||||
$key = wp_generate_password( 20, false );
|
||||
@ -327,7 +327,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 32429
|
||||
*/
|
||||
function test_empty_user_activation_key_fails_key_check() {
|
||||
public function test_empty_user_activation_key_fails_key_check() {
|
||||
// An empty user_activation_key should not allow any key to be accepted.
|
||||
$check = check_password_reset_key( 'key', $this->user->user_login );
|
||||
$this->assertInstanceOf( 'WP_Error', $check );
|
||||
@ -340,7 +340,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 32429
|
||||
*/
|
||||
function test_legacy_user_activation_key_is_rejected() {
|
||||
public function test_legacy_user_activation_key_is_rejected() {
|
||||
global $wpdb;
|
||||
|
||||
// A legacy user_activation_key is one without the `time()` prefix introduced in WordPress 4.3.
|
||||
@ -370,7 +370,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
* @ticket 32429
|
||||
* @ticket 24783
|
||||
*/
|
||||
function test_plaintext_user_activation_key_is_rejected() {
|
||||
public function test_plaintext_user_activation_key_is_rejected() {
|
||||
global $wpdb;
|
||||
|
||||
// A plaintext user_activation_key is one stored before hashing was introduced in WordPress 3.7.
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
*/
|
||||
class Tests_Basic extends WP_UnitTestCase {
|
||||
|
||||
function test_license() {
|
||||
public function test_license() {
|
||||
// This test is designed to only run on trunk/master.
|
||||
$this->skipOnAutomatedBranches();
|
||||
|
||||
@ -17,7 +17,7 @@ class Tests_Basic extends WP_UnitTestCase {
|
||||
$this->assertSame( $this_year, trim( $matches[1] ), "license.txt's year needs to be updated to $this_year." );
|
||||
}
|
||||
|
||||
function test_security_md() {
|
||||
public function test_security_md() {
|
||||
// This test is designed to only run on trunk/master.
|
||||
$this->skipOnAutomatedBranches();
|
||||
|
||||
@ -28,7 +28,7 @@ class Tests_Basic extends WP_UnitTestCase {
|
||||
$this->assertSame( $latest_stable, trim( $matches[0] ), "SECURITY.md's version needs to be updated to $latest_stable." );
|
||||
}
|
||||
|
||||
function test_package_json() {
|
||||
public function test_package_json() {
|
||||
$package_json = file_get_contents( dirname( ABSPATH ) . '/package.json' );
|
||||
$package_json = json_decode( $package_json, true );
|
||||
list( $version ) = explode( '-', $GLOBALS['wp_version'] );
|
||||
@ -43,14 +43,14 @@ class Tests_Basic extends WP_UnitTestCase {
|
||||
/**
|
||||
* @depends test_package_json
|
||||
*/
|
||||
function test_package_json_node_engine( $package_json ) {
|
||||
public function test_package_json_node_engine( $package_json ) {
|
||||
$this->assertArrayHasKey( 'engines', $package_json );
|
||||
$this->assertArrayHasKey( 'node', $package_json['engines'] );
|
||||
}
|
||||
|
||||
// Test some helper utility functions.
|
||||
|
||||
function test_strip_ws() {
|
||||
public function test_strip_ws() {
|
||||
$this->assertSame( '', strip_ws( '' ) );
|
||||
$this->assertSame( 'foo', strip_ws( 'foo' ) );
|
||||
$this->assertSame( '', strip_ws( "\r\n\t \n\r\t" ) );
|
||||
@ -77,7 +77,7 @@ class Tests_Basic extends WP_UnitTestCase {
|
||||
|
||||
}
|
||||
|
||||
function test_mask_input_value() {
|
||||
public function test_mask_input_value() {
|
||||
$in = <<<EOF
|
||||
<h2>Assign Authors</h2>
|
||||
<p>To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.</p>
|
||||
|
||||
@ -33,7 +33,7 @@ class Block_Template_Utils_Test extends WP_UnitTestCase {
|
||||
wp_delete_post( self::$post->ID );
|
||||
}
|
||||
|
||||
function test_build_template_result_from_post() {
|
||||
public function test_build_template_result_from_post() {
|
||||
$template = _build_template_result_from_post(
|
||||
self::$post,
|
||||
'wp_template'
|
||||
@ -53,7 +53,7 @@ class Block_Template_Utils_Test extends WP_UnitTestCase {
|
||||
/**
|
||||
* Should retrieve the template from the CPT.
|
||||
*/
|
||||
function test_get_block_template_from_post() {
|
||||
public function test_get_block_template_from_post() {
|
||||
$id = get_stylesheet() . '//' . 'my_template';
|
||||
$template = get_block_template( $id, 'wp_template' );
|
||||
$this->assertSame( $id, $template->id );
|
||||
@ -67,7 +67,7 @@ class Block_Template_Utils_Test extends WP_UnitTestCase {
|
||||
/**
|
||||
* Should retrieve block templates.
|
||||
*/
|
||||
function test_get_block_templates() {
|
||||
public function test_get_block_templates() {
|
||||
function get_template_ids( $templates ) {
|
||||
return array_map(
|
||||
static function( $template ) {
|
||||
|
||||
@ -43,7 +43,7 @@ class Block_Template_Test extends WP_UnitTestCase {
|
||||
/**
|
||||
* Regression: https://github.com/WordPress/gutenberg/issues/31399.
|
||||
*/
|
||||
function test_custom_page_php_template_takes_precedence_over_all_other_templates() {
|
||||
public function test_custom_page_php_template_takes_precedence_over_all_other_templates() {
|
||||
$custom_page_template = 'templates/full-width.php';
|
||||
$custom_page_template_path = get_stylesheet_directory() . '/' . $custom_page_template;
|
||||
$type = 'page';
|
||||
@ -60,7 +60,7 @@ class Block_Template_Test extends WP_UnitTestCase {
|
||||
/**
|
||||
* Covers: https://github.com/WordPress/gutenberg/pull/30438.
|
||||
*/
|
||||
function test_custom_page_block_template_takes_precedence_over_all_other_templates() {
|
||||
public function test_custom_page_block_template_takes_precedence_over_all_other_templates() {
|
||||
global $_wp_current_template_content;
|
||||
|
||||
$custom_page_block_template = 'wp-custom-template-my-block-template';
|
||||
@ -80,7 +80,7 @@ class Block_Template_Test extends WP_UnitTestCase {
|
||||
/**
|
||||
* Regression: https://github.com/WordPress/gutenberg/issues/31652.
|
||||
*/
|
||||
function test_template_remains_unchanged_if_templates_array_is_empty() {
|
||||
public function test_template_remains_unchanged_if_templates_array_is_empty() {
|
||||
$resolved_template_path = locate_block_template( '', 'search', array() );
|
||||
$this->assertSame( '', $resolved_template_path );
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ class Tests_Blocks_Context extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_provides_block_context() {
|
||||
public function test_provides_block_context() {
|
||||
$provided_context = array();
|
||||
|
||||
$this->register_block_type(
|
||||
@ -146,7 +146,7 @@ class Tests_Blocks_Context extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_provides_default_context() {
|
||||
public function test_provides_default_context() {
|
||||
global $post;
|
||||
|
||||
$provided_context = array();
|
||||
@ -181,7 +181,7 @@ class Tests_Blocks_Context extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_default_context_is_filterable() {
|
||||
public function test_default_context_is_filterable() {
|
||||
$provided_context = array();
|
||||
|
||||
$this->register_block_type(
|
||||
|
||||
@ -42,7 +42,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
function filter_set_block_categories_post( $block_categories, $post ) {
|
||||
public function filter_set_block_categories_post( $block_categories, $post ) {
|
||||
if ( empty( $post ) ) {
|
||||
return $block_categories;
|
||||
}
|
||||
@ -56,7 +56,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function filter_set_allowed_block_types_post( $allowed_block_types, $post ) {
|
||||
public function filter_set_allowed_block_types_post( $allowed_block_types, $post ) {
|
||||
if ( empty( $post ) ) {
|
||||
return $allowed_block_types;
|
||||
}
|
||||
@ -64,7 +64,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
return array( 'test/filtered-block' );
|
||||
}
|
||||
|
||||
function filter_set_block_editor_settings_post( $editor_settings, $post ) {
|
||||
public function filter_set_block_editor_settings_post( $editor_settings, $post ) {
|
||||
if ( empty( $post ) ) {
|
||||
return $allowed_block_types;
|
||||
}
|
||||
@ -77,7 +77,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52920
|
||||
*/
|
||||
function test_block_editor_context_no_settings() {
|
||||
public function test_block_editor_context_no_settings() {
|
||||
$context = new WP_Block_Editor_Context();
|
||||
|
||||
$this->assertNull( $context->post );
|
||||
@ -86,7 +86,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52920
|
||||
*/
|
||||
function test_block_editor_context_post() {
|
||||
public function test_block_editor_context_post() {
|
||||
$context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
|
||||
|
||||
$this->assertSame( get_post(), $context->post );
|
||||
@ -96,7 +96,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
* @ticket 52920
|
||||
* @expectedDeprecated block_categories
|
||||
*/
|
||||
function test_get_block_categories_deprecated_filter_post_object() {
|
||||
public function test_get_block_categories_deprecated_filter_post_object() {
|
||||
add_filter( 'block_categories', array( $this, 'filter_set_block_categories_post' ), 10, 2 );
|
||||
|
||||
$block_categories = get_block_categories( get_post() );
|
||||
@ -119,7 +119,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
* @ticket 52920
|
||||
* @expectedDeprecated block_categories
|
||||
*/
|
||||
function test_get_block_categories_deprecated_filter_post_editor() {
|
||||
public function test_get_block_categories_deprecated_filter_post_editor() {
|
||||
add_filter( 'block_categories', array( $this, 'filter_set_block_categories_post' ), 10, 2 );
|
||||
|
||||
$post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
|
||||
@ -142,7 +142,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52920
|
||||
*/
|
||||
function test_get_allowed_block_types_default() {
|
||||
public function test_get_allowed_block_types_default() {
|
||||
$post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
|
||||
$allowed_block_types = get_allowed_block_types( $post_editor_context );
|
||||
|
||||
@ -153,7 +153,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
* @ticket 52920
|
||||
* @expectedDeprecated allowed_block_types
|
||||
*/
|
||||
function test_get_allowed_block_types_deprecated_filter_post_editor() {
|
||||
public function test_get_allowed_block_types_deprecated_filter_post_editor() {
|
||||
add_filter( 'allowed_block_types', array( $this, 'filter_set_allowed_block_types_post' ), 10, 2 );
|
||||
|
||||
$post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
|
||||
@ -167,7 +167,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52920
|
||||
*/
|
||||
function test_get_default_block_editor_settings() {
|
||||
public function test_get_default_block_editor_settings() {
|
||||
$settings = get_default_block_editor_settings();
|
||||
|
||||
$this->assertCount( 16, $settings );
|
||||
@ -270,7 +270,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 53397
|
||||
*/
|
||||
function test_get_legacy_widget_block_editor_settings() {
|
||||
public function test_get_legacy_widget_block_editor_settings() {
|
||||
$settings = get_legacy_widget_block_editor_settings();
|
||||
$this->assertCount( 1, $settings );
|
||||
$this->assertSameSets(
|
||||
@ -299,7 +299,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52920
|
||||
*/
|
||||
function test_get_block_editor_settings_overrides_default_settings_all_editors() {
|
||||
public function test_get_block_editor_settings_overrides_default_settings_all_editors() {
|
||||
function filter_allowed_block_types_my_editor() {
|
||||
return array( 'test/filtered-my-block' );
|
||||
}
|
||||
@ -346,7 +346,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 53458
|
||||
*/
|
||||
function test_get_block_editor_settings_theme_json_settings() {
|
||||
public function test_get_block_editor_settings_theme_json_settings() {
|
||||
switch_theme( 'block-theme' );
|
||||
|
||||
$post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
|
||||
@ -411,7 +411,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
* @ticket 52920
|
||||
* @expectedDeprecated block_editor_settings
|
||||
*/
|
||||
function test_get_block_editor_settings_deprecated_filter_post_editor() {
|
||||
public function test_get_block_editor_settings_deprecated_filter_post_editor() {
|
||||
add_filter( 'block_editor_settings', array( $this, 'filter_set_block_editor_settings_post' ), 10, 2 );
|
||||
|
||||
$post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
|
||||
@ -430,7 +430,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52920
|
||||
*/
|
||||
function test_block_editor_rest_api_preload_no_paths() {
|
||||
public function test_block_editor_rest_api_preload_no_paths() {
|
||||
$editor_context = new WP_Block_Editor_Context();
|
||||
block_editor_rest_api_preload( array(), $editor_context );
|
||||
|
||||
@ -442,7 +442,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
* @ticket 52920
|
||||
* @expectedDeprecated block_editor_preload_paths
|
||||
*/
|
||||
function test_block_editor_rest_api_preload_deprecated_filter_post_editor() {
|
||||
public function test_block_editor_rest_api_preload_deprecated_filter_post_editor() {
|
||||
function filter_remove_preload_paths( $preload_paths, $post ) {
|
||||
if ( empty( $post ) ) {
|
||||
return $preload_paths;
|
||||
@ -468,7 +468,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52920
|
||||
*/
|
||||
function test_block_editor_rest_api_preload_filter_all() {
|
||||
public function test_block_editor_rest_api_preload_filter_all() {
|
||||
function filter_add_preload_paths( $preload_paths, WP_Block_Editor_Context $context ) {
|
||||
if ( empty( $context->post ) ) {
|
||||
array_push( $preload_paths, array( '/wp/v2/types', 'OPTIONS' ) );
|
||||
@ -497,7 +497,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 53344
|
||||
*/
|
||||
function test_get_block_editor_theme_styles() {
|
||||
public function test_get_block_editor_theme_styles() {
|
||||
$theme_styles = get_block_editor_theme_styles();
|
||||
$this->assertCount( 1, $theme_styles );
|
||||
$this->assertSameSets(
|
||||
|
||||
@ -50,14 +50,14 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* Empty render function for tests to use.
|
||||
*/
|
||||
function render_stub() {}
|
||||
public function render_stub() {}
|
||||
|
||||
/**
|
||||
* Tear down after each test.
|
||||
*
|
||||
* @since 5.0.0
|
||||
*/
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$registry = WP_Block_Type_Registry::get_instance();
|
||||
|
||||
foreach ( array( 'core/test-static', 'core/test-dynamic', 'tests/notice' ) as $block_name ) {
|
||||
@ -74,14 +74,14 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function filter_set_locale_to_polish() {
|
||||
public function filter_set_locale_to_polish() {
|
||||
return 'pl_PL';
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 45109
|
||||
*/
|
||||
function test_register_affects_main_registry() {
|
||||
public function test_register_affects_main_registry() {
|
||||
$name = 'core/test-static';
|
||||
$settings = array(
|
||||
'icon' => 'text',
|
||||
@ -96,7 +96,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 45109
|
||||
*/
|
||||
function test_unregister_affects_main_registry() {
|
||||
public function test_unregister_affects_main_registry() {
|
||||
$name = 'core/test-static';
|
||||
$settings = array(
|
||||
'icon' => 'text',
|
||||
@ -112,7 +112,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50263
|
||||
*/
|
||||
function test_does_not_remove_block_asset_path_prefix() {
|
||||
public function test_does_not_remove_block_asset_path_prefix() {
|
||||
$result = remove_block_asset_path_prefix( 'script-handle' );
|
||||
|
||||
$this->assertSame( 'script-handle', $result );
|
||||
@ -121,7 +121,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50263
|
||||
*/
|
||||
function test_removes_block_asset_path_prefix() {
|
||||
public function test_removes_block_asset_path_prefix() {
|
||||
$result = remove_block_asset_path_prefix( 'file:./block.js' );
|
||||
|
||||
$this->assertSame( './block.js', $result );
|
||||
@ -130,7 +130,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50263
|
||||
*/
|
||||
function test_generate_block_asset_handle() {
|
||||
public function test_generate_block_asset_handle() {
|
||||
$block_name = 'unit-tests/my-block';
|
||||
|
||||
$this->assertSame(
|
||||
@ -158,7 +158,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50328
|
||||
*/
|
||||
function test_generate_block_asset_handle_core_block() {
|
||||
public function test_generate_block_asset_handle_core_block() {
|
||||
$block_name = 'core/paragraph';
|
||||
|
||||
$this->assertSame(
|
||||
@ -186,7 +186,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50263
|
||||
*/
|
||||
function test_field_not_found_register_block_script_handle() {
|
||||
public function test_field_not_found_register_block_script_handle() {
|
||||
$result = register_block_script_handle( array(), 'script' );
|
||||
|
||||
$this->assertFalse( $result );
|
||||
@ -195,7 +195,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50263
|
||||
*/
|
||||
function test_empty_value_register_block_script_handle() {
|
||||
public function test_empty_value_register_block_script_handle() {
|
||||
$metadata = array( 'script' => '' );
|
||||
$result = register_block_script_handle( $metadata, 'script' );
|
||||
|
||||
@ -206,7 +206,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
* @expectedIncorrectUsage register_block_script_handle
|
||||
* @ticket 50263
|
||||
*/
|
||||
function test_missing_asset_file_register_block_script_handle() {
|
||||
public function test_missing_asset_file_register_block_script_handle() {
|
||||
$metadata = array(
|
||||
'file' => __FILE__,
|
||||
'name' => 'unit-tests/test-block',
|
||||
@ -220,7 +220,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50263
|
||||
*/
|
||||
function test_handle_passed_register_block_script_handle() {
|
||||
public function test_handle_passed_register_block_script_handle() {
|
||||
$metadata = array(
|
||||
'editorScript' => 'test-script-handle',
|
||||
);
|
||||
@ -232,7 +232,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50263
|
||||
*/
|
||||
function test_success_register_block_script_handle() {
|
||||
public function test_success_register_block_script_handle() {
|
||||
$metadata = array(
|
||||
'file' => DIR_TESTDATA . '/blocks/notice/block.json',
|
||||
'name' => 'unit-tests/test-block',
|
||||
@ -246,7 +246,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50263
|
||||
*/
|
||||
function test_field_not_found_register_block_style_handle() {
|
||||
public function test_field_not_found_register_block_style_handle() {
|
||||
$result = register_block_style_handle( array(), 'style' );
|
||||
|
||||
$this->assertFalse( $result );
|
||||
@ -255,7 +255,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50263
|
||||
*/
|
||||
function test_empty_value_found_register_block_style_handle() {
|
||||
public function test_empty_value_found_register_block_style_handle() {
|
||||
$metadata = array( 'style' => '' );
|
||||
$result = register_block_style_handle( $metadata, 'style' );
|
||||
|
||||
@ -265,7 +265,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 50263
|
||||
*/
|
||||
function test_handle_passed_register_block_style_handle() {
|
||||
public function test_handle_passed_register_block_style_handle() {
|
||||
$metadata = array(
|
||||
'style' => 'test-style-handle',
|
||||
);
|
||||
@ -278,7 +278,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
* @ticket 50263
|
||||
* @ticket 50328
|
||||
*/
|
||||
function test_success_register_block_style_handle() {
|
||||
public function test_success_register_block_style_handle() {
|
||||
$metadata = array(
|
||||
'file' => DIR_TESTDATA . '/blocks/notice/block.json',
|
||||
'name' => 'unit-tests/test-block',
|
||||
@ -302,7 +302,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 50263
|
||||
*/
|
||||
function test_metadata_not_found_in_wordpress_core() {
|
||||
public function test_metadata_not_found_in_wordpress_core() {
|
||||
$result = register_block_type_from_metadata( 'unknown' );
|
||||
|
||||
$this->assertFalse( $result );
|
||||
@ -314,7 +314,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 50263
|
||||
*/
|
||||
function test_metadata_not_found_in_the_current_directory() {
|
||||
public function test_metadata_not_found_in_the_current_directory() {
|
||||
$result = register_block_type_from_metadata( __DIR__ );
|
||||
|
||||
$this->assertFalse( $result );
|
||||
@ -327,7 +327,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
* @ticket 50263
|
||||
* @ticket 50328
|
||||
*/
|
||||
function test_block_registers_with_metadata_fixture() {
|
||||
public function test_block_registers_with_metadata_fixture() {
|
||||
$result = register_block_type_from_metadata(
|
||||
DIR_TESTDATA . '/blocks/notice'
|
||||
);
|
||||
@ -414,7 +414,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 53233
|
||||
*/
|
||||
function test_block_register_block_type_proxy_for_metadata() {
|
||||
public function test_block_register_block_type_proxy_for_metadata() {
|
||||
$result = register_block_type(
|
||||
DIR_TESTDATA . '/blocks/notice'
|
||||
);
|
||||
@ -426,7 +426,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52301
|
||||
*/
|
||||
function test_block_registers_with_metadata_i18n_support() {
|
||||
public function test_block_registers_with_metadata_i18n_support() {
|
||||
add_filter( 'locale', array( $this, 'filter_set_locale_to_polish' ) );
|
||||
load_textdomain( 'notice', WP_LANG_DIR . '/plugins/notice-pl_PL.mo' );
|
||||
|
||||
@ -472,7 +472,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 45109
|
||||
*/
|
||||
function test_get_dynamic_block_names() {
|
||||
public function test_get_dynamic_block_names() {
|
||||
register_block_type( 'core/test-static', array() );
|
||||
register_block_type( 'core/test-dynamic', array( 'render_callback' => array( $this, 'render_stub' ) ) );
|
||||
|
||||
@ -485,7 +485,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 45109
|
||||
*/
|
||||
function test_has_blocks() {
|
||||
public function test_has_blocks() {
|
||||
// Test with passing post ID.
|
||||
$this->assertTrue( has_blocks( self::$post_id ) );
|
||||
|
||||
|
||||
@ -83,14 +83,14 @@ class Tests_Blocks_Render extends WP_UnitTestCase {
|
||||
$this->assertSame( trim( $classic_filtered_content ), trim( $block_filtered_content ) );
|
||||
}
|
||||
|
||||
function handle_shortcode( $atts, $content ) {
|
||||
public function handle_shortcode( $atts, $content ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 45495
|
||||
*/
|
||||
function test_nested_calls_to_the_content() {
|
||||
public function test_nested_calls_to_the_content() {
|
||||
register_block_type(
|
||||
'core/test',
|
||||
array(
|
||||
@ -108,7 +108,7 @@ class Tests_Blocks_Render extends WP_UnitTestCase {
|
||||
$this->assertSame( $content, $the_content );
|
||||
}
|
||||
|
||||
function dynamic_the_content_call( $attrs, $content ) {
|
||||
public function dynamic_the_content_call( $attrs, $content ) {
|
||||
apply_filters( 'the_content', '' );
|
||||
return $content;
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ class Tests_Blocks_Serialize extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data_serialize_identity_from_parsed
|
||||
*/
|
||||
function test_serialize_identity_from_parsed( $original ) {
|
||||
public function test_serialize_identity_from_parsed( $original ) {
|
||||
$blocks = parse_blocks( $original );
|
||||
|
||||
$actual = serialize_blocks( $blocks );
|
||||
@ -28,7 +28,7 @@ class Tests_Blocks_Serialize extends WP_UnitTestCase {
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
function data_serialize_identity_from_parsed() {
|
||||
public function data_serialize_identity_from_parsed() {
|
||||
return array(
|
||||
// Void block.
|
||||
array( '<!-- wp:void /-->' ),
|
||||
@ -53,7 +53,7 @@ class Tests_Blocks_Serialize extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function test_serialized_block_name() {
|
||||
public function test_serialized_block_name() {
|
||||
$this->assertNull( strip_core_block_namespace( null ) );
|
||||
$this->assertSame( 'example', strip_core_block_namespace( 'example' ) );
|
||||
$this->assertSame( 'example', strip_core_block_namespace( 'core/example' ) );
|
||||
|
||||
@ -41,14 +41,14 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
function filter_render_block( $content, $parsed_block ) {
|
||||
public function filter_render_block( $content, $parsed_block ) {
|
||||
return 'Original: "' . $content . '", from block "' . $parsed_block['blockName'] . '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_constructor_assigns_properties_from_parsed_block() {
|
||||
public function test_constructor_assigns_properties_from_parsed_block() {
|
||||
$this->registry->register( 'core/example', array() );
|
||||
|
||||
$parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
|
||||
@ -66,7 +66,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_constructor_assigns_block_type_from_registry() {
|
||||
public function test_constructor_assigns_block_type_from_registry() {
|
||||
$block_type_settings = array(
|
||||
'attributes' => array(
|
||||
'defaulted' => array(
|
||||
@ -91,7 +91,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_lazily_assigns_attributes_with_defaults() {
|
||||
public function test_lazily_assigns_attributes_with_defaults() {
|
||||
$this->registry->register(
|
||||
'core/example',
|
||||
array(
|
||||
@ -125,7 +125,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_lazily_assigns_attributes_with_only_defaults() {
|
||||
public function test_lazily_assigns_attributes_with_only_defaults() {
|
||||
$this->registry->register(
|
||||
'core/example',
|
||||
array(
|
||||
@ -153,7 +153,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_constructor_assigns_context_from_block_type() {
|
||||
public function test_constructor_assigns_context_from_block_type() {
|
||||
$this->registry->register(
|
||||
'core/example',
|
||||
array(
|
||||
@ -174,7 +174,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_constructor_maps_inner_blocks() {
|
||||
public function test_constructor_maps_inner_blocks() {
|
||||
$this->registry->register( 'core/example', array() );
|
||||
|
||||
$parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
|
||||
@ -190,7 +190,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_constructor_prepares_context_for_inner_blocks() {
|
||||
public function test_constructor_prepares_context_for_inner_blocks() {
|
||||
$this->registry->register(
|
||||
'core/outer',
|
||||
array(
|
||||
@ -226,7 +226,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_constructor_assigns_merged_context() {
|
||||
public function test_constructor_assigns_merged_context() {
|
||||
$this->registry->register(
|
||||
'core/example',
|
||||
array(
|
||||
@ -270,7 +270,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_render_static_block_type_returns_own_content() {
|
||||
public function test_render_static_block_type_returns_own_content() {
|
||||
$this->registry->register( 'core/static', array() );
|
||||
$this->registry->register(
|
||||
'core/dynamic',
|
||||
@ -292,7 +292,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_render_passes_block_for_render_callback() {
|
||||
public function test_render_passes_block_for_render_callback() {
|
||||
$this->registry->register(
|
||||
'core/greeting',
|
||||
array(
|
||||
@ -313,7 +313,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_render_applies_render_block_filter() {
|
||||
public function test_render_applies_render_block_filter() {
|
||||
$this->registry->register( 'core/example', array() );
|
||||
|
||||
add_filter( 'render_block', array( $this, 'filter_render_block' ), 10, 2 );
|
||||
@ -333,7 +333,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 46187
|
||||
*/
|
||||
function test_render_applies_dynamic_render_block_filter() {
|
||||
public function test_render_applies_dynamic_render_block_filter() {
|
||||
$this->registry->register( 'core/example', array() );
|
||||
|
||||
add_filter( 'render_block_core/example', array( $this, 'filter_render_block' ), 10, 2 );
|
||||
@ -353,7 +353,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_passes_attributes_to_render_callback() {
|
||||
public function test_passes_attributes_to_render_callback() {
|
||||
$this->registry->register(
|
||||
'core/greeting',
|
||||
array(
|
||||
@ -387,7 +387,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_passes_content_to_render_callback() {
|
||||
public function test_passes_content_to_render_callback() {
|
||||
$this->registry->register(
|
||||
'core/outer',
|
||||
array(
|
||||
|
||||
@ -45,7 +45,7 @@ class Tests_Blocks_wpBlockList extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_array_access() {
|
||||
public function test_array_access() {
|
||||
$parsed_blocks = parse_blocks( '<!-- wp:example /-->' );
|
||||
$context = array();
|
||||
$blocks = new WP_Block_List( $parsed_blocks, $context, $this->registry );
|
||||
@ -69,7 +69,7 @@ class Tests_Blocks_wpBlockList extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_iterable() {
|
||||
public function test_iterable() {
|
||||
$parsed_blocks = parse_blocks( '<!-- wp:example --><!-- wp:example /--><!-- /wp:example -->' );
|
||||
$context = array();
|
||||
$blocks = new WP_Block_List( $parsed_blocks, $context, $this->registry );
|
||||
@ -101,7 +101,7 @@ class Tests_Blocks_wpBlockList extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49927
|
||||
*/
|
||||
function test_countable() {
|
||||
public function test_countable() {
|
||||
$parsed_blocks = parse_blocks( '<!-- wp:example /-->' );
|
||||
$context = array();
|
||||
$blocks = new WP_Block_List( $parsed_blocks, $context, $this->registry );
|
||||
|
||||
@ -216,7 +216,7 @@ class Tests_Blocks_wpBlockType extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 45145
|
||||
*/
|
||||
function test_prepare_attributes_none_defined() {
|
||||
public function test_prepare_attributes_none_defined() {
|
||||
$attributes = array( 'exists' => 'keep' );
|
||||
|
||||
$block_type = new WP_Block_Type( 'core/dummy', array() );
|
||||
|
||||
@ -6,19 +6,19 @@
|
||||
class Tests_Cache extends WP_UnitTestCase {
|
||||
public $cache = null;
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
// Create two cache objects with a shared cache directory.
|
||||
// This simulates a typical cache situation, two separate requests interacting.
|
||||
$this->cache =& $this->init_cache();
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$this->flush_cache();
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
function &init_cache() {
|
||||
private function &init_cache() {
|
||||
global $wp_object_cache;
|
||||
$cache_class = get_class( $wp_object_cache );
|
||||
$cache = new $cache_class();
|
||||
@ -26,11 +26,11 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
function test_miss() {
|
||||
public function test_miss() {
|
||||
$this->assertFalse( $this->cache->get( 'test_miss' ) );
|
||||
}
|
||||
|
||||
function test_add_get() {
|
||||
public function test_add_get() {
|
||||
$key = __FUNCTION__;
|
||||
$val = 'val';
|
||||
|
||||
@ -38,7 +38,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( $val, $this->cache->get( $key ) );
|
||||
}
|
||||
|
||||
function test_add_get_0() {
|
||||
public function test_add_get_0() {
|
||||
$key = __FUNCTION__;
|
||||
$val = 0;
|
||||
|
||||
@ -50,7 +50,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20004
|
||||
*/
|
||||
function test_add_get_null() {
|
||||
public function test_add_get_null() {
|
||||
$key = __FUNCTION__;
|
||||
$val = null;
|
||||
|
||||
@ -62,7 +62,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20004
|
||||
*/
|
||||
function test_add_get_false() {
|
||||
public function test_add_get_false() {
|
||||
$key = __FUNCTION__;
|
||||
$val = false;
|
||||
|
||||
@ -71,7 +71,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( $val, $this->cache->get( $key ) );
|
||||
}
|
||||
|
||||
function test_add() {
|
||||
public function test_add() {
|
||||
$key = __FUNCTION__;
|
||||
$val1 = 'val1';
|
||||
$val2 = 'val2';
|
||||
@ -84,7 +84,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( $val1, $this->cache->get( $key ) );
|
||||
}
|
||||
|
||||
function test_replace() {
|
||||
public function test_replace() {
|
||||
$key = __FUNCTION__;
|
||||
$val = 'val1';
|
||||
$val2 = 'val2';
|
||||
@ -98,7 +98,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( $val2, $this->cache->get( $key ) );
|
||||
}
|
||||
|
||||
function test_set() {
|
||||
public function test_set() {
|
||||
$key = __FUNCTION__;
|
||||
$val1 = 'val1';
|
||||
$val2 = 'val2';
|
||||
@ -111,7 +111,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( $val2, $this->cache->get( $key ) );
|
||||
}
|
||||
|
||||
function test_flush() {
|
||||
public function test_flush() {
|
||||
global $_wp_using_ext_object_cache;
|
||||
|
||||
if ( $_wp_using_ext_object_cache ) {
|
||||
@ -130,7 +130,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
// Make sure objects are cloned going to and from the cache.
|
||||
function test_object_refs() {
|
||||
public function test_object_refs() {
|
||||
$key = __FUNCTION__ . '_1';
|
||||
$object_a = new stdClass;
|
||||
$object_a->foo = 'alpha';
|
||||
@ -152,7 +152,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( 'bravo', $object_a->foo );
|
||||
}
|
||||
|
||||
function test_incr() {
|
||||
public function test_incr() {
|
||||
$key = __FUNCTION__;
|
||||
|
||||
$this->assertFalse( $this->cache->incr( $key ) );
|
||||
@ -165,7 +165,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( 3, $this->cache->get( $key ) );
|
||||
}
|
||||
|
||||
function test_wp_cache_incr() {
|
||||
public function test_wp_cache_incr() {
|
||||
$key = __FUNCTION__;
|
||||
|
||||
$this->assertFalse( wp_cache_incr( $key ) );
|
||||
@ -178,7 +178,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( 3, wp_cache_get( $key ) );
|
||||
}
|
||||
|
||||
function test_decr() {
|
||||
public function test_decr() {
|
||||
$key = __FUNCTION__;
|
||||
|
||||
$this->assertFalse( $this->cache->decr( $key ) );
|
||||
@ -198,7 +198,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21327
|
||||
*/
|
||||
function test_wp_cache_decr() {
|
||||
public function test_wp_cache_decr() {
|
||||
$key = __FUNCTION__;
|
||||
|
||||
$this->assertFalse( wp_cache_decr( $key ) );
|
||||
@ -215,7 +215,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( 0, wp_cache_get( $key ) );
|
||||
}
|
||||
|
||||
function test_delete() {
|
||||
public function test_delete() {
|
||||
$key = __FUNCTION__;
|
||||
$val = 'val';
|
||||
|
||||
@ -230,7 +230,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertFalse( $this->cache->delete( $key, 'default' ) );
|
||||
}
|
||||
|
||||
function test_wp_cache_delete() {
|
||||
public function test_wp_cache_delete() {
|
||||
$key = __FUNCTION__;
|
||||
$val = 'val';
|
||||
|
||||
@ -249,7 +249,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertFalse( wp_cache_delete( $key, 'default' ) );
|
||||
}
|
||||
|
||||
function test_switch_to_blog() {
|
||||
public function test_switch_to_blog() {
|
||||
if ( ! method_exists( $this->cache, 'switch_to_blog' ) ) {
|
||||
$this->markTestSkipped( 'This test requires a switch_to_blog() method on the cache object.' );
|
||||
}
|
||||
@ -295,7 +295,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( $val2, $this->cache->get( $key, 'global-cache-test' ) );
|
||||
}
|
||||
|
||||
function test_wp_cache_init() {
|
||||
public function test_wp_cache_init() {
|
||||
$new_blank_cache_object = new WP_Object_Cache();
|
||||
wp_cache_init();
|
||||
|
||||
@ -309,7 +309,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_wp_cache_replace() {
|
||||
public function test_wp_cache_replace() {
|
||||
$key = 'my-key';
|
||||
$val1 = 'first-val';
|
||||
$val2 = 'second-val';
|
||||
|
||||
@ -18,7 +18,7 @@ class Tests_Canonical extends WP_Canonical_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data_canonical
|
||||
*/
|
||||
function test_canonical( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) {
|
||||
public function test_canonical( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) {
|
||||
|
||||
if ( false !== strpos( $test_url, '%d' ) ) {
|
||||
if ( false !== strpos( $test_url, '/?author=%d' ) ) {
|
||||
@ -32,7 +32,7 @@ class Tests_Canonical extends WP_Canonical_UnitTestCase {
|
||||
$this->assertCanonical( $test_url, $expected, $ticket, $expected_doing_it_wrong );
|
||||
}
|
||||
|
||||
function data_canonical() {
|
||||
public function data_canonical() {
|
||||
/*
|
||||
* Data format:
|
||||
* [0]: Test URL.
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
*/
|
||||
class Tests_Canonical_CustomRules extends WP_Canonical_UnitTestCase {
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
global $wp_rewrite;
|
||||
// Add a custom Rewrite rule to test category redirections.
|
||||
@ -18,11 +18,11 @@ class Tests_Canonical_CustomRules extends WP_Canonical_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data
|
||||
*/
|
||||
function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) {
|
||||
public function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) {
|
||||
$this->assertCanonical( $test_url, $expected, $ticket, $expected_doing_it_wrong );
|
||||
}
|
||||
|
||||
function data() {
|
||||
public function data() {
|
||||
/*
|
||||
* Data format:
|
||||
* [0]: Test URL.
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* @group query
|
||||
*/
|
||||
class Tests_Canonical_HTTPS extends WP_Canonical_UnitTestCase {
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
||||
|
||||
@ -24,11 +24,11 @@ class Tests_Canonical_NoRewrite extends WP_Canonical_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data
|
||||
*/
|
||||
function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) {
|
||||
public function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) {
|
||||
$this->assertCanonical( $test_url, $expected, $ticket, $expected_doing_it_wrong );
|
||||
}
|
||||
|
||||
function data() {
|
||||
public function data() {
|
||||
/*
|
||||
* Test URL.
|
||||
* [0]: Test URL.
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
*/
|
||||
class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase {
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
update_option( 'show_on_front', 'page' );
|
||||
@ -35,11 +35,11 @@ class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data
|
||||
*/
|
||||
function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) {
|
||||
public function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) {
|
||||
$this->assertCanonical( $test_url, $expected, $ticket, $expected_doing_it_wrong );
|
||||
}
|
||||
|
||||
function data() {
|
||||
public function data() {
|
||||
/*
|
||||
* Data format:
|
||||
* [0]: Test URL.
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
*/
|
||||
class Tests_Canonical_Paged extends WP_Canonical_UnitTestCase {
|
||||
|
||||
function test_redirect_canonical_with_nextpage_pagination() {
|
||||
public function test_redirect_canonical_with_nextpage_pagination() {
|
||||
$para = 'This is a paragraph.
|
||||
This is a paragraph.
|
||||
This is a paragraph.';
|
||||
|
||||
@ -166,7 +166,7 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase {
|
||||
wp_trash_post( self::$posts['trash-page']->ID );
|
||||
}
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
self::setup_custom_types();
|
||||
}
|
||||
@ -248,7 +248,7 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase {
|
||||
* @type string $expected Expected URL.
|
||||
* }
|
||||
*/
|
||||
function data_canonical_redirects_to_plain_permalinks() {
|
||||
public function data_canonical_redirects_to_plain_permalinks() {
|
||||
$data = array();
|
||||
$all_user_list = array( 'anon', 'subscriber', 'content_author', 'editor' );
|
||||
$select_allow_list = array( 'content_author', 'editor' );
|
||||
@ -584,7 +584,7 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase {
|
||||
* @type string $expected Expected URL.
|
||||
* }
|
||||
*/
|
||||
function data_canonical_redirects_to_pretty_permalinks() {
|
||||
public function data_canonical_redirects_to_pretty_permalinks() {
|
||||
$data = array();
|
||||
$all_user_list = array( 'anon', 'subscriber', 'content_author', 'editor' );
|
||||
$select_allow_list = array( 'content_author', 'editor' );
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
*/
|
||||
class Tests_Category extends WP_UnitTestCase {
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
_unregister_taxonomy( 'test_tax_cat' );
|
||||
parent::tear_down();
|
||||
}
|
||||
@ -19,7 +19,7 @@ class Tests_Category extends WP_UnitTestCase {
|
||||
*
|
||||
* @expectedDeprecated get_all_category_ids
|
||||
*/
|
||||
function test_get_all_category_ids() {
|
||||
public function test_get_all_category_ids() {
|
||||
// Ccreate categories.
|
||||
self::factory()->category->create_many( 2 );
|
||||
|
||||
@ -35,7 +35,7 @@ class Tests_Category extends WP_UnitTestCase {
|
||||
/**
|
||||
* Validate get_category_by_slug function
|
||||
*/
|
||||
function test_get_category_by_slug() {
|
||||
public function test_get_category_by_slug() {
|
||||
|
||||
// Create test categories.
|
||||
$testcat = self::factory()->category->create_and_get(
|
||||
@ -65,7 +65,7 @@ class Tests_Category extends WP_UnitTestCase {
|
||||
/**
|
||||
* Validate _make_cat_compat function
|
||||
*/
|
||||
function test__make_cat_compat() {
|
||||
public function test__make_cat_compat() {
|
||||
|
||||
// Create test categories and array representations.
|
||||
$testcat_array = array(
|
||||
@ -142,7 +142,7 @@ class Tests_Category extends WP_UnitTestCase {
|
||||
/**
|
||||
* Validate get_cat_name function
|
||||
*/
|
||||
function test_get_cat_name() {
|
||||
public function test_get_cat_name() {
|
||||
|
||||
// Create test category.
|
||||
$testcat = self::factory()->category->create_and_get(
|
||||
@ -162,7 +162,7 @@ class Tests_Category extends WP_UnitTestCase {
|
||||
/**
|
||||
* Validate get_cat_name function
|
||||
*/
|
||||
function test_get_cat_ID() {
|
||||
public function test_get_cat_ID() {
|
||||
|
||||
// Create test category.
|
||||
$testcat = self::factory()->category->create_and_get(
|
||||
@ -182,7 +182,7 @@ class Tests_Category extends WP_UnitTestCase {
|
||||
/**
|
||||
* Validate get_category_by_path function
|
||||
*/
|
||||
function test_get_category_by_path() {
|
||||
public function test_get_category_by_path() {
|
||||
|
||||
// Create test categories.
|
||||
$root_id = self::factory()->category->create(
|
||||
|
||||
@ -34,7 +34,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
|
||||
self::delete_user( self::$editor_id );
|
||||
}
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
require_once ABSPATH . WPINC . '/class-phpass.php';
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ class Tests_Comment extends WP_UnitTestCase {
|
||||
public function test_wp_update_comment_is_wp_error() {
|
||||
$comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
|
||||
|
||||
add_filter( 'wp_update_comment_data', array( $this, '_wp_update_comment_data_filter' ), 10, 3 );
|
||||
add_filter( 'wp_update_comment_data', array( $this, 'wp_update_comment_data_filter' ), 10, 3 );
|
||||
|
||||
$result = wp_update_comment(
|
||||
array(
|
||||
@ -189,7 +189,7 @@ class Tests_Comment extends WP_UnitTestCase {
|
||||
true
|
||||
);
|
||||
|
||||
remove_filter( 'wp_update_comment_data', array( $this, '_wp_update_comment_data_filter' ), 10, 3 );
|
||||
remove_filter( 'wp_update_comment_data', array( $this, 'wp_update_comment_data_filter' ), 10, 3 );
|
||||
|
||||
$this->assertWPError( $result );
|
||||
}
|
||||
@ -197,7 +197,7 @@ class Tests_Comment extends WP_UnitTestCase {
|
||||
/**
|
||||
* Blocks comments from being updated by returning WP_Error.
|
||||
*/
|
||||
public function _wp_update_comment_data_filter( $data, $comment, $commentarr ) {
|
||||
public function wp_update_comment_data_filter( $data, $comment, $commentarr ) {
|
||||
return new WP_Error( 'comment_wrong', 'wp_update_comment_data filter fails for this comment.', 500 );
|
||||
}
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
|
||||
/**
|
||||
* setUp options
|
||||
*/
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
$this->option_page_comments = get_option( 'page_comments' );
|
||||
$this->option_page_comments = get_option( 'comments_per_page' );
|
||||
@ -26,7 +26,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
|
||||
/**
|
||||
* tearDown options
|
||||
*/
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
update_option( 'page_comments', $this->option_page_comments );
|
||||
update_option( 'comments_per_page', $this->option_page_comments );
|
||||
update_option( 'thread_comments', $this->option_page_comments );
|
||||
@ -37,7 +37,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
|
||||
/**
|
||||
* Validate get_comments_pages_count for empty comments
|
||||
*/
|
||||
function test_empty() {
|
||||
public function test_empty() {
|
||||
// Setup post and comments.
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
@ -64,7 +64,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
|
||||
/**
|
||||
* Validate get_comments_pages_count for treaded comments
|
||||
*/
|
||||
function test_threaded_comments() {
|
||||
public function test_threaded_comments() {
|
||||
// Setup post and comments.
|
||||
$post = self::factory()->post->create_and_get(
|
||||
array(
|
||||
@ -84,7 +84,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
|
||||
/**
|
||||
* Validate get_comments_pages_count for option tread_comments
|
||||
*/
|
||||
function test_option_thread_comments() {
|
||||
public function test_option_thread_comments() {
|
||||
|
||||
// Setup post and comments.
|
||||
$post = self::factory()->post->create_and_get(
|
||||
@ -115,7 +115,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
|
||||
/**
|
||||
* Validate $wp_query logic of get_comment_pages_count
|
||||
*/
|
||||
function test_wp_query_comments_per_page() {
|
||||
public function test_wp_query_comments_per_page() {
|
||||
global $wp_query;
|
||||
|
||||
update_option( 'posts_per_rss', 100 );
|
||||
@ -164,7 +164,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
|
||||
/**
|
||||
* Validate max_num_comment_pages logic of get_comment_pages_count
|
||||
*/
|
||||
function test_max_num_comment_pages() {
|
||||
public function test_max_num_comment_pages() {
|
||||
global $wp_query;
|
||||
$wp_query = new WP_Query();
|
||||
|
||||
|
||||
@ -1284,7 +1284,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
$this->assertSame( array( $comments[2] ), $q->comments );
|
||||
}
|
||||
|
||||
function test_get_comments_for_post() {
|
||||
public function test_get_comments_for_post() {
|
||||
$limit = 5;
|
||||
|
||||
$post_id = self::factory()->post->create();
|
||||
@ -1344,7 +1344,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21003
|
||||
*/
|
||||
function test_orderby_meta() {
|
||||
public function test_orderby_meta() {
|
||||
$comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
|
||||
$comment_id2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
|
||||
$comment_id3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
|
||||
@ -1596,7 +1596,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 27064
|
||||
*/
|
||||
function test_get_comments_by_user() {
|
||||
public function test_get_comments_by_user() {
|
||||
$users = self::factory()->user->create_many( 2 );
|
||||
self::factory()->comment->create(
|
||||
array(
|
||||
@ -1689,7 +1689,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 28434
|
||||
*/
|
||||
function test_fields_ids_query() {
|
||||
public function test_fields_ids_query() {
|
||||
$comment_1 = self::factory()->comment->create(
|
||||
array(
|
||||
'comment_post_ID' => self::$post_id,
|
||||
@ -1725,7 +1725,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 29189
|
||||
*/
|
||||
function test_fields_comment__in() {
|
||||
public function test_fields_comment__in() {
|
||||
$comment_1 = self::factory()->comment->create(
|
||||
array(
|
||||
'comment_post_ID' => self::$post_id,
|
||||
@ -1761,7 +1761,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 29189
|
||||
*/
|
||||
function test_fields_comment__not_in() {
|
||||
public function test_fields_comment__not_in() {
|
||||
$comment_1 = self::factory()->comment->create(
|
||||
array(
|
||||
'comment_post_ID' => self::$post_id,
|
||||
@ -1797,7 +1797,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 29189
|
||||
*/
|
||||
function test_fields_post__in() {
|
||||
public function test_fields_post__in() {
|
||||
$p1 = self::factory()->post->create();
|
||||
$p2 = self::factory()->post->create();
|
||||
$p3 = self::factory()->post->create();
|
||||
@ -1837,7 +1837,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 29189
|
||||
*/
|
||||
function test_fields_post__not_in() {
|
||||
public function test_fields_post__not_in() {
|
||||
$p1 = self::factory()->post->create();
|
||||
$p2 = self::factory()->post->create();
|
||||
$p3 = self::factory()->post->create();
|
||||
@ -1877,7 +1877,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 29885
|
||||
*/
|
||||
function test_fields_post_author__in() {
|
||||
public function test_fields_post_author__in() {
|
||||
$author_id1 = 105;
|
||||
$author_id2 = 106;
|
||||
|
||||
@ -1920,7 +1920,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 29885
|
||||
*/
|
||||
function test_fields_post_author__not_in() {
|
||||
public function test_fields_post_author__not_in() {
|
||||
$author_id1 = 111;
|
||||
$author_id2 = 112;
|
||||
|
||||
@ -1963,7 +1963,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 29885
|
||||
*/
|
||||
function test_fields_author__in() {
|
||||
public function test_fields_author__in() {
|
||||
$p1 = self::factory()->post->create();
|
||||
$p2 = self::factory()->post->create();
|
||||
$p3 = self::factory()->post->create();
|
||||
@ -2011,7 +2011,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 29885
|
||||
*/
|
||||
function test_fields_author__not_in() {
|
||||
public function test_fields_author__not_in() {
|
||||
$p1 = self::factory()->post->create();
|
||||
$p2 = self::factory()->post->create();
|
||||
$p3 = self::factory()->post->create();
|
||||
|
||||
@ -15,7 +15,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
|
||||
self::$post_id = $factory->post->create();
|
||||
}
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
wp_set_current_user( self::$author_id );
|
||||
@ -34,7 +34,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
|
||||
/**
|
||||
* Tests the extended model function that expects slashed data.
|
||||
*/
|
||||
function test_wp_new_comment() {
|
||||
public function test_wp_new_comment() {
|
||||
$post_id = self::$post_id;
|
||||
|
||||
// Not testing comment_author_email or comment_author_url
|
||||
@ -73,7 +73,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
|
||||
/**
|
||||
* Tests the controller function that expects slashed data.
|
||||
*/
|
||||
function test_edit_comment() {
|
||||
public function test_edit_comment() {
|
||||
$post_id = self::$post_id;
|
||||
$comment_id = self::factory()->comment->create(
|
||||
array(
|
||||
@ -119,7 +119,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
|
||||
/**
|
||||
* Tests the model function that expects slashed data.
|
||||
*/
|
||||
function test_wp_insert_comment() {
|
||||
public function test_wp_insert_comment() {
|
||||
$post_id = self::$post_id;
|
||||
|
||||
$comment_id = wp_insert_comment(
|
||||
@ -150,7 +150,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
|
||||
/**
|
||||
* Tests the model function that expects slashed data.
|
||||
*/
|
||||
function test_wp_update_comment() {
|
||||
public function test_wp_update_comment() {
|
||||
$post_id = self::$post_id;
|
||||
$comment_id = self::factory()->comment->create(
|
||||
array(
|
||||
|
||||
@ -19,7 +19,7 @@ class Tests_Comment_Template extends WP_UnitTestCase {
|
||||
self::$post_id = self::factory()->post->create();
|
||||
}
|
||||
|
||||
function test_get_comments_number() {
|
||||
public function test_get_comments_number() {
|
||||
$post_id = self::$post_id;
|
||||
|
||||
$this->assertSame( 0, get_comments_number( 0 ) );
|
||||
@ -32,7 +32,7 @@ class Tests_Comment_Template extends WP_UnitTestCase {
|
||||
$this->assertSame( '12', get_comments_number( get_post( $post_id ) ) );
|
||||
}
|
||||
|
||||
function test_get_comments_number_without_arg() {
|
||||
public function test_get_comments_number_without_arg() {
|
||||
$post_id = self::$post_id;
|
||||
$permalink = get_permalink( $post_id );
|
||||
$this->go_to( $permalink );
|
||||
@ -48,7 +48,7 @@ class Tests_Comment_Template extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 48772
|
||||
*/
|
||||
function test_get_comments_number_text_with_post_id() {
|
||||
public function test_get_comments_number_text_with_post_id() {
|
||||
$post_id = self::$post_id;
|
||||
$this->factory->comment->create_post_comments( $post_id, 6 );
|
||||
|
||||
@ -67,7 +67,7 @@ class Tests_Comment_Template extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 13651
|
||||
*/
|
||||
function test_get_comments_number_text_declension_with_default_args() {
|
||||
public function test_get_comments_number_text_declension_with_default_args() {
|
||||
$post_id = self::$post_id;
|
||||
$permalink = get_permalink( $post_id );
|
||||
$this->go_to( $permalink );
|
||||
@ -90,21 +90,21 @@ class Tests_Comment_Template extends WP_UnitTestCase {
|
||||
* @ticket 13651
|
||||
* @dataProvider data_get_comments_number_text_declension
|
||||
*/
|
||||
function test_get_comments_number_text_declension_with_custom_args( $number, $input, $output ) {
|
||||
public function test_get_comments_number_text_declension_with_custom_args( $number, $input, $output ) {
|
||||
$post_id = self::$post_id;
|
||||
$permalink = get_permalink( $post_id );
|
||||
|
||||
$this->factory->comment->create_post_comments( $post_id, $number );
|
||||
$this->go_to( $permalink );
|
||||
|
||||
add_filter( 'gettext_with_context', array( $this, '_enable_comment_number_declension' ), 10, 4 );
|
||||
add_filter( 'gettext_with_context', array( $this, 'enable_comment_number_declension' ), 10, 4 );
|
||||
|
||||
$this->assertSame( $output, get_comments_number_text( false, false, $input ) );
|
||||
|
||||
remove_filter( 'gettext_with_context', array( $this, '_enable_comment_number_declension' ), 10, 4 );
|
||||
remove_filter( 'gettext_with_context', array( $this, 'enable_comment_number_declension' ), 10, 4 );
|
||||
}
|
||||
|
||||
function _enable_comment_number_declension( $translation, $text, $context, $domain ) {
|
||||
public function enable_comment_number_declension( $translation, $text, $context, $domain ) {
|
||||
if ( 'Comment number declension: on or off' === $context ) {
|
||||
$translation = 'on';
|
||||
}
|
||||
@ -123,7 +123,7 @@ class Tests_Comment_Template extends WP_UnitTestCase {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
function data_get_comments_number_text_declension() {
|
||||
public function data_get_comments_number_text_declension() {
|
||||
return array(
|
||||
array(
|
||||
2,
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
*/
|
||||
class Tests_Comment_Walker extends WP_UnitTestCase {
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
$this->post_id = self::factory()->post->create();
|
||||
@ -14,7 +14,7 @@ class Tests_Comment_Walker extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 14041
|
||||
*/
|
||||
function test_has_children() {
|
||||
public function test_has_children() {
|
||||
$comment_parent = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) );
|
||||
$comment_child = self::factory()->comment->create(
|
||||
array(
|
||||
|
||||
@ -16,7 +16,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*/
|
||||
private $plus_thirty_minutes;
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
// Make sure the schedule is clear.
|
||||
_set_cron_array( array() );
|
||||
@ -24,19 +24,19 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->plus_thirty_minutes = strtotime( '+30 minutes' );
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
// Make sure the schedule is clear.
|
||||
_set_cron_array( array() );
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
function test_wp_get_schedule_empty() {
|
||||
public function test_wp_get_schedule_empty() {
|
||||
// Nothing scheduled.
|
||||
$hook = __FUNCTION__;
|
||||
$this->assertFalse( wp_get_schedule( $hook ) );
|
||||
}
|
||||
|
||||
function test_schedule_event_single() {
|
||||
public function test_schedule_event_single() {
|
||||
// Schedule an event and make sure it's returned by wp_next_scheduled().
|
||||
$hook = __FUNCTION__;
|
||||
$timestamp = strtotime( '+1 hour' );
|
||||
@ -50,7 +50,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
|
||||
}
|
||||
|
||||
function test_schedule_event_single_args() {
|
||||
public function test_schedule_event_single_args() {
|
||||
// Schedule an event with arguments and make sure it's returned by wp_next_scheduled().
|
||||
$hook = 'event';
|
||||
$timestamp = strtotime( '+1 hour' );
|
||||
@ -68,7 +68,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertFalse( wp_get_schedule( $hook, $args ) );
|
||||
}
|
||||
|
||||
function test_schedule_event() {
|
||||
public function test_schedule_event() {
|
||||
// Schedule an event and make sure it's returned by wp_next_scheduled().
|
||||
$hook = __FUNCTION__;
|
||||
$recur = 'hourly';
|
||||
@ -82,7 +82,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertSame( $recur, wp_get_schedule( $hook ) );
|
||||
}
|
||||
|
||||
function test_schedule_event_args() {
|
||||
public function test_schedule_event_args() {
|
||||
// Schedule an event and make sure it's returned by wp_next_scheduled().
|
||||
$hook = 'event';
|
||||
$timestamp = strtotime( '+1 hour' );
|
||||
@ -111,7 +111,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::wp_schedule_event
|
||||
*/
|
||||
function test_wp_schedule_event_without_cron_option_does_not_throw_warning() {
|
||||
public function test_wp_schedule_event_without_cron_option_does_not_throw_warning() {
|
||||
delete_option( 'cron' );
|
||||
|
||||
// Verify that the cause of the error is in place.
|
||||
@ -132,7 +132,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::wp_schedule_single_event
|
||||
*/
|
||||
function test_wp_schedule_single_event_without_cron_option() {
|
||||
public function test_wp_schedule_single_event_without_cron_option() {
|
||||
delete_option( 'cron' );
|
||||
|
||||
// Verify that the cause of the error is in place.
|
||||
@ -148,7 +148,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertNotContains( false, get_option( 'cron' ), 'Resulting cron array contains the value "false"' );
|
||||
}
|
||||
|
||||
function test_unschedule_event() {
|
||||
public function test_unschedule_event() {
|
||||
// Schedule an event and make sure it's returned by wp_next_scheduled().
|
||||
$hook = __FUNCTION__;
|
||||
$timestamp = strtotime( '+1 hour' );
|
||||
@ -162,7 +162,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertFalse( wp_next_scheduled( $hook ) );
|
||||
}
|
||||
|
||||
function test_clear_schedule() {
|
||||
public function test_clear_schedule() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
|
||||
@ -189,7 +189,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertFalse( wp_next_scheduled( $hook, $args ) );
|
||||
}
|
||||
|
||||
function test_clear_undefined_schedule() {
|
||||
public function test_clear_undefined_schedule() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
|
||||
@ -201,7 +201,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertSame( 0, $hook_unscheduled );
|
||||
}
|
||||
|
||||
function test_clear_schedule_multiple_args() {
|
||||
public function test_clear_schedule_multiple_args() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1', 'arg2' );
|
||||
|
||||
@ -230,7 +230,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 10468
|
||||
*/
|
||||
function test_clear_schedule_new_args() {
|
||||
public function test_clear_schedule_new_args() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$multi_hook = __FUNCTION__ . '_multi';
|
||||
@ -268,7 +268,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 18997
|
||||
*/
|
||||
function test_unschedule_hook() {
|
||||
public function test_unschedule_hook() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( rand_str() );
|
||||
|
||||
@ -288,7 +288,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertFalse( wp_next_scheduled( $hook ) );
|
||||
}
|
||||
|
||||
function test_unschedule_undefined_hook() {
|
||||
public function test_unschedule_undefined_hook() {
|
||||
$hook = __FUNCTION__;
|
||||
$unrelated_hook = __FUNCTION__ . '_two';
|
||||
|
||||
@ -309,7 +309,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 6966
|
||||
*/
|
||||
function test_duplicate_event() {
|
||||
public function test_duplicate_event() {
|
||||
// Duplicate events close together should be skipped.
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
@ -332,7 +332,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 6966
|
||||
*/
|
||||
function test_not_duplicate_event() {
|
||||
public function test_not_duplicate_event() {
|
||||
// Duplicate events far apart should work normally.
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
@ -351,7 +351,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertSame( $ts1, wp_next_scheduled( $hook, $args ) );
|
||||
}
|
||||
|
||||
function test_not_duplicate_event_reversed() {
|
||||
public function test_not_duplicate_event_reversed() {
|
||||
// Duplicate events far apart should work normally regardless of order.
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
@ -376,7 +376,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 32656
|
||||
*/
|
||||
function test_pre_schedule_event_filter() {
|
||||
public function test_pre_schedule_event_filter() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts1 = strtotime( '+30 minutes' );
|
||||
@ -384,7 +384,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
|
||||
$expected = _get_cron_array();
|
||||
|
||||
add_filter( 'pre_schedule_event', array( $this, '_filter_pre_schedule_event_filter' ), 10, 2 );
|
||||
add_filter( 'pre_schedule_event', array( $this, 'filter_pre_schedule_event_filter' ), 10, 2 );
|
||||
|
||||
$this->assertTrue( wp_schedule_single_event( $ts1, $hook, $args ) );
|
||||
$this->assertTrue( wp_schedule_event( $ts2, 'hourly', $hook ) );
|
||||
@ -410,7 +410,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
/**
|
||||
* Filter the scheduling of events to use the preflight array.
|
||||
*/
|
||||
function _filter_pre_schedule_event_filter( $null, $event ) {
|
||||
public function filter_pre_schedule_event_filter( $null, $event ) {
|
||||
$key = md5( serialize( $event->args ) );
|
||||
|
||||
$this->preflight_cron_array[ $event->timestamp ][ $event->hook ][ $key ] = array(
|
||||
@ -428,7 +428,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 32656
|
||||
*/
|
||||
function test_pre_reschedule_event_filter() {
|
||||
public function test_pre_reschedule_event_filter() {
|
||||
$hook = __FUNCTION__;
|
||||
$ts1 = strtotime( '+30 minutes' );
|
||||
|
||||
@ -452,7 +452,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 32656
|
||||
*/
|
||||
function test_pre_unschedule_event_filter() {
|
||||
public function test_pre_unschedule_event_filter() {
|
||||
$hook = __FUNCTION__;
|
||||
$ts1 = strtotime( '+30 minutes' );
|
||||
|
||||
@ -476,7 +476,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 32656
|
||||
*/
|
||||
function test_pre_clear_scheduled_hook_filters() {
|
||||
public function test_pre_clear_scheduled_hook_filters() {
|
||||
$hook = __FUNCTION__;
|
||||
$ts1 = strtotime( '+30 minutes' );
|
||||
|
||||
@ -507,7 +507,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 32656
|
||||
*/
|
||||
function test_pre_scheduled_event_hooks() {
|
||||
public function test_pre_scheduled_event_hooks() {
|
||||
add_filter( 'pre_get_scheduled_event', array( $this, 'filter_pre_scheduled_event_hooks' ) );
|
||||
|
||||
$actual = wp_get_scheduled_event( 'preflight_event', array(), $this->plus_thirty_minutes );
|
||||
@ -524,7 +524,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertSame( $expected->timestamp, $actual2 );
|
||||
}
|
||||
|
||||
function filter_pre_scheduled_event_hooks() {
|
||||
public function filter_pre_scheduled_event_hooks() {
|
||||
return (object) array(
|
||||
'hook' => 'preflight_event',
|
||||
'timestamp' => $this->plus_thirty_minutes,
|
||||
@ -541,7 +541,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 45976.
|
||||
*/
|
||||
function test_get_scheduled_event_singles() {
|
||||
public function test_get_scheduled_event_singles() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts_late = strtotime( '+30 minutes' );
|
||||
@ -584,7 +584,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 45976.
|
||||
*/
|
||||
function test_get_scheduled_event_recurring() {
|
||||
public function test_get_scheduled_event_recurring() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts_late = strtotime( '+30 minutes' );
|
||||
@ -628,7 +628,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 45976.
|
||||
*/
|
||||
function test_get_scheduled_event_false() {
|
||||
public function test_get_scheduled_event_false() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts = strtotime( '+3 minutes' );
|
||||
@ -653,7 +653,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 44818
|
||||
*/
|
||||
function test_duplicate_past_event() {
|
||||
public function test_duplicate_past_event() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts1 = strtotime( '-14 minutes' );
|
||||
@ -680,7 +680,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 44818
|
||||
*/
|
||||
function test_duplicate_near_future_event() {
|
||||
public function test_duplicate_near_future_event() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts1 = strtotime( '+4 minutes' );
|
||||
@ -708,7 +708,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 44818
|
||||
*/
|
||||
function test_duplicate_future_event() {
|
||||
public function test_duplicate_future_event() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts1 = strtotime( '+15 minutes' );
|
||||
@ -732,7 +732,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 44818
|
||||
*/
|
||||
function test_not_duplicate_future_event() {
|
||||
public function test_not_duplicate_future_event() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts1 = strtotime( '+15 minutes' );
|
||||
|
||||
@ -24,7 +24,7 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
|
||||
/**
|
||||
* Set up.
|
||||
*/
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
|
||||
@ -37,7 +37,7 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Control::check_capabilities()
|
||||
*/
|
||||
function test_check_capabilities() {
|
||||
public function test_check_capabilities() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$control = new WP_Customize_Control(
|
||||
$this->wp_customize,
|
||||
@ -105,7 +105,7 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 38164
|
||||
*/
|
||||
function test_dropdown_pages() {
|
||||
public function test_dropdown_pages() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$this->assertInstanceOf( 'WP_Customize_Nav_Menus', $this->wp_customize->nav_menus );
|
||||
@ -172,7 +172,7 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
|
||||
/**
|
||||
* Tear down.
|
||||
*/
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$this->wp_customize = null;
|
||||
unset( $GLOBALS['wp_customize'] );
|
||||
parent::tear_down();
|
||||
|
||||
@ -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( '' );
|
||||
|
||||
@ -53,7 +53,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
/**
|
||||
* Set up test.
|
||||
*/
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
|
||||
$this->manager = $this->instantiate();
|
||||
@ -70,7 +70,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
/**
|
||||
* Tear down test.
|
||||
*/
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$this->manager = null;
|
||||
unset( $GLOBALS['wp_customize'] );
|
||||
$_REQUEST = array();
|
||||
@ -83,7 +83,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @throws Exception If an inactive core Twenty* theme cannot be found.
|
||||
* @return string Theme slug (stylesheet).
|
||||
*/
|
||||
function get_inactive_core_theme() {
|
||||
private function get_inactive_core_theme() {
|
||||
$stylesheet = get_stylesheet();
|
||||
foreach ( wp_get_themes() as $theme ) {
|
||||
if ( $theme->stylesheet !== $stylesheet && 0 === strpos( $theme->stylesheet, 'twenty' ) ) {
|
||||
@ -98,7 +98,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @return WP_Customize_Manager
|
||||
*/
|
||||
function instantiate() {
|
||||
private function instantiate() {
|
||||
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
|
||||
return $GLOBALS['wp_customize'];
|
||||
}
|
||||
@ -108,7 +108,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers WP_Customize_Manager::__construct
|
||||
*/
|
||||
function test_constructor() {
|
||||
public function test_constructor() {
|
||||
$uuid = wp_generate_uuid4();
|
||||
$theme = 'twentyfifteen';
|
||||
$messenger_channel = 'preview-123';
|
||||
@ -227,7 +227,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers WP_Customize_Manager::setup_theme
|
||||
*/
|
||||
function test_setup_theme_in_customize_admin() {
|
||||
public function test_setup_theme_in_customize_admin() {
|
||||
global $pagenow, $wp_customize;
|
||||
$pagenow = 'customize.php';
|
||||
set_current_screen( 'customize' );
|
||||
@ -273,7 +273,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @see _delete_option_fresh_site()
|
||||
* @ticket 41039
|
||||
*/
|
||||
function test_fresh_site_flag_clearing() {
|
||||
public function test_fresh_site_flag_clearing() {
|
||||
global $wp_customize, $wpdb;
|
||||
|
||||
// Make sure fresh site flag is cleared when publishing a changeset.
|
||||
@ -296,7 +296,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers WP_Customize_Manager::setup_theme
|
||||
*/
|
||||
function test_setup_theme_in_frontend() {
|
||||
public function test_setup_theme_in_frontend() {
|
||||
global $wp_customize, $pagenow, $show_admin_bar;
|
||||
$pagenow = 'front';
|
||||
set_current_screen( 'front' );
|
||||
@ -331,7 +331,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 39221
|
||||
* @covers WP_Customize_Manager::settings_previewed
|
||||
*/
|
||||
function test_settings_previewed() {
|
||||
public function test_settings_previewed() {
|
||||
$wp_customize = new WP_Customize_Manager( array( 'settings_previewed' => false ) );
|
||||
$this->assertFalse( $wp_customize->settings_previewed() );
|
||||
|
||||
@ -384,7 +384,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::changeset_uuid
|
||||
*/
|
||||
function test_changeset_uuid() {
|
||||
public function test_changeset_uuid() {
|
||||
$uuid = wp_generate_uuid4();
|
||||
$wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
|
||||
$this->assertSame( $uuid, $wp_customize->changeset_uuid() );
|
||||
@ -398,7 +398,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::wp_loaded
|
||||
*/
|
||||
function test_wp_loaded() {
|
||||
public function test_wp_loaded() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$wp_customize = new WP_Customize_Manager();
|
||||
$title = 'Hello World';
|
||||
@ -416,7 +416,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::find_changeset_post_id
|
||||
*/
|
||||
function test_find_changeset_post_id() {
|
||||
public function test_find_changeset_post_id() {
|
||||
$uuid = wp_generate_uuid4();
|
||||
$post_id = $this->factory()->post->create(
|
||||
array(
|
||||
@ -441,7 +441,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::changeset_post_id
|
||||
*/
|
||||
function test_changeset_post_id() {
|
||||
public function test_changeset_post_id() {
|
||||
$uuid = wp_generate_uuid4();
|
||||
$wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
|
||||
$this->assertNull( $wp_customize->changeset_post_id() );
|
||||
@ -465,7 +465,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::changeset_data
|
||||
*/
|
||||
function test_changeset_data() {
|
||||
public function test_changeset_data() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$uuid = wp_generate_uuid4();
|
||||
$wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
|
||||
@ -543,7 +543,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @covers WP_Customize_Manager::_save_starter_content_changeset
|
||||
* @requires function imagejpeg
|
||||
*/
|
||||
function test_import_theme_starter_content() {
|
||||
public function test_import_theme_starter_content() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
register_nav_menu( 'top', 'Top' );
|
||||
add_theme_support( 'custom-logo' );
|
||||
@ -811,7 +811,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 45484
|
||||
* @covers WP_Customize_Manager::import_theme_starter_content
|
||||
*/
|
||||
function test_import_theme_starter_content_with_nested_arrays() {
|
||||
public function test_import_theme_starter_content_with_nested_arrays() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
|
||||
$existing_published_home_page_id = $this->factory()->post->create(
|
||||
@ -885,7 +885,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::customize_preview_init
|
||||
*/
|
||||
function test_customize_preview_init() {
|
||||
public function test_customize_preview_init() {
|
||||
|
||||
// Test authorized admin user.
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
@ -930,7 +930,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 40020
|
||||
* @covers WP_Customize_Manager::filter_iframe_security_headers
|
||||
*/
|
||||
function test_filter_iframe_security_headers() {
|
||||
public function test_filter_iframe_security_headers() {
|
||||
$wp_customize = new WP_Customize_Manager();
|
||||
$headers = $wp_customize->filter_iframe_security_headers( array() );
|
||||
$this->assertArrayHasKey( 'X-Frame-Options', $headers );
|
||||
@ -945,7 +945,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::add_state_query_params
|
||||
*/
|
||||
function test_add_state_query_params() {
|
||||
public function test_add_state_query_params() {
|
||||
$preview_theme = $this->get_inactive_core_theme();
|
||||
|
||||
$uuid = wp_generate_uuid4();
|
||||
@ -1004,7 +1004,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::save_changeset_post
|
||||
*/
|
||||
function test_save_changeset_post_without_theme_activation() {
|
||||
public function test_save_changeset_post_without_theme_activation() {
|
||||
global $wp_customize;
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
|
||||
@ -1421,7 +1421,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param array $context Context.
|
||||
* @return array Data.
|
||||
*/
|
||||
function filter_customize_changeset_save_data( $data, $context ) {
|
||||
public function filter_customize_changeset_save_data( $data, $context ) {
|
||||
$this->customize_changeset_save_data_call_count += 1;
|
||||
$this->assertIsArray( $data );
|
||||
$this->assertIsArray( $context );
|
||||
@ -1440,7 +1440,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @return WP_Error Error.
|
||||
*/
|
||||
function return_illegal_error() {
|
||||
public function return_illegal_error() {
|
||||
return new WP_Error( 'illegal' );
|
||||
}
|
||||
|
||||
@ -1451,7 +1451,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @covers WP_Customize_Manager::save_changeset_post
|
||||
* @covers WP_Customize_Manager::update_stashed_theme_mod_settings
|
||||
*/
|
||||
function test_save_changeset_post_with_theme_activation() {
|
||||
public function test_save_changeset_post_with_theme_activation() {
|
||||
global $wp_customize;
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
|
||||
@ -1489,7 +1489,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 38705
|
||||
* @covers WP_Customize_Manager::save_changeset_post
|
||||
*/
|
||||
function test_save_changeset_post_with_varying_users() {
|
||||
public function test_save_changeset_post_with_varying_users() {
|
||||
global $wp_customize;
|
||||
|
||||
add_theme_support( 'custom-background' );
|
||||
@ -1664,7 +1664,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @see wp_delete_auto_drafts()
|
||||
* @covers WP_Customize_Manager::save_changeset_post
|
||||
*/
|
||||
function test_save_changeset_post_dumping_auto_draft_date() {
|
||||
public function test_save_changeset_post_dumping_auto_draft_date() {
|
||||
global $wp_customize;
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
|
||||
@ -1704,7 +1704,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 38865
|
||||
* @covers WP_Customize_Manager::save_changeset_post
|
||||
*/
|
||||
function test_save_changeset_post_with_unchanged_values() {
|
||||
public function test_save_changeset_post_with_unchanged_values() {
|
||||
global $wp_customize;
|
||||
|
||||
add_theme_support( 'custom-background' );
|
||||
@ -1904,7 +1904,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 41621
|
||||
* @covers WP_Customize_Manager::save_changeset_post
|
||||
*/
|
||||
function test_remove_setting_from_changeset_post() {
|
||||
public function test_remove_setting_from_changeset_post() {
|
||||
$uuid = wp_generate_uuid4();
|
||||
|
||||
$manager = $this->create_test_manager( $uuid );
|
||||
@ -1940,7 +1940,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 38705
|
||||
* @covers WP_Customize_Manager::save_changeset_post
|
||||
*/
|
||||
function test_save_changeset_post_with_varying_unfiltered_html_cap() {
|
||||
public function test_save_changeset_post_with_varying_unfiltered_html_cap() {
|
||||
global $wp_customize;
|
||||
grant_super_admin( self::$admin_user_id );
|
||||
$this->assertTrue( user_can( self::$admin_user_id, 'unfiltered_html' ) );
|
||||
@ -2012,7 +2012,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Widgets::schedule_customize_register()
|
||||
* @see WP_Customize_Widgets::customize_register()
|
||||
*/
|
||||
function test_wp_customize_publish_changeset() {
|
||||
public function test_wp_customize_publish_changeset() {
|
||||
global $wp_customize;
|
||||
$wp_customize = null;
|
||||
|
||||
@ -2058,7 +2058,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 41336
|
||||
* @covers WP_Customize_Manager::save_changeset_post
|
||||
*/
|
||||
function test_publish_changeset_with_future_status_when_future_date() {
|
||||
public function test_publish_changeset_with_future_status_when_future_date() {
|
||||
$wp_customize = $this->create_test_manager( wp_generate_uuid4() );
|
||||
|
||||
$wp_customize->save_changeset_post(
|
||||
@ -2079,7 +2079,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @covers WP_Customize_Manager::save_changeset_post
|
||||
* @covers WP_Customize_Manager::get_changeset_post_data
|
||||
*/
|
||||
function test_save_changeset_post_for_bad_changeset() {
|
||||
public function test_save_changeset_post_for_bad_changeset() {
|
||||
$uuid = wp_generate_uuid4();
|
||||
$post_id = wp_insert_post(
|
||||
array(
|
||||
@ -2150,7 +2150,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @param WP_Customize_Manager $wp_customize Manager.
|
||||
*/
|
||||
function register_scratchpad_setting( WP_Customize_Manager $wp_customize ) {
|
||||
public function register_scratchpad_setting( WP_Customize_Manager $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'scratchpad',
|
||||
array(
|
||||
@ -2167,7 +2167,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param string $value Value.
|
||||
* @return string Value.
|
||||
*/
|
||||
function filter_sanitize_scratchpad( $value ) {
|
||||
public function filter_sanitize_scratchpad( $value ) {
|
||||
return apply_filters( 'content_save_pre', $value );
|
||||
}
|
||||
|
||||
@ -2185,7 +2185,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param WP_Customize_Setting $setting Setting.
|
||||
* @return mixed Value.
|
||||
*/
|
||||
function filter_customize_setting_to_log_current_user( $value, $setting ) {
|
||||
public function filter_customize_setting_to_log_current_user( $value, $setting ) {
|
||||
$this->filtered_setting_current_user_ids[ $setting->id ] = get_current_user_id();
|
||||
return $value;
|
||||
}
|
||||
@ -2196,7 +2196,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::is_cross_domain
|
||||
*/
|
||||
function test_is_cross_domain() {
|
||||
public function test_is_cross_domain() {
|
||||
$wp_customize = new WP_Customize_Manager();
|
||||
|
||||
update_option( 'home', 'http://example.com' );
|
||||
@ -2214,7 +2214,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::get_allowed_urls
|
||||
*/
|
||||
function test_get_allowed_urls() {
|
||||
public function test_get_allowed_urls() {
|
||||
$wp_customize = new WP_Customize_Manager();
|
||||
$this->assertFalse( is_ssl() );
|
||||
$this->assertFalse( $wp_customize->is_cross_domain() );
|
||||
@ -2232,7 +2232,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param array $urls URLs.
|
||||
* @return array URLs.
|
||||
*/
|
||||
function filter_customize_allowed_urls( $urls ) {
|
||||
public function filter_customize_allowed_urls( $urls ) {
|
||||
$urls[] = 'http://headless.example.com/';
|
||||
return $urls;
|
||||
}
|
||||
@ -2242,7 +2242,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @group ajax
|
||||
*/
|
||||
function test_doing_ajax() {
|
||||
public function test_doing_ajax() {
|
||||
add_filter( 'wp_doing_ajax', '__return_true' );
|
||||
|
||||
$manager = $this->manager;
|
||||
@ -2256,7 +2256,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
/**
|
||||
* Test ! WP_Customize_Manager::doing_ajax().
|
||||
*/
|
||||
function test_not_doing_ajax() {
|
||||
public function test_not_doing_ajax() {
|
||||
add_filter( 'wp_doing_ajax', '__return_false' );
|
||||
|
||||
$manager = $this->manager;
|
||||
@ -2268,7 +2268,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 30988
|
||||
*/
|
||||
function test_unsanitized_post_values_from_input() {
|
||||
public function test_unsanitized_post_values_from_input() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$manager = $this->manager;
|
||||
|
||||
@ -2297,7 +2297,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::unsanitized_post_values
|
||||
*/
|
||||
function test_unsanitized_post_values_with_changeset_and_stashed_theme_mods() {
|
||||
public function test_unsanitized_post_values_with_changeset_and_stashed_theme_mods() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
|
||||
$preview_theme = $this->get_inactive_core_theme();
|
||||
@ -2421,7 +2421,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 30988
|
||||
*/
|
||||
function test_post_value() {
|
||||
public function test_post_value() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$posted_settings = array(
|
||||
'foo' => 'OOF',
|
||||
@ -2445,7 +2445,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 34893
|
||||
*/
|
||||
function test_invalid_post_value() {
|
||||
public function test_invalid_post_value() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$default_value = 'foo_default';
|
||||
$setting = $this->manager->add_setting(
|
||||
@ -2483,7 +2483,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param mixed $value Value.
|
||||
* @return string|WP_Error
|
||||
*/
|
||||
function filter_customize_sanitize_foo( $value ) {
|
||||
public function filter_customize_sanitize_foo( $value ) {
|
||||
if ( 'return_null_in_sanitize' === $value ) {
|
||||
$value = null;
|
||||
} elseif ( is_string( $value ) ) {
|
||||
@ -2502,7 +2502,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param mixed $value Value.
|
||||
* @return WP_Error
|
||||
*/
|
||||
function filter_customize_validate_foo( $validity, $value ) {
|
||||
public function filter_customize_validate_foo( $validity, $value ) {
|
||||
if ( false !== stripos( $value, '<script' ) ) {
|
||||
$validity->add( 'invalid_value_in_validate', __( 'Invalid value.' ), array( 'source' => 'filter_customize_validate_foo' ) );
|
||||
}
|
||||
@ -2514,7 +2514,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 37247
|
||||
*/
|
||||
function test_post_value_validation_sanitization_order() {
|
||||
public function test_post_value_validation_sanitization_order() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$default_value = '0';
|
||||
$setting = $this->manager->add_setting(
|
||||
@ -2539,7 +2539,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param mixed $value Value.
|
||||
* @return string|WP_Error
|
||||
*/
|
||||
function filter_customize_sanitize_numeric( $value ) {
|
||||
public function filter_customize_sanitize_numeric( $value ) {
|
||||
return absint( $value );
|
||||
}
|
||||
|
||||
@ -2550,7 +2550,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param mixed $value Value.
|
||||
* @return WP_Error
|
||||
*/
|
||||
function filter_customize_validate_numeric( $validity, $value ) {
|
||||
public function filter_customize_validate_numeric( $validity, $value ) {
|
||||
if ( ! is_string( $value ) || ! is_numeric( $value ) ) {
|
||||
$validity->add( 'invalid_value_in_validate', __( 'Invalid value.' ), array( 'source' => 'filter_customize_validate_numeric' ) );
|
||||
}
|
||||
@ -2562,7 +2562,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Manager::validate_setting_values()
|
||||
*/
|
||||
function test_validate_setting_values() {
|
||||
public function test_validate_setting_values() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$setting = $this->manager->add_setting(
|
||||
'foo',
|
||||
@ -2611,7 +2611,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 37638
|
||||
* @covers WP_Customize_Manager::validate_setting_values
|
||||
*/
|
||||
function test_late_validate_setting_values() {
|
||||
public function test_late_validate_setting_values() {
|
||||
$setting = new Test_Setting_Without_Applying_Validate_Filter( $this->manager, 'required' );
|
||||
$this->manager->add_setting( $setting );
|
||||
|
||||
@ -2637,7 +2637,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 30937
|
||||
* @covers WP_Customize_Manager::validate_setting_values
|
||||
*/
|
||||
function test_validate_setting_values_args() {
|
||||
public function test_validate_setting_values_args() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$this->manager->register_controls();
|
||||
|
||||
@ -2675,7 +2675,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param WP_Customize_Setting $setting Setting.
|
||||
* @return WP_Error Validity.
|
||||
*/
|
||||
function late_validate_length( $validity, $value, $setting ) {
|
||||
public function late_validate_length( $validity, $value, $setting ) {
|
||||
$this->assertInstanceOf( 'WP_Customize_Setting', $setting );
|
||||
if ( strlen( $value ) < 10 ) {
|
||||
$validity->add( 'minlength', '' );
|
||||
@ -2688,7 +2688,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 37247
|
||||
*/
|
||||
function test_validate_setting_values_validation_sanitization_order() {
|
||||
public function test_validate_setting_values_validation_sanitization_order() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$setting = $this->manager->add_setting(
|
||||
'numeric',
|
||||
@ -2709,7 +2709,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Manager::prepare_setting_validity_for_js()
|
||||
*/
|
||||
function test_prepare_setting_validity_for_js() {
|
||||
public function test_prepare_setting_validity_for_js() {
|
||||
$this->assertTrue( $this->manager->prepare_setting_validity_for_js( true ) );
|
||||
$error = new WP_Error();
|
||||
$error->add( 'bad_letter', 'Bad letter', 'A' );
|
||||
@ -2733,7 +2733,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Manager::set_post_value()
|
||||
*/
|
||||
function test_set_post_value() {
|
||||
public function test_set_post_value() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$this->manager->add_setting(
|
||||
'foo',
|
||||
@ -2768,7 +2768,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param mixed $value Value.
|
||||
* @return int Value.
|
||||
*/
|
||||
function sanitize_foo_for_test_set_post_value( $value ) {
|
||||
public function sanitize_foo_for_test_set_post_value( $value ) {
|
||||
return (int) $value;
|
||||
}
|
||||
|
||||
@ -2787,7 +2787,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @param mixed ...$args Optional arguments passed to the action.
|
||||
*/
|
||||
function capture_customize_post_value_set_actions( ...$args ) {
|
||||
public function capture_customize_post_value_set_actions( ...$args ) {
|
||||
$action = current_action();
|
||||
$this->captured_customize_post_value_set_actions[] = compact( 'action', 'args' );
|
||||
}
|
||||
@ -2797,7 +2797,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 30936
|
||||
*/
|
||||
function test_add_dynamic_settings() {
|
||||
public function test_add_dynamic_settings() {
|
||||
$manager = $this->manager;
|
||||
$setting_ids = array( 'foo', 'bar' );
|
||||
$manager->add_setting( 'foo', array( 'default' => 'foo_default' ) );
|
||||
@ -2818,7 +2818,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 38013
|
||||
* @covers WP_Customize_Manager::has_published_pages
|
||||
*/
|
||||
function test_has_published_pages() {
|
||||
public function test_has_published_pages() {
|
||||
foreach ( get_pages() as $page ) {
|
||||
wp_delete_post( $page->ID, true );
|
||||
}
|
||||
@ -2847,7 +2847,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 38013
|
||||
* @covers WP_Customize_Manager::has_published_pages
|
||||
*/
|
||||
function test_has_published_pages_when_nav_menus_created_posts() {
|
||||
public function test_has_published_pages_when_nav_menus_created_posts() {
|
||||
foreach ( get_pages() as $page ) {
|
||||
wp_delete_post( $page->ID, true );
|
||||
}
|
||||
@ -2876,7 +2876,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 30936
|
||||
*/
|
||||
function test_register_dynamic_settings() {
|
||||
public function test_register_dynamic_settings() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$posted_settings = array(
|
||||
'foo' => 'OOF',
|
||||
@ -2898,7 +2898,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
/**
|
||||
* In lieu of closures, callback for customize_register action added in test_register_dynamic_settings().
|
||||
*/
|
||||
function action_customize_register_for_dynamic_settings() {
|
||||
public function action_customize_register_for_dynamic_settings() {
|
||||
add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_customize_dynamic_setting_args_for_test_dynamic_settings' ), 10, 2 );
|
||||
add_filter( 'customize_dynamic_setting_class', array( $this, 'filter_customize_dynamic_setting_class_for_test_dynamic_settings' ), 10, 3 );
|
||||
}
|
||||
@ -2910,7 +2910,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param string $setting_id Setting ID.
|
||||
* @return array
|
||||
*/
|
||||
function filter_customize_dynamic_setting_args_for_test_dynamic_settings( $setting_args, $setting_id ) {
|
||||
public function filter_customize_dynamic_setting_args_for_test_dynamic_settings( $setting_args, $setting_id ) {
|
||||
$this->assertIsString( $setting_id );
|
||||
if ( in_array( $setting_id, array( 'foo', 'bar' ), true ) ) {
|
||||
$setting_args = array( 'default' => "dynamic_{$setting_id}_default" );
|
||||
@ -2926,7 +2926,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param array $setting_args Setting args.
|
||||
* @return string
|
||||
*/
|
||||
function filter_customize_dynamic_setting_class_for_test_dynamic_settings( $setting_class, $setting_id, $setting_args ) {
|
||||
public function filter_customize_dynamic_setting_class_for_test_dynamic_settings( $setting_class, $setting_id, $setting_args ) {
|
||||
$this->assertSame( 'WP_Customize_Setting', $setting_class );
|
||||
$this->assertIsString( $setting_id );
|
||||
$this->assertIsArray( $setting_args );
|
||||
@ -2938,7 +2938,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Manager::get_document_title_template()
|
||||
*/
|
||||
function test_get_document_title_template() {
|
||||
public function test_get_document_title_template() {
|
||||
$tpl = $this->manager->get_document_title_template();
|
||||
$this->assertStringContainsString( '%s', $tpl );
|
||||
}
|
||||
@ -2949,7 +2949,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Manager::get_preview_url()
|
||||
* @see WP_Customize_Manager::set_preview_url()
|
||||
*/
|
||||
function test_preview_url() {
|
||||
public function test_preview_url() {
|
||||
$this->assertSame( home_url( '/' ), $this->manager->get_preview_url() );
|
||||
$preview_url = home_url( '/foo/bar/baz/' );
|
||||
$this->manager->set_preview_url( $preview_url );
|
||||
@ -2964,7 +2964,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Manager::get_return_url()
|
||||
* @see WP_Customize_Manager::set_return_url()
|
||||
*/
|
||||
function test_return_url() {
|
||||
public function test_return_url() {
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'author' ) ) );
|
||||
$this->assertSame( home_url( '/' ), $this->manager->get_return_url() );
|
||||
|
||||
@ -2999,7 +2999,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 46686
|
||||
*/
|
||||
function test_return_url_with_deactivated_theme() {
|
||||
public function test_return_url_with_deactivated_theme() {
|
||||
$this->manager->set_return_url( admin_url( 'themes.php?page=mytheme_documentation' ) );
|
||||
$this->assertSame( admin_url( 'themes.php' ), $this->manager->get_return_url() );
|
||||
}
|
||||
@ -3010,7 +3010,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Manager::get_autofocus()
|
||||
* @see WP_Customize_Manager::set_autofocus()
|
||||
*/
|
||||
function test_autofocus() {
|
||||
public function test_autofocus() {
|
||||
$this->assertEmpty( $this->manager->get_autofocus() );
|
||||
|
||||
$this->manager->set_autofocus( array( 'unrecognized' => 'food' ) );
|
||||
@ -3038,7 +3038,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Manager::get_nonces()
|
||||
*/
|
||||
function test_nonces() {
|
||||
public function test_nonces() {
|
||||
$nonces = $this->manager->get_nonces();
|
||||
$this->assertIsArray( $nonces );
|
||||
$this->assertArrayHasKey( 'save', $nonces );
|
||||
@ -3057,7 +3057,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param WP_Customize_Manager $manager Manager.
|
||||
* @return array Nonces.
|
||||
*/
|
||||
function filter_customize_refresh_nonces( $nonces, $manager ) {
|
||||
public function filter_customize_refresh_nonces( $nonces, $manager ) {
|
||||
$this->assertInstanceOf( 'WP_Customize_Manager', $manager );
|
||||
$nonces['foo'] = wp_create_nonce( 'foo' );
|
||||
return $nonces;
|
||||
@ -3068,7 +3068,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Manager::customize_pane_settings()
|
||||
*/
|
||||
function test_customize_pane_settings() {
|
||||
public function test_customize_pane_settings() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$this->manager->register_controls();
|
||||
$this->manager->prepare_controls();
|
||||
@ -3119,7 +3119,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 38867
|
||||
* @covers WP_Customize_Manager::remove_frameless_preview_messenger_channel
|
||||
*/
|
||||
function test_remove_frameless_preview_messenger_channel() {
|
||||
public function test_remove_frameless_preview_messenger_channel() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$manager = new WP_Customize_Manager( array( 'messenger_channel' => null ) );
|
||||
ob_start();
|
||||
@ -3139,7 +3139,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Manager::customize_preview_settings()
|
||||
*/
|
||||
function test_customize_preview_settings() {
|
||||
public function test_customize_preview_settings() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$this->manager->register_controls();
|
||||
$this->manager->prepare_controls();
|
||||
@ -3171,7 +3171,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 33552
|
||||
*/
|
||||
function test_customize_loaded_components_filter() {
|
||||
public function test_customize_loaded_components_filter() {
|
||||
$manager = new WP_Customize_Manager();
|
||||
$this->assertInstanceOf( 'WP_Customize_Widgets', $manager->widgets );
|
||||
$this->assertInstanceOf( 'WP_Customize_Nav_Menus', $manager->nav_menus );
|
||||
@ -3203,7 +3203,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @return array Components.
|
||||
*/
|
||||
function return_array_containing_widgets( $components, $customize_manager ) {
|
||||
public function return_array_containing_widgets( $components, $customize_manager ) {
|
||||
$this->assertIsArray( $components );
|
||||
$this->assertContains( 'widgets', $components );
|
||||
$this->assertContains( 'nav_menus', $components );
|
||||
@ -3220,7 +3220,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @return array Components.
|
||||
*/
|
||||
function return_array_containing_nav_menus( $components, $customize_manager ) {
|
||||
public function return_array_containing_nav_menus( $components, $customize_manager ) {
|
||||
$this->assertIsArray( $components );
|
||||
$this->assertContains( 'widgets', $components );
|
||||
$this->assertContains( 'nav_menus', $components );
|
||||
@ -3233,7 +3233,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @ticket 30225
|
||||
* @ticket 34594
|
||||
*/
|
||||
function test_prepare_controls_stable_sorting() {
|
||||
public function test_prepare_controls_stable_sorting() {
|
||||
$manager = new WP_Customize_Manager();
|
||||
$manager->register_controls();
|
||||
$section_id = 'foo-section';
|
||||
@ -3273,7 +3273,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34596
|
||||
*/
|
||||
function test_add_section_return_instance() {
|
||||
public function test_add_section_return_instance() {
|
||||
$manager = new WP_Customize_Manager();
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
|
||||
@ -3307,7 +3307,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34596
|
||||
*/
|
||||
function test_add_setting_return_instance() {
|
||||
public function test_add_setting_return_instance() {
|
||||
$manager = new WP_Customize_Manager();
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
|
||||
@ -3328,7 +3328,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34597
|
||||
*/
|
||||
function test_add_setting_honoring_dynamic() {
|
||||
public function test_add_setting_honoring_dynamic() {
|
||||
$manager = new WP_Customize_Manager();
|
||||
|
||||
$setting_id = 'dynamic';
|
||||
@ -3353,7 +3353,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param string $id Setting ID.
|
||||
* @return string Setting class.
|
||||
*/
|
||||
function return_dynamic_customize_setting_class( $class, $id, $args ) {
|
||||
public function return_dynamic_customize_setting_class( $class, $id, $args ) {
|
||||
unset( $args );
|
||||
if ( 0 === strpos( $id, 'dynamic' ) ) {
|
||||
$class = 'Test_Dynamic_Customize_Setting';
|
||||
@ -3368,7 +3368,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @param string $id Setting ID.
|
||||
* @return string Setting args.
|
||||
*/
|
||||
function return_dynamic_customize_setting_args( $args, $id ) {
|
||||
public function return_dynamic_customize_setting_args( $args, $id ) {
|
||||
if ( 0 === strpos( $id, 'dynamic' ) ) {
|
||||
$args['custom'] = 'foo';
|
||||
}
|
||||
@ -3378,7 +3378,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34596
|
||||
*/
|
||||
function test_add_panel_return_instance() {
|
||||
public function test_add_panel_return_instance() {
|
||||
$manager = new WP_Customize_Manager();
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
|
||||
@ -3411,7 +3411,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34596
|
||||
*/
|
||||
function test_add_control_return_instance() {
|
||||
public function test_add_control_return_instance() {
|
||||
$manager = new WP_Customize_Manager();
|
||||
$section_id = 'foo-section';
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
@ -3459,7 +3459,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 31195
|
||||
*/
|
||||
function test_get_previewable_devices() {
|
||||
public function test_get_previewable_devices() {
|
||||
|
||||
// Setup the instance.
|
||||
$manager = new WP_Customize_Manager();
|
||||
@ -3496,7 +3496,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function filtered_device_list() {
|
||||
private function filtered_device_list() {
|
||||
return array(
|
||||
'custom-device' => array(
|
||||
'label' => __( 'Enter custom-device preview mode' ),
|
||||
@ -3512,14 +3512,14 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function filter_customize_previewable_devices( $devices ) {
|
||||
public function filter_customize_previewable_devices( $devices ) {
|
||||
return $this->filtered_device_list();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 37128
|
||||
*/
|
||||
function test_prepare_controls_wp_list_sort_controls() {
|
||||
public function test_prepare_controls_wp_list_sort_controls() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
|
||||
$controls = array(
|
||||
@ -3552,7 +3552,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 37128
|
||||
*/
|
||||
function test_prepare_controls_wp_list_sort_sections() {
|
||||
public function test_prepare_controls_wp_list_sort_sections() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
|
||||
$sections = array(
|
||||
@ -3581,7 +3581,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 37128
|
||||
*/
|
||||
function test_prepare_controls_wp_list_sort_panels() {
|
||||
public function test_prepare_controls_wp_list_sort_panels() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
|
||||
$panels = array(
|
||||
@ -3612,7 +3612,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 39125
|
||||
*/
|
||||
function test_sanitize_external_header_video_trim() {
|
||||
public function test_sanitize_external_header_video_trim() {
|
||||
$this->manager->register_controls();
|
||||
$setting = $this->manager->get_setting( 'external_header_video' );
|
||||
$video_url = 'https://www.youtube.com/watch?v=72xdCU__XCk';
|
||||
|
||||
@ -18,7 +18,7 @@ class Test_WP_Customize_Nav_Menu_Item_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';
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
@ -31,7 +31,7 @@ class Test_WP_Customize_Nav_Menu_Item_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();
|
||||
@ -43,7 +43,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
* @param object $menu_item Menu item.
|
||||
* @return object
|
||||
*/
|
||||
function filter_type_label( $menu_item ) {
|
||||
public function filter_type_label( $menu_item ) {
|
||||
if ( 'custom_type' === $menu_item->type ) {
|
||||
$menu_item->type_label = 'Custom Label';
|
||||
}
|
||||
@ -54,7 +54,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
/**
|
||||
* Test constants and statics.
|
||||
*/
|
||||
function test_constants() {
|
||||
public function test_constants() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$this->assertTrue( post_type_exists( WP_Customize_Nav_Menu_Item_Setting::POST_TYPE ) );
|
||||
}
|
||||
@ -64,7 +64,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::__construct()
|
||||
*/
|
||||
function test_construct() {
|
||||
public function test_construct() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, 'nav_menu_item[123]' );
|
||||
@ -108,7 +108,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
/**
|
||||
* Test empty constructor.
|
||||
*/
|
||||
function test_construct_empty_menus() {
|
||||
public function test_construct_empty_menus() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$_wp_customize = $this->wp_customize;
|
||||
unset( $_wp_customize->nav_menus );
|
||||
@ -128,7 +128,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::__construct()
|
||||
*/
|
||||
function test_construct_placeholder() {
|
||||
public function test_construct_placeholder() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$default = array(
|
||||
'title' => 'Lorem',
|
||||
@ -146,7 +146,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::value()
|
||||
*/
|
||||
function test_value_type_post_type() {
|
||||
public function test_value_type_post_type() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
|
||||
@ -197,7 +197,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::value()
|
||||
*/
|
||||
function test_value_type_post_type_without_label() {
|
||||
public function test_value_type_post_type_without_label() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$original_title = 'Hello World';
|
||||
@ -229,7 +229,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::value()
|
||||
*/
|
||||
function test_value_type_taxonomy() {
|
||||
public function test_value_type_taxonomy() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$tax_id = self::factory()->category->create( array( 'name' => 'Salutations' ) );
|
||||
@ -268,7 +268,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::value()
|
||||
*/
|
||||
function test_custom_type_label() {
|
||||
public function test_custom_type_label() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
add_filter( 'wp_setup_nav_menu_item', array( $this, 'filter_type_label' ) );
|
||||
|
||||
@ -300,7 +300,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::value()
|
||||
*/
|
||||
function test_value_nav_menu_term_id_returns_zero() {
|
||||
public function test_value_nav_menu_term_id_returns_zero() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = -123;
|
||||
@ -345,7 +345,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::preview()
|
||||
*/
|
||||
function test_preview_updated() {
|
||||
public function test_preview_updated() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$first_post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
|
||||
@ -400,7 +400,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::preview()
|
||||
*/
|
||||
function test_preview_inserted() {
|
||||
public function test_preview_inserted() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = wp_create_nav_menu( 'Primary' );
|
||||
@ -459,7 +459,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::preview()
|
||||
*/
|
||||
function test_preview_deleted() {
|
||||
public function test_preview_deleted() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = wp_create_nav_menu( 'Primary' );
|
||||
@ -499,7 +499,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::sanitize()
|
||||
*/
|
||||
function test_sanitize() {
|
||||
public function test_sanitize() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = wp_create_nav_menu( 'Primary' );
|
||||
@ -637,7 +637,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::update()
|
||||
*/
|
||||
function test_save_updated() {
|
||||
public function test_save_updated() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$first_post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
|
||||
@ -706,7 +706,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::update()
|
||||
*/
|
||||
function test_save_inserted() {
|
||||
public function test_save_inserted() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = wp_create_nav_menu( 'Primary' );
|
||||
@ -779,7 +779,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::update()
|
||||
*/
|
||||
function test_save_deleted() {
|
||||
public function test_save_deleted() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = wp_create_nav_menu( 'Primary' );
|
||||
@ -831,7 +831,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 33665
|
||||
*/
|
||||
function test_invalid_nav_menu_item() {
|
||||
public function test_invalid_nav_menu_item() {
|
||||
$menu_id = wp_create_nav_menu( 'Primary' );
|
||||
register_post_type(
|
||||
'poem',
|
||||
@ -888,7 +888,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item()
|
||||
*/
|
||||
function test_value_as_wp_post_nav_menu_item() {
|
||||
public function test_value_as_wp_post_nav_menu_item() {
|
||||
$post_id = self::factory()->post->create();
|
||||
|
||||
$setting = new WP_Customize_Nav_Menu_Item_Setting(
|
||||
@ -949,7 +949,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
* @ticket 38945
|
||||
* @covers WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item
|
||||
*/
|
||||
function test_value_as_wp_post_nav_menu_item_term_urls() {
|
||||
public function test_value_as_wp_post_nav_menu_item_term_urls() {
|
||||
$term_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) );
|
||||
register_post_type(
|
||||
'press_release',
|
||||
@ -1022,7 +1022,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
* @ticket 38945
|
||||
* @covers WP_Customize_Nav_Menu_Item_Setting::get_original_title
|
||||
*/
|
||||
function test_get_original_title() {
|
||||
public function test_get_original_title() {
|
||||
$menu_id = wp_create_nav_menu( 'Menu' );
|
||||
register_post_type(
|
||||
'press_release',
|
||||
@ -1217,7 +1217,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
* @ticket 38015
|
||||
* @see WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item()
|
||||
*/
|
||||
function test_value_as_wp_post_nav_menu_item_with_empty_title() {
|
||||
public function test_value_as_wp_post_nav_menu_item_with_empty_title() {
|
||||
$original_title = 'The Original Title';
|
||||
$post_id = self::factory()->post->create( array( 'post_title' => $original_title ) );
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ class Test_WP_Customize_Nav_Menu_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';
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
@ -32,7 +32,7 @@ class Test_WP_Customize_Nav_Menu_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();
|
||||
@ -43,14 +43,14 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_nav_menu_items_option() {
|
||||
private function get_nav_menu_items_option() {
|
||||
return get_option( 'nav_menu_options', array( 'auto_add' => array() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test constants and statics.
|
||||
*/
|
||||
function test_constants() {
|
||||
public function test_constants() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$this->assertTrue( taxonomy_exists( WP_Customize_Nav_Menu_Setting::TAXONOMY ) );
|
||||
}
|
||||
@ -60,7 +60,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Setting::__construct()
|
||||
*/
|
||||
function test_construct() {
|
||||
public function test_construct() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'nav_menu[123]' );
|
||||
@ -91,7 +91,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
/**
|
||||
* Test empty constructor.
|
||||
*/
|
||||
function test_construct_empty_menus() {
|
||||
public function test_construct_empty_menus() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$_wp_customize = $this->wp_customize;
|
||||
unset( $_wp_customize->nav_menus );
|
||||
@ -111,7 +111,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Setting::__construct()
|
||||
*/
|
||||
function test_construct_placeholder() {
|
||||
public function test_construct_placeholder() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$default = array(
|
||||
'name' => 'Lorem \\o/',
|
||||
@ -128,7 +128,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Setting::value()
|
||||
*/
|
||||
function test_value() {
|
||||
public function test_value() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_name = 'Test 123 \\o/';
|
||||
@ -168,7 +168,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Setting::preview()
|
||||
*/
|
||||
function test_preview_updated() {
|
||||
public function test_preview_updated() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = wp_update_nav_menu_object(
|
||||
@ -235,7 +235,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Setting::preview()
|
||||
*/
|
||||
function test_preview_inserted() {
|
||||
public function test_preview_inserted() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = -123;
|
||||
@ -280,7 +280,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Setting::preview()
|
||||
*/
|
||||
function test_preview_deleted() {
|
||||
public function test_preview_deleted() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = wp_update_nav_menu_object(
|
||||
@ -319,7 +319,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Setting::sanitize()
|
||||
*/
|
||||
function test_sanitize() {
|
||||
public function test_sanitize() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'nav_menu[123]' );
|
||||
|
||||
@ -350,7 +350,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Setting::update()
|
||||
*/
|
||||
function test_save_updated() {
|
||||
public function test_save_updated() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = wp_update_nav_menu_object(
|
||||
@ -415,7 +415,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Setting::update()
|
||||
*/
|
||||
function test_save_inserted() {
|
||||
public function test_save_inserted() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = -123;
|
||||
@ -464,7 +464,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Setting::update()
|
||||
*/
|
||||
function test_save_inserted_conflicted_name() {
|
||||
public function test_save_inserted_conflicted_name() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_name = 'Foo';
|
||||
@ -489,7 +489,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menu_Setting::update()
|
||||
*/
|
||||
function test_save_deleted() {
|
||||
public function test_save_deleted() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_name = 'Lorem Ipsum \\o/';
|
||||
|
||||
@ -19,7 +19,7 @@ class Test_WP_Customize_Nav_Menus 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';
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
@ -31,7 +31,7 @@ class Test_WP_Customize_Nav_Menus 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();
|
||||
@ -43,7 +43,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
* @param array $items Menu item types.
|
||||
* @return array Menu item types.
|
||||
*/
|
||||
function filter_item_types( $items ) {
|
||||
public function filter_item_types( $items ) {
|
||||
$items[] = array(
|
||||
'title' => 'Custom',
|
||||
'type_label' => 'Custom Type',
|
||||
@ -62,7 +62,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
* @param string $object The object name (e.g. category).
|
||||
* @return array Menu items.
|
||||
*/
|
||||
function filter_items( $items, $type, $object ) {
|
||||
public function filter_items( $items, $type, $object ) {
|
||||
$items[] = array(
|
||||
'id' => 'custom-1',
|
||||
'title' => 'Cool beans',
|
||||
@ -81,7 +81,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::__construct()
|
||||
*/
|
||||
function test_construct() {
|
||||
public function test_construct() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
$this->assertInstanceOf( 'WP_Customize_Manager', $menus->manager );
|
||||
@ -107,7 +107,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::load_available_items_query()
|
||||
*/
|
||||
function test_load_available_items_query_returns_wp_error() {
|
||||
public function test_load_available_items_query_returns_wp_error() {
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
// Invalid post type $obj_name.
|
||||
@ -126,7 +126,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::load_available_items_query()
|
||||
*/
|
||||
function test_load_available_items_query_maybe_returns_home() {
|
||||
public function test_load_available_items_query_maybe_returns_home() {
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
// Expected menu item array.
|
||||
@ -157,7 +157,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::load_available_items_query()
|
||||
*/
|
||||
function test_load_available_items_query_returns_post_item_with_page_number() {
|
||||
public function test_load_available_items_query_returns_post_item_with_page_number() {
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
// Create page.
|
||||
@ -187,7 +187,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::load_available_items_query()
|
||||
*/
|
||||
function test_load_available_items_query_returns_page_item() {
|
||||
public function test_load_available_items_query_returns_page_item() {
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
// Create page.
|
||||
@ -218,7 +218,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::load_available_items_query()
|
||||
*/
|
||||
function test_load_available_items_query_returns_post_item() {
|
||||
public function test_load_available_items_query_returns_post_item() {
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
// Create post.
|
||||
@ -244,7 +244,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::load_available_items_query()
|
||||
*/
|
||||
function test_load_available_items_query_returns_term_item() {
|
||||
public function test_load_available_items_query_returns_term_item() {
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
// Create term.
|
||||
@ -270,7 +270,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::load_available_items_query()
|
||||
*/
|
||||
function test_load_available_items_query_returns_custom_item() {
|
||||
public function test_load_available_items_query_returns_custom_item() {
|
||||
add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) );
|
||||
add_filter( 'customize_nav_menu_available_items', array( $this, 'filter_items' ), 10, 4 );
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
@ -295,7 +295,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::search_available_items_query()
|
||||
*/
|
||||
function test_search_available_items_query() {
|
||||
public function test_search_available_items_query() {
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
@ -464,7 +464,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
* }
|
||||
* @return array Items.
|
||||
*/
|
||||
function filter_search( $items, $args ) {
|
||||
public function filter_search( $items, $args ) {
|
||||
$this->assertIsArray( $items );
|
||||
$this->assertIsArray( $args );
|
||||
$this->assertArrayHasKey( 's', $args );
|
||||
@ -492,7 +492,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::enqueue_scripts()
|
||||
*/
|
||||
function test_enqueue_scripts() {
|
||||
public function test_enqueue_scripts() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
$menus->enqueue_scripts();
|
||||
@ -507,7 +507,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::filter_dynamic_setting_args()
|
||||
*/
|
||||
function test_filter_dynamic_setting_args() {
|
||||
public function test_filter_dynamic_setting_args() {
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
$expected = array( 'type' => 'nav_menu_item' );
|
||||
@ -524,7 +524,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::filter_dynamic_setting_class()
|
||||
*/
|
||||
function test_filter_dynamic_setting_class() {
|
||||
public function test_filter_dynamic_setting_class() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
@ -542,7 +542,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::customize_register()
|
||||
*/
|
||||
function test_customize_register() {
|
||||
public function test_customize_register() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$menu_id = wp_create_nav_menu( 'Primary' );
|
||||
$post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
|
||||
@ -574,7 +574,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::intval_base10()
|
||||
*/
|
||||
function test_intval_base10() {
|
||||
public function test_intval_base10() {
|
||||
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
@ -593,7 +593,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::available_item_types()
|
||||
*/
|
||||
function test_available_item_types() {
|
||||
public function test_available_item_types() {
|
||||
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
@ -729,7 +729,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::print_templates()
|
||||
*/
|
||||
function test_print_templates() {
|
||||
public function test_print_templates() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
@ -753,7 +753,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::available_items_template()
|
||||
*/
|
||||
function test_available_items_template() {
|
||||
public function test_available_items_template() {
|
||||
add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) );
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
@ -800,7 +800,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::customize_dynamic_partial_args()
|
||||
*/
|
||||
function test_customize_dynamic_partial_args() {
|
||||
public function test_customize_dynamic_partial_args() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$args = apply_filters( 'customize_dynamic_partial_args', false, 'nav_menu_instance[68b329da9893e34099c7d8ad5cb9c940]' );
|
||||
@ -822,7 +822,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::customize_preview_init()
|
||||
*/
|
||||
function test_customize_preview_init() {
|
||||
public function test_customize_preview_init() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
@ -837,7 +837,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers WP_Customize_Nav_Menus::make_auto_draft_status_previewable
|
||||
*/
|
||||
function test_make_auto_draft_status_previewable() {
|
||||
public function test_make_auto_draft_status_previewable() {
|
||||
global $wp_post_statuses;
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
$menus->make_auto_draft_status_previewable();
|
||||
@ -849,7 +849,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers WP_Customize_Nav_Menus::sanitize_nav_menus_created_posts
|
||||
*/
|
||||
function test_sanitize_nav_menus_created_posts() {
|
||||
public function test_sanitize_nav_menus_created_posts() {
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
$contributor_user_id = $this->factory()->user->create( array( 'role' => 'contributor' ) );
|
||||
$author_user_id = $this->factory()->user->create( array( 'role' => 'author' ) );
|
||||
@ -923,7 +923,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers WP_Customize_Nav_Menus::save_nav_menus_created_posts
|
||||
*/
|
||||
function test_save_nav_menus_created_posts() {
|
||||
public function test_save_nav_menus_created_posts() {
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
@ -1031,7 +1031,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::filter_wp_nav_menu_args()
|
||||
*/
|
||||
function test_filter_wp_nav_menu_args() {
|
||||
public function test_filter_wp_nav_menu_args() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$menus = $this->wp_customize->nav_menus;
|
||||
$menu_id = wp_create_nav_menu( 'Foo' );
|
||||
@ -1117,7 +1117,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
* @covers WP_Customize_Nav_Menus::filter_wp_nav_menu
|
||||
* @covers WP_Customize_Nav_Menus::filter_wp_nav_menu_args
|
||||
*/
|
||||
function test_filter_wp_nav_menu() {
|
||||
public function test_filter_wp_nav_menu() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
@ -1158,7 +1158,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::customize_preview_enqueue_deps()
|
||||
*/
|
||||
function test_customize_preview_enqueue_deps() {
|
||||
public function test_customize_preview_enqueue_deps() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
|
||||
@ -1172,7 +1172,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::export_preview_data()
|
||||
*/
|
||||
function test_export_preview_data() {
|
||||
public function test_export_preview_data() {
|
||||
ob_start();
|
||||
$this->wp_customize->nav_menus->export_preview_data();
|
||||
$html = ob_get_clean();
|
||||
@ -1186,7 +1186,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Nav_Menus::render_nav_menu_partial()
|
||||
*/
|
||||
function test_render_nav_menu_partial() {
|
||||
public function test_render_nav_menu_partial() {
|
||||
$this->wp_customize->nav_menus->customize_preview_init();
|
||||
|
||||
$menu = wp_create_nav_menu( 'Foo' );
|
||||
|
||||
@ -12,7 +12,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
*/
|
||||
protected $manager;
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
|
||||
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
|
||||
@ -20,7 +20,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
$this->undefined = new stdClass();
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$this->manager = null;
|
||||
unset( $GLOBALS['wp_customize'] );
|
||||
parent::tear_down();
|
||||
@ -29,7 +29,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Panel::__construct()
|
||||
*/
|
||||
function test_construct_default_args() {
|
||||
public function test_construct_default_args() {
|
||||
$panel = new WP_Customize_Panel( $this->manager, 'foo' );
|
||||
$this->assertIsInt( $panel->instance_number );
|
||||
$this->assertSame( $this->manager, $panel->manager );
|
||||
@ -47,7 +47,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Panel::__construct()
|
||||
*/
|
||||
function test_construct_custom_args() {
|
||||
public function test_construct_custom_args() {
|
||||
$args = array(
|
||||
'priority' => 200,
|
||||
'capability' => 'edit_posts',
|
||||
@ -67,7 +67,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Panel::__construct()
|
||||
*/
|
||||
function test_construct_custom_type() {
|
||||
public function test_construct_custom_type() {
|
||||
$panel = new Custom_Panel_Test( $this->manager, 'foo' );
|
||||
$this->assertSame( 'titleless', $panel->type );
|
||||
}
|
||||
@ -76,7 +76,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Panel::active()
|
||||
* @see WP_Customize_Panel::active_callback()
|
||||
*/
|
||||
function test_active() {
|
||||
public function test_active() {
|
||||
$panel = new WP_Customize_Panel( $this->manager, 'foo' );
|
||||
$this->assertTrue( $panel->active() );
|
||||
|
||||
@ -97,7 +97,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
* @param WP_Customize_Panel $panel
|
||||
* @return bool
|
||||
*/
|
||||
function filter_active_test( $active, $panel ) {
|
||||
public function filter_active_test( $active, $panel ) {
|
||||
$this->assertFalse( $active );
|
||||
$this->assertInstanceOf( 'WP_Customize_Panel', $panel );
|
||||
$active = true;
|
||||
@ -107,7 +107,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Panel::json()
|
||||
*/
|
||||
function test_json() {
|
||||
public function test_json() {
|
||||
$args = array(
|
||||
'priority' => 200,
|
||||
'capability' => 'edit_posts',
|
||||
@ -131,7 +131,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Panel::check_capabilities()
|
||||
*/
|
||||
function test_check_capabilities() {
|
||||
public function test_check_capabilities() {
|
||||
$user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
|
||||
wp_set_current_user( $user_id );
|
||||
|
||||
@ -149,7 +149,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Panel::get_content()
|
||||
*/
|
||||
function test_get_content() {
|
||||
public function test_get_content() {
|
||||
$panel = new WP_Customize_Panel( $this->manager, 'foo' );
|
||||
$this->assertEmpty( $panel->get_content() );
|
||||
}
|
||||
@ -157,7 +157,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Panel::maybe_render()
|
||||
*/
|
||||
function test_maybe_render() {
|
||||
public function test_maybe_render() {
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$panel = new WP_Customize_Panel( $this->manager, 'bar' );
|
||||
$customize_render_panel_count = did_action( 'customize_render_panel' );
|
||||
@ -175,14 +175,14 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Panel::maybe_render()
|
||||
* @param WP_Customize_Panel $panel
|
||||
*/
|
||||
function action_customize_render_panel_test( $panel ) {
|
||||
public function action_customize_render_panel_test( $panel ) {
|
||||
$this->assertInstanceOf( 'WP_Customize_Panel', $panel );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see WP_Customize_Panel::print_template()
|
||||
*/
|
||||
function test_print_templates_standard() {
|
||||
public function test_print_templates_standard() {
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
|
||||
$panel = new WP_Customize_Panel( $this->manager, 'baz' );
|
||||
@ -200,7 +200,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Panel::print_template()
|
||||
*/
|
||||
function test_print_templates_custom() {
|
||||
public function test_print_templates_custom() {
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
|
||||
$panel = new Custom_Panel_Test( $this->manager, 'baz' );
|
||||
|
||||
@ -29,7 +29,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
/**
|
||||
* Set up.
|
||||
*/
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
|
||||
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
|
||||
@ -44,7 +44,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Partial::__construct()
|
||||
*/
|
||||
function test_construct_default_args() {
|
||||
public function test_construct_default_args() {
|
||||
$partial_id = 'blogname';
|
||||
$partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id );
|
||||
$this->assertSame( $partial_id, $partial->id );
|
||||
@ -64,7 +64,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
* @param WP_Customize_Partial $partial Partial.
|
||||
* @return string|false Content or false if error.
|
||||
*/
|
||||
function render_post_content_partial( $partial ) {
|
||||
public function render_post_content_partial( $partial ) {
|
||||
$id_data = $partial->id_data();
|
||||
$post_id = (int) $id_data['keys'][0];
|
||||
if ( empty( $post_id ) ) {
|
||||
@ -82,7 +82,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Partial::__construct()
|
||||
*/
|
||||
function test_construct_non_default_args() {
|
||||
public function test_construct_non_default_args() {
|
||||
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
@ -129,7 +129,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Partial::id_data()
|
||||
*/
|
||||
function test_id_data() {
|
||||
public function test_id_data() {
|
||||
$partial = new WP_Customize_Partial( $this->selective_refresh, 'foo' );
|
||||
$id_data = $partial->id_data();
|
||||
$this->assertSame( 'foo', $id_data['base'] );
|
||||
@ -163,7 +163,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
* @param array $container_context Data.
|
||||
* @return string|false Content.
|
||||
*/
|
||||
function filter_customize_partial_render( $rendered, $partial, $container_context ) {
|
||||
public function filter_customize_partial_render( $rendered, $partial, $container_context ) {
|
||||
$this->assertTrue( false === $rendered || is_string( $rendered ) );
|
||||
$this->assertInstanceOf( 'WP_Customize_Partial', $partial );
|
||||
$this->assertIsArray( $container_context );
|
||||
@ -179,7 +179,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
* @param array $container_context Data.
|
||||
* @return string|false Content.
|
||||
*/
|
||||
function filter_customize_partial_render_with_id( $rendered, $partial, $container_context ) {
|
||||
public function filter_customize_partial_render_with_id( $rendered, $partial, $container_context ) {
|
||||
$this->assertSame( sprintf( 'customize_partial_render_%s', $partial->id ), current_filter() );
|
||||
$this->assertTrue( false === $rendered || is_string( $rendered ) );
|
||||
$this->assertInstanceOf( 'WP_Customize_Partial', $partial );
|
||||
@ -193,7 +193,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*
|
||||
* @return string Content.
|
||||
*/
|
||||
function render_echo_and_return() {
|
||||
public function render_echo_and_return() {
|
||||
echo 'foo';
|
||||
return 'bar';
|
||||
}
|
||||
@ -201,7 +201,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
/**
|
||||
* Echo render_callback().
|
||||
*/
|
||||
function render_echo() {
|
||||
public function render_echo() {
|
||||
echo 'foo';
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*
|
||||
* @return string Content.
|
||||
*/
|
||||
function render_return() {
|
||||
public function render_return() {
|
||||
return 'bar';
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Partial::render()
|
||||
*/
|
||||
function test_render_with_bad_callback_should_give_preference_to_return_value() {
|
||||
public function test_render_with_bad_callback_should_give_preference_to_return_value() {
|
||||
$partial = new WP_Customize_Partial(
|
||||
$this->selective_refresh,
|
||||
'foo',
|
||||
@ -236,7 +236,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Partial::render()
|
||||
*/
|
||||
function test_render_echo_callback() {
|
||||
public function test_render_echo_callback() {
|
||||
$partial = new WP_Customize_Partial(
|
||||
$this->selective_refresh,
|
||||
'foo',
|
||||
@ -259,7 +259,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Partial::render()
|
||||
*/
|
||||
function test_render_return_callback() {
|
||||
public function test_render_return_callback() {
|
||||
$partial = new WP_Customize_Partial(
|
||||
$this->selective_refresh,
|
||||
'foo',
|
||||
@ -282,7 +282,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Partial::render_callback()
|
||||
*/
|
||||
function test_render_callback_default() {
|
||||
public function test_render_callback_default() {
|
||||
$partial = new WP_Customize_Partial( $this->selective_refresh, 'foo' );
|
||||
$this->assertFalse( $partial->render_callback( $partial, array() ) );
|
||||
$this->assertFalse( call_user_func( $partial->render_callback, $partial, array() ) );
|
||||
@ -293,7 +293,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Partial::json()
|
||||
*/
|
||||
function test_json() {
|
||||
public function test_json() {
|
||||
$post_id = 123;
|
||||
$partial_id = sprintf( 'post_content[%d]', $post_id );
|
||||
$args = array(
|
||||
@ -321,7 +321,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Partial::check_capabilities()
|
||||
*/
|
||||
function test_check_capabilities() {
|
||||
public function test_check_capabilities() {
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$partial = new WP_Customize_Partial(
|
||||
@ -390,7 +390,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
/**
|
||||
* Tear down.
|
||||
*/
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$this->wp_customize = null;
|
||||
unset( $GLOBALS['wp_customize'] );
|
||||
parent::tear_down();
|
||||
|
||||
@ -19,7 +19,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
*/
|
||||
protected $manager;
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
|
||||
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
|
||||
@ -27,7 +27,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
$this->undefined = new stdClass();
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$this->manager = null;
|
||||
unset( $GLOBALS['wp_customize'] );
|
||||
parent::tear_down();
|
||||
@ -36,7 +36,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Section::__construct()
|
||||
*/
|
||||
function test_construct_default_args() {
|
||||
public function test_construct_default_args() {
|
||||
$section = new WP_Customize_Section( $this->manager, 'foo' );
|
||||
$this->assertIsInt( $section->instance_number );
|
||||
$this->assertSame( $this->manager, $section->manager );
|
||||
@ -54,7 +54,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Section::__construct()
|
||||
*/
|
||||
function test_construct_custom_args() {
|
||||
public function test_construct_custom_args() {
|
||||
$args = array(
|
||||
'priority' => 200,
|
||||
'capability' => 'edit_posts',
|
||||
@ -77,7 +77,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Section::__construct()
|
||||
*/
|
||||
function test_construct_custom_type() {
|
||||
public function test_construct_custom_type() {
|
||||
$section = new Custom_Section_Test( $this->manager, 'foo' );
|
||||
$this->assertSame( 'titleless', $section->type );
|
||||
}
|
||||
@ -86,7 +86,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Section::active()
|
||||
* @see WP_Customize_Section::active_callback()
|
||||
*/
|
||||
function test_active() {
|
||||
public function test_active() {
|
||||
$section = new WP_Customize_Section( $this->manager, 'foo' );
|
||||
$this->assertTrue( $section->active() );
|
||||
|
||||
@ -107,7 +107,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
* @param WP_Customize_Section $section
|
||||
* @return bool
|
||||
*/
|
||||
function filter_active_test( $active, $section ) {
|
||||
public function filter_active_test( $active, $section ) {
|
||||
$this->assertFalse( $active );
|
||||
$this->assertInstanceOf( 'WP_Customize_Section', $section );
|
||||
$active = true;
|
||||
@ -117,7 +117,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Section::json()
|
||||
*/
|
||||
function test_json() {
|
||||
public function test_json() {
|
||||
$args = array(
|
||||
'priority' => 200,
|
||||
'capability' => 'edit_posts',
|
||||
@ -145,7 +145,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Section::check_capabilities()
|
||||
*/
|
||||
function test_check_capabilities() {
|
||||
public function test_check_capabilities() {
|
||||
wp_set_current_user( self::$admin_id );
|
||||
|
||||
$section = new WP_Customize_Section( $this->manager, 'foo' );
|
||||
@ -162,7 +162,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Section::get_content()
|
||||
*/
|
||||
function test_get_content() {
|
||||
public function test_get_content() {
|
||||
$section = new WP_Customize_Section( $this->manager, 'foo' );
|
||||
$this->assertEmpty( $section->get_content() );
|
||||
}
|
||||
@ -170,7 +170,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Section::maybe_render()
|
||||
*/
|
||||
function test_maybe_render() {
|
||||
public function test_maybe_render() {
|
||||
wp_set_current_user( self::$admin_id );
|
||||
$section = new WP_Customize_Section( $this->manager, 'bar' );
|
||||
$customize_render_section_count = did_action( 'customize_render_section' );
|
||||
@ -188,14 +188,14 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Section::maybe_render()
|
||||
* @param WP_Customize_Section $section
|
||||
*/
|
||||
function action_customize_render_section_test( $section ) {
|
||||
public function action_customize_render_section_test( $section ) {
|
||||
$this->assertInstanceOf( 'WP_Customize_Section', $section );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see WP_Customize_Section::print_template()
|
||||
*/
|
||||
function test_print_templates_standard() {
|
||||
public function test_print_templates_standard() {
|
||||
wp_set_current_user( self::$admin_id );
|
||||
|
||||
$section = new WP_Customize_Section( $this->manager, 'baz' );
|
||||
@ -210,7 +210,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Section::print_template()
|
||||
*/
|
||||
function test_print_templates_custom() {
|
||||
public function test_print_templates_custom() {
|
||||
wp_set_current_user( self::$admin_id );
|
||||
|
||||
$section = new Custom_Section_Test( $this->manager, 'baz' );
|
||||
|
||||
@ -34,7 +34,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
/**
|
||||
* Set up the test fixture.
|
||||
*/
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
// Define wp_doing_ajax so that wp_die() will be used instead of die().
|
||||
@ -52,7 +52,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
/**
|
||||
* Do Customizer boot actions.
|
||||
*/
|
||||
function do_customize_boot_actions() {
|
||||
private function do_customize_boot_actions() {
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
do_action( 'setup_theme' );
|
||||
do_action( 'after_setup_theme' );
|
||||
@ -67,7 +67,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::handle_render_partials_request()
|
||||
*/
|
||||
function test_handle_render_partials_request_for_unauthenticated_user() {
|
||||
public function test_handle_render_partials_request_for_unauthenticated_user() {
|
||||
$_POST[ WP_Customize_Selective_Refresh::RENDER_QUERY_VAR ] = '1';
|
||||
|
||||
// Check current_user_cannot_customize.
|
||||
@ -123,7 +123,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
/**
|
||||
* Set the current user to be an admin, add the preview nonce, and set the query var.
|
||||
*/
|
||||
function setup_valid_render_partials_request_environment() {
|
||||
private function setup_valid_render_partials_request_environment() {
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$_REQUEST['nonce'] = wp_create_nonce( 'preview-customize_' . $this->wp_customize->theme()->get_stylesheet() );
|
||||
$_POST[ WP_Customize_Selective_Refresh::RENDER_QUERY_VAR ] = '1';
|
||||
@ -135,7 +135,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::handle_render_partials_request()
|
||||
*/
|
||||
function test_handle_render_partials_request_for_unrecognized_partial() {
|
||||
public function test_handle_render_partials_request_for_unrecognized_partial() {
|
||||
$this->setup_valid_render_partials_request_environment();
|
||||
$context_data = array();
|
||||
$placements = array( $context_data );
|
||||
@ -172,7 +172,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::handle_render_partials_request()
|
||||
*/
|
||||
function test_handle_render_partials_request_for_non_rendering_partial() {
|
||||
public function test_handle_render_partials_request_for_non_rendering_partial() {
|
||||
$this->setup_valid_render_partials_request_environment();
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$this->wp_customize->add_setting( 'home' );
|
||||
@ -211,7 +211,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::handle_render_partials_request()
|
||||
*/
|
||||
function test_handle_rendering_disallowed_partial() {
|
||||
public function test_handle_rendering_disallowed_partial() {
|
||||
$this->setup_valid_render_partials_request_environment();
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$this->wp_customize->add_setting(
|
||||
@ -247,7 +247,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::handle_render_partials_request()
|
||||
*/
|
||||
function test_handle_rendering_partial_with_missing_settings() {
|
||||
public function test_handle_rendering_partial_with_missing_settings() {
|
||||
$this->setup_valid_render_partials_request_environment();
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$this->wp_customize->selective_refresh->add_partial( 'bar', array( 'settings' => 'bar' ) );
|
||||
@ -279,7 +279,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
* @param array $context Context data.
|
||||
* @return string
|
||||
*/
|
||||
function render_callback_blogname( $partial, $context ) {
|
||||
public function render_callback_blogname( $partial, $context ) {
|
||||
$this->assertIsArray( $context );
|
||||
$this->assertInstanceOf( 'WP_Customize_Partial', $partial );
|
||||
return get_bloginfo( 'name', 'display' );
|
||||
@ -292,7 +292,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
* @param array $context Context data.
|
||||
* @return string
|
||||
*/
|
||||
function render_callback_blogdescription( $partial, $context ) {
|
||||
public function render_callback_blogdescription( $partial, $context ) {
|
||||
$this->assertIsArray( $context );
|
||||
$this->assertInstanceOf( 'WP_Customize_Partial', $partial );
|
||||
$x = get_bloginfo( 'description', 'display' );
|
||||
@ -304,7 +304,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::handle_render_partials_request()
|
||||
*/
|
||||
function test_handle_render_partials_request_with_single_valid_placement() {
|
||||
public function test_handle_render_partials_request_with_single_valid_placement() {
|
||||
$this->setup_valid_render_partials_request_environment();
|
||||
|
||||
$this->wp_customize->selective_refresh->add_partial(
|
||||
@ -353,7 +353,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
*
|
||||
* @return array|false Args.
|
||||
*/
|
||||
function filter_customize_dynamic_partial_args( $partial_args, $partial_id ) {
|
||||
public function filter_customize_dynamic_partial_args( $partial_args, $partial_id ) {
|
||||
if ( 'test_dynamic_blogname' === $partial_id ) {
|
||||
$partial_args = array(
|
||||
'settings' => array( 'blogname' ),
|
||||
@ -373,7 +373,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
* the placements' context data.
|
||||
* @return array Response.
|
||||
*/
|
||||
function filter_customize_render_partials_response( $response, $component, $partial_placements ) {
|
||||
public function filter_customize_render_partials_response( $response, $component, $partial_placements ) {
|
||||
$this->assertIsArray( $response );
|
||||
$this->assertInstanceOf( 'WP_Customize_Selective_Refresh', $component );
|
||||
if ( isset( $this->expected_partial_ids ) ) {
|
||||
@ -395,7 +395,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
* @param WP_Customize_Selective_Refresh $component Selective refresh component.
|
||||
* @param array $partial_placements Partial IDs.
|
||||
*/
|
||||
function handle_action_customize_render_partials_after( $component, $partial_placements ) {
|
||||
public function handle_action_customize_render_partials_after( $component, $partial_placements ) {
|
||||
$this->assertInstanceOf( 'WP_Customize_Selective_Refresh', $component );
|
||||
if ( isset( $this->expected_partial_ids ) ) {
|
||||
$this->assertSameSets( $this->expected_partial_ids, array_keys( $partial_placements ) );
|
||||
@ -408,7 +408,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
* @param WP_Customize_Selective_Refresh $component Selective refresh component.
|
||||
* @param array $partial_placements Partial IDs.
|
||||
*/
|
||||
function handle_action_customize_render_partials_before( $component, $partial_placements ) {
|
||||
public function handle_action_customize_render_partials_before( $component, $partial_placements ) {
|
||||
$this->assertInstanceOf( 'WP_Customize_Selective_Refresh', $component );
|
||||
if ( isset( $this->expected_partial_ids ) ) {
|
||||
$this->assertSameSets( $this->expected_partial_ids, array_keys( $partial_placements ) );
|
||||
@ -420,7 +420,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::handle_render_partials_request()
|
||||
*/
|
||||
function test_handle_render_partials_request_for_dynamic_partial() {
|
||||
public function test_handle_render_partials_request_for_dynamic_partial() {
|
||||
$this->setup_valid_render_partials_request_environment();
|
||||
add_filter( 'customize_dynamic_partial_args', array( $this, 'filter_customize_dynamic_partial_args' ), 10, 2 );
|
||||
|
||||
@ -458,7 +458,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::handle_render_partials_request()
|
||||
*/
|
||||
function test_handle_render_partials_request_for_multiple_partials_placements() {
|
||||
public function test_handle_render_partials_request_for_multiple_partials_placements() {
|
||||
$this->setup_valid_render_partials_request_environment();
|
||||
|
||||
$this->wp_customize->selective_refresh->add_partial(
|
||||
@ -509,7 +509,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
/**
|
||||
* Tear down.
|
||||
*/
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$this->expected_partial_ids = null;
|
||||
$this->wp_customize = null;
|
||||
unset( $GLOBALS['wp_customize'] );
|
||||
|
||||
@ -29,7 +29,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
/**
|
||||
* Set up the test fixture.
|
||||
*/
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
|
||||
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
|
||||
@ -44,7 +44,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::__construct()
|
||||
*/
|
||||
function test_construct() {
|
||||
public function test_construct() {
|
||||
$this->assertSame( $this->selective_refresh, $this->wp_customize->selective_refresh );
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::register_scripts()
|
||||
*/
|
||||
function test_register_scripts() {
|
||||
public function test_register_scripts() {
|
||||
$scripts = new WP_Scripts();
|
||||
$handles = array(
|
||||
'customize-selective-refresh',
|
||||
@ -70,7 +70,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::partials()
|
||||
*/
|
||||
function test_partials() {
|
||||
public function test_partials() {
|
||||
$this->assertIsArray( $this->selective_refresh->partials() );
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Selective_Refresh::add_partial()
|
||||
* @see WP_Customize_Selective_Refresh::remove_partial()
|
||||
*/
|
||||
function test_crud_partial() {
|
||||
public function test_crud_partial() {
|
||||
$partial = $this->selective_refresh->add_partial( 'foo' );
|
||||
$this->assertSame( $this->selective_refresh, $partial->component );
|
||||
$this->assertInstanceOf( 'WP_Customize_Partial', $partial );
|
||||
@ -110,7 +110,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::init_preview()
|
||||
*/
|
||||
function test_init_preview() {
|
||||
public function test_init_preview() {
|
||||
$this->selective_refresh->init_preview();
|
||||
$this->assertSame( 10, has_action( 'template_redirect', array( $this->selective_refresh, 'handle_render_partials_request' ) ) );
|
||||
$this->assertSame( 10, has_action( 'wp_enqueue_scripts', array( $this->selective_refresh, 'enqueue_preview_scripts' ) ) );
|
||||
@ -121,7 +121,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::enqueue_preview_scripts()
|
||||
*/
|
||||
function test_enqueue_preview_scripts() {
|
||||
public function test_enqueue_preview_scripts() {
|
||||
$scripts = wp_scripts();
|
||||
$this->assertNotContains( 'customize-selective-refresh', $scripts->queue );
|
||||
$this->selective_refresh->enqueue_preview_scripts();
|
||||
@ -134,7 +134,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::export_preview_data()
|
||||
*/
|
||||
function test_export_preview_data() {
|
||||
public function test_export_preview_data() {
|
||||
$user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
|
||||
wp_set_current_user( $user_id );
|
||||
$user = new WP_User( $user_id );
|
||||
@ -178,7 +178,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::add_dynamic_partials()
|
||||
*/
|
||||
function test_add_dynamic_partials() {
|
||||
public function test_add_dynamic_partials() {
|
||||
$partial_ids = array( 'recognized', 'recognized-class', 'unrecognized', 'already-added' );
|
||||
|
||||
$partials = $this->selective_refresh->add_dynamic_partials( $partial_ids );
|
||||
@ -206,7 +206,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
* @param string $partial_id ID for dynamic partial.
|
||||
* @return false|array Dynamic partial args.
|
||||
*/
|
||||
function filter_customize_dynamic_partial_args( $partial_args, $partial_id ) {
|
||||
public function filter_customize_dynamic_partial_args( $partial_args, $partial_id ) {
|
||||
$this->assertTrue( false === $partial_args || is_array( $partial_args ) );
|
||||
$this->assertIsString( $partial_id );
|
||||
|
||||
@ -229,7 +229,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
* @param array $partial_args The arguments to the WP_Customize_Partial constructor.
|
||||
* @return string
|
||||
*/
|
||||
function filter_customize_dynamic_partial_class( $partial_class, $partial_id, $partial_args ) {
|
||||
public function filter_customize_dynamic_partial_class( $partial_class, $partial_id, $partial_args ) {
|
||||
$this->assertIsArray( $partial_args );
|
||||
$this->assertIsString( $partial_id );
|
||||
$this->assertIsString( $partial_class );
|
||||
@ -246,7 +246,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Selective_Refresh::is_render_partials_request()
|
||||
*/
|
||||
function test_is_render_partials_request() {
|
||||
public function test_is_render_partials_request() {
|
||||
$this->assertFalse( $this->selective_refresh->is_render_partials_request() );
|
||||
$_POST[ WP_Customize_Selective_Refresh::RENDER_QUERY_VAR ] = '1';
|
||||
$this->assertTrue( $this->selective_refresh->is_render_partials_request() );
|
||||
@ -255,7 +255,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
/**
|
||||
* Tear down.
|
||||
*/
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$this->wp_customize = null;
|
||||
unset( $GLOBALS['wp_customize'] );
|
||||
unset( $GLOBALS['wp_scripts'] );
|
||||
|
||||
@ -17,7 +17,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
*/
|
||||
public $undefined;
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
|
||||
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
|
||||
@ -25,13 +25,13 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
$this->undefined = new stdClass();
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$this->manager = null;
|
||||
unset( $GLOBALS['wp_customize'] );
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
function test_constructor_without_args() {
|
||||
public function test_constructor_without_args() {
|
||||
$setting = new WP_Customize_Setting( $this->manager, 'foo' );
|
||||
$this->assertSame( $this->manager, $setting->manager );
|
||||
$this->assertSame( 'foo', $setting->id );
|
||||
@ -84,11 +84,11 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
* @param mixed $value The setting value.
|
||||
* @param WP_Customize_Setting $setting The setting object.
|
||||
*/
|
||||
function sanitize_js_callback_base64_for_testing( $value, $setting ) {
|
||||
public function sanitize_js_callback_base64_for_testing( $value, $setting ) {
|
||||
return base64_encode( $value );
|
||||
}
|
||||
|
||||
function test_constructor_with_args() {
|
||||
public function test_constructor_with_args() {
|
||||
$args = array(
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_posts',
|
||||
@ -136,7 +136,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Setting::value()
|
||||
*/
|
||||
function test_preview_standard_types_non_multidimensional() {
|
||||
public function test_preview_standard_types_non_multidimensional() {
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
|
||||
|
||||
@ -215,7 +215,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Setting::preview()
|
||||
* @see WP_Customize_Setting::value()
|
||||
*/
|
||||
function test_preview_standard_types_multidimensional() {
|
||||
public function test_preview_standard_types_multidimensional() {
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
|
||||
|
||||
@ -316,7 +316,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
*/
|
||||
protected $custom_type_data_previewed;
|
||||
|
||||
function custom_type_getter( $name, $default = null ) {
|
||||
private function custom_type_getter( $name, $default = null ) {
|
||||
if ( did_action( "customize_preview_{$name}" ) && array_key_exists( $name, $this->custom_type_data_previewed ) ) {
|
||||
$value = $this->custom_type_data_previewed[ $name ];
|
||||
} elseif ( array_key_exists( $name, $this->custom_type_data_saved ) ) {
|
||||
@ -327,7 +327,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
return $value;
|
||||
}
|
||||
|
||||
function custom_type_setter( $name, $value ) {
|
||||
private function custom_type_setter( $name, $value ) {
|
||||
$this->custom_type_data_saved[ $name ] = $value;
|
||||
}
|
||||
|
||||
@ -339,7 +339,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
function custom_type_value_filter( $default, $setting = null ) {
|
||||
public function custom_type_value_filter( $default, $setting = null ) {
|
||||
$name = preg_replace( '/^customize_value_/', '', current_filter() );
|
||||
$this->assertInstanceOf( 'WP_Customize_Setting', $setting );
|
||||
$id_data = $setting->id_data();
|
||||
@ -350,7 +350,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
/**
|
||||
* @param WP_Customize_Setting $setting
|
||||
*/
|
||||
function custom_type_preview( $setting ) {
|
||||
public function custom_type_preview( $setting ) {
|
||||
$previewed_value = $setting->post_value( $this->undefined );
|
||||
if ( $this->undefined !== $previewed_value ) {
|
||||
$this->custom_type_data_previewed[ $setting->id ] = $previewed_value;
|
||||
@ -361,7 +361,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Setting::preview()
|
||||
*/
|
||||
function test_preview_custom_type() {
|
||||
public function test_preview_custom_type() {
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$type = 'custom_type';
|
||||
$post_data_overrides = array(
|
||||
@ -473,7 +473,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 30988
|
||||
*/
|
||||
function test_non_posted_setting_applying_default_value_in_preview() {
|
||||
public function test_non_posted_setting_applying_default_value_in_preview() {
|
||||
$type = 'option';
|
||||
$name = 'unset_option_without_post_value';
|
||||
$default = "default_value_{$name}";
|
||||
@ -491,7 +491,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Setting::save()
|
||||
* @see WP_Customize_Setting::update()
|
||||
*/
|
||||
function test_update_custom_type() {
|
||||
public function test_update_custom_type() {
|
||||
$type = 'custom';
|
||||
$name = 'foo';
|
||||
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type' ) );
|
||||
@ -526,7 +526,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
* @param mixed $value
|
||||
* @param WP_Customize_Setting $setting
|
||||
*/
|
||||
function handle_customize_update_custom_foo_action( $value, $setting = null ) {
|
||||
public function handle_customize_update_custom_foo_action( $value, $setting = null ) {
|
||||
$this->assertSame( 'hello world \\o/', $value );
|
||||
$this->assertInstanceOf( 'WP_Customize_Setting', $setting );
|
||||
}
|
||||
@ -537,7 +537,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
* @see Tests_WP_Customize_Setting::test_update_custom_type()
|
||||
* @param WP_Customize_Setting $setting
|
||||
*/
|
||||
function handle_customize_save_custom_foo_action( $setting ) {
|
||||
public function handle_customize_save_custom_foo_action( $setting ) {
|
||||
$this->assertInstanceOf( 'WP_Customize_Setting', $setting );
|
||||
$this->assertSame( 'custom', $setting->type );
|
||||
$this->assertSame( 'foo', $setting->id );
|
||||
@ -550,7 +550,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 31428
|
||||
*/
|
||||
function test_is_current_blog_previewed() {
|
||||
public function test_is_current_blog_previewed() {
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$type = 'option';
|
||||
$name = 'blogname';
|
||||
@ -572,7 +572,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
* @group multisite
|
||||
* @group ms-required
|
||||
*/
|
||||
function test_previewing_with_switch_to_blog() {
|
||||
public function test_previewing_with_switch_to_blog() {
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$type = 'option';
|
||||
$name = 'blogdescription';
|
||||
@ -594,7 +594,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 33499
|
||||
*/
|
||||
function test_option_autoloading() {
|
||||
public function test_option_autoloading() {
|
||||
global $wpdb;
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*/
|
||||
protected $backup_registered_sidebars;
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
|
||||
|
||||
@ -78,7 +78,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
WP_Customize_Setting::reset_aggregated_multidimensionals();
|
||||
}
|
||||
|
||||
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();
|
||||
@ -90,7 +90,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
parent::clean_up_global_scope();
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$this->manager = null;
|
||||
unset( $GLOBALS['wp_customize'] );
|
||||
unset( $GLOBALS['wp_scripts'] );
|
||||
@ -98,7 +98,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
function set_customized_post_data( $customized ) {
|
||||
private function set_customized_post_data( $customized ) {
|
||||
$_POST['customized'] = wp_slash( wp_json_encode( $customized ) );
|
||||
if ( $this->manager ) {
|
||||
foreach ( $customized as $id => $value ) {
|
||||
@ -107,7 +107,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function do_customize_boot_actions() {
|
||||
private function do_customize_boot_actions() {
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_REQUEST['nonce'] = wp_create_nonce( 'preview-customize_' . $this->manager->theme()->get_stylesheet() );
|
||||
do_action( 'setup_theme' );
|
||||
@ -117,14 +117,14 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
do_action( 'wp', $GLOBALS['wp'] );
|
||||
}
|
||||
|
||||
function remove_widgets_block_editor() {
|
||||
public function remove_widgets_block_editor() {
|
||||
remove_theme_support( 'widgets-block-editor' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test WP_Customize_Widgets::__construct()
|
||||
*/
|
||||
function test_construct() {
|
||||
public function test_construct() {
|
||||
$this->assertInstanceOf( 'WP_Customize_Widgets', $this->manager->widgets );
|
||||
$this->assertSame( $this->manager, $this->manager->widgets->manager );
|
||||
}
|
||||
@ -136,7 +136,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Widgets::preview_sidebars_widgets()
|
||||
* @ticket 36660
|
||||
*/
|
||||
function test_customize_register_with_deleted_sidebars() {
|
||||
public function test_customize_register_with_deleted_sidebars() {
|
||||
$sidebar_id = 'sidebar-1';
|
||||
delete_option( 'sidebars_widgets' );
|
||||
register_sidebar( array( 'id' => $sidebar_id ) );
|
||||
@ -228,7 +228,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Widgets::get_selective_refreshable_widgets()
|
||||
*/
|
||||
function test_get_selective_refreshable_widgets_when_theme_supports() {
|
||||
public function test_get_selective_refreshable_widgets_when_theme_supports() {
|
||||
global $wp_widget_factory;
|
||||
add_action( 'widgets_init', array( $this, 'override_search_widget_customize_selective_refresh' ), 90 );
|
||||
add_theme_support( 'customize-selective-refresh-widgets' );
|
||||
@ -248,7 +248,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Widgets::get_selective_refreshable_widgets()
|
||||
*/
|
||||
function test_get_selective_refreshable_widgets_when_no_theme_supports() {
|
||||
public function test_get_selective_refreshable_widgets_when_no_theme_supports() {
|
||||
add_action( 'widgets_init', array( $this, 'override_search_widget_customize_selective_refresh' ), 90 );
|
||||
remove_theme_support( 'customize-selective-refresh-widgets' );
|
||||
$this->do_customize_boot_actions();
|
||||
@ -262,7 +262,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
* @see Tests_WP_Customize_Widgets::test_get_selective_refreshable_widgets_when_theme_supports()
|
||||
* @see Tests_WP_Customize_Widgets::test_get_selective_refreshable_widgets_when_no_theme_supports()
|
||||
*/
|
||||
function override_search_widget_customize_selective_refresh() {
|
||||
public function override_search_widget_customize_selective_refresh() {
|
||||
global $wp_widget_factory;
|
||||
$wp_widget_factory->widgets['WP_Widget_Search']->widget_options['customize_selective_refresh'] = false;
|
||||
}
|
||||
@ -272,7 +272,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Widgets::is_widget_selective_refreshable()
|
||||
*/
|
||||
function test_is_widget_selective_refreshable() {
|
||||
public function test_is_widget_selective_refreshable() {
|
||||
add_action( 'widgets_init', array( $this, 'override_search_widget_customize_selective_refresh' ), 90 );
|
||||
add_theme_support( 'customize-selective-refresh-widgets' );
|
||||
$this->do_customize_boot_actions();
|
||||
@ -288,7 +288,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
* @ticket 30988
|
||||
* @ticket 36389
|
||||
*/
|
||||
function test_register_settings() {
|
||||
public function test_register_settings() {
|
||||
add_theme_support( 'customize-selective-refresh-widgets' );
|
||||
|
||||
$raw_widget_customized = array(
|
||||
@ -340,7 +340,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 36389
|
||||
*/
|
||||
function test_register_settings_without_selective_refresh() {
|
||||
public function test_register_settings_without_selective_refresh() {
|
||||
remove_theme_support( 'customize-selective-refresh-widgets' );
|
||||
$this->test_register_settings();
|
||||
}
|
||||
@ -350,7 +350,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 36389
|
||||
*/
|
||||
function test_register_settings_with_late_theme_support_added() {
|
||||
public function test_register_settings_with_late_theme_support_added() {
|
||||
remove_theme_support( 'customize-selective-refresh-widgets' );
|
||||
add_action( 'after_setup_theme', array( $this, 'add_customize_selective_refresh_theme_support' ), 100 );
|
||||
$this->test_register_settings();
|
||||
@ -359,14 +359,14 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* Add customize-selective-refresh-widgets theme support.
|
||||
*/
|
||||
function add_customize_selective_refresh_theme_support() {
|
||||
public function add_customize_selective_refresh_theme_support() {
|
||||
add_theme_support( 'customize-selective-refresh-widgets' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test WP_Customize_Widgets::get_setting_args()
|
||||
*/
|
||||
function test_get_setting_args() {
|
||||
public function test_get_setting_args() {
|
||||
add_theme_support( 'customize-selective-refresh-widgets' );
|
||||
$this->do_customize_boot_actions();
|
||||
|
||||
@ -447,7 +447,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
$this->assertSame( 'SIDEBARS_WIDGETS[SIDEBAR-2]', $args['uppercase_id_set_by_filter'] );
|
||||
}
|
||||
|
||||
function filter_widget_customizer_setting_args( $args, $id ) {
|
||||
public function filter_widget_customizer_setting_args( $args, $id ) {
|
||||
$args['uppercase_id_set_by_filter'] = strtoupper( $id );
|
||||
return $args;
|
||||
}
|
||||
@ -455,7 +455,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* Test WP_Customize_Widgets::sanitize_widget_js_instance() and WP_Customize_Widgets::sanitize_widget_instance()
|
||||
*/
|
||||
function test_sanitize_widget_js_instance() {
|
||||
public function test_sanitize_widget_js_instance() {
|
||||
$this->do_customize_boot_actions();
|
||||
|
||||
$new_categories_instance = array(
|
||||
@ -486,7 +486,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 53489
|
||||
*/
|
||||
function test_sanitize_widget_instance_raw_instance() {
|
||||
public function test_sanitize_widget_instance_raw_instance() {
|
||||
remove_action( 'widgets_init', array( $this, 'remove_widgets_block_editor' ) );
|
||||
$this->do_customize_boot_actions();
|
||||
|
||||
@ -513,7 +513,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 53489
|
||||
*/
|
||||
function test_sanitize_widget_instance_with_no_show_instance_in_rest() {
|
||||
public function test_sanitize_widget_instance_with_no_show_instance_in_rest() {
|
||||
global $wp_widget_factory;
|
||||
|
||||
remove_action( 'widgets_init', array( $this, 'remove_widgets_block_editor' ) );
|
||||
@ -544,7 +544,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 53479
|
||||
*/
|
||||
function test_sanitize_widget_instance_empty_instance() {
|
||||
public function test_sanitize_widget_instance_empty_instance() {
|
||||
$this->do_customize_boot_actions();
|
||||
$this->assertSame( $this->manager->widgets->sanitize_widget_instance( array() ), array() );
|
||||
}
|
||||
@ -554,7 +554,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_test_widget_control_args() {
|
||||
private function get_test_widget_control_args() {
|
||||
global $wp_registered_widgets;
|
||||
require_once ABSPATH . '/wp-admin/includes/widgets.php';
|
||||
$widget_id = 'search-2';
|
||||
@ -575,7 +575,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Widgets::get_widget_control()
|
||||
*/
|
||||
function test_get_widget_control() {
|
||||
public function test_get_widget_control() {
|
||||
$this->do_customize_boot_actions();
|
||||
$widget_control = $this->manager->widgets->get_widget_control( $this->get_test_widget_control_args() );
|
||||
|
||||
@ -588,7 +588,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Widgets::get_widget_control_parts()
|
||||
*/
|
||||
function test_get_widget_control_parts() {
|
||||
public function test_get_widget_control_parts() {
|
||||
$this->do_customize_boot_actions();
|
||||
$widget_control_parts = $this->manager->widgets->get_widget_control_parts( $this->get_test_widget_control_args() );
|
||||
$this->assertArrayHasKey( 'content', $widget_control_parts );
|
||||
@ -604,7 +604,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Widget_Form_Customize_Control::json()
|
||||
*/
|
||||
function test_wp_widget_form_customize_control_json() {
|
||||
public function test_wp_widget_form_customize_control_json() {
|
||||
$this->do_customize_boot_actions();
|
||||
$control = $this->manager->get_control( 'widget_search[2]' );
|
||||
$params = $control->json();
|
||||
@ -626,7 +626,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
/**
|
||||
* @see WP_Customize_Widgets::is_panel_active()
|
||||
*/
|
||||
function test_is_panel_active() {
|
||||
public function test_is_panel_active() {
|
||||
global $wp_registered_sidebars;
|
||||
$this->do_customize_boot_actions();
|
||||
|
||||
@ -643,7 +643,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
* @ticket 34738
|
||||
* @see WP_Customize_Widgets::call_widget_update()
|
||||
*/
|
||||
function test_call_widget_update() {
|
||||
public function test_call_widget_update() {
|
||||
|
||||
$widget_number = 2;
|
||||
$widget_id = "search-{$widget_number}";
|
||||
@ -699,7 +699,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Widgets::customize_dynamic_partial_args()
|
||||
*/
|
||||
function test_customize_dynamic_partial_args() {
|
||||
public function test_customize_dynamic_partial_args() {
|
||||
do_action( 'customize_register', $this->manager );
|
||||
|
||||
$args = apply_filters( 'customize_dynamic_partial_args', false, 'widget[search-2]' );
|
||||
@ -725,7 +725,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Widgets::selective_refresh_init()
|
||||
*/
|
||||
function test_selective_refresh_init_with_theme_support() {
|
||||
public function test_selective_refresh_init_with_theme_support() {
|
||||
add_theme_support( 'customize-selective-refresh-widgets' );
|
||||
$this->manager->widgets->selective_refresh_init();
|
||||
$this->assertSame( 10, has_action( 'dynamic_sidebar_before', array( $this->manager->widgets, 'start_dynamic_sidebar' ) ) );
|
||||
@ -739,7 +739,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Widgets::selective_refresh_init()
|
||||
*/
|
||||
function test_selective_refresh_init_without_theme_support() {
|
||||
public function test_selective_refresh_init_without_theme_support() {
|
||||
remove_theme_support( 'customize-selective-refresh-widgets' );
|
||||
$this->manager->widgets->selective_refresh_init();
|
||||
$this->assertFalse( has_action( 'dynamic_sidebar_before', array( $this->manager->widgets, 'start_dynamic_sidebar' ) ) );
|
||||
@ -753,7 +753,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Widgets::customize_preview_enqueue()
|
||||
*/
|
||||
function test_customize_preview_enqueue() {
|
||||
public function test_customize_preview_enqueue() {
|
||||
$this->manager->widgets->customize_preview_enqueue();
|
||||
$this->assertTrue( wp_script_is( 'customize-preview-widgets', 'enqueued' ) );
|
||||
$this->assertTrue( wp_style_is( 'customize-preview', 'enqueued' ) );
|
||||
@ -768,7 +768,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Widgets::start_dynamic_sidebar()
|
||||
* @see WP_Customize_Widgets::end_dynamic_sidebar()
|
||||
*/
|
||||
function test_filter_dynamic_sidebar_params() {
|
||||
public function test_filter_dynamic_sidebar_params() {
|
||||
global $wp_registered_sidebars;
|
||||
register_sidebar(
|
||||
array(
|
||||
@ -823,7 +823,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
*
|
||||
* @see WP_Customize_Widgets::render_widget_partial()
|
||||
*/
|
||||
function test_render_widget_partial() {
|
||||
public function test_render_widget_partial() {
|
||||
add_theme_support( 'customize-selective-refresh-widgets' );
|
||||
$this->do_customize_boot_actions();
|
||||
$this->manager->widgets->selective_refresh_init();
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
*/
|
||||
class Tests_Date_GetFeedBuildDate extends WP_UnitTestCase {
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
global $wp_query;
|
||||
|
||||
update_option( 'timezone_string', 'UTC' );
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
*/
|
||||
class Tests_Date_GetPermalink extends WP_UnitTestCase {
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
delete_option( 'permalink_structure' );
|
||||
update_option( 'timezone_string', 'UTC' );
|
||||
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
*/
|
||||
class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
|
||||
date_default_timezone_set( 'UTC' );
|
||||
|
||||
@ -17,14 +17,14 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 28310
|
||||
*/
|
||||
function test_mysql2date_returns_false_with_no_date() {
|
||||
public function test_mysql2date_returns_false_with_no_date() {
|
||||
$this->assertFalse( mysql2date( 'F j, Y H:i:s', '' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 28310
|
||||
*/
|
||||
function test_mysql2date_returns_gmt_or_unix_timestamp() {
|
||||
public function test_mysql2date_returns_gmt_or_unix_timestamp() {
|
||||
$this->assertSame( 441013392, mysql2date( 'G', '1983-12-23 07:43:12' ) );
|
||||
$this->assertSame( 441013392, mysql2date( 'U', '1983-12-23 07:43:12' ) );
|
||||
}
|
||||
@ -32,7 +32,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 28992
|
||||
*/
|
||||
function test_mysql2date_should_format_time() {
|
||||
public function test_mysql2date_should_format_time() {
|
||||
$timezone = 'Europe/Kiev';
|
||||
update_option( 'timezone_string', $timezone );
|
||||
$datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
|
||||
@ -46,7 +46,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 28992
|
||||
*/
|
||||
function test_mysql2date_should_format_time_with_changed_time_zone() {
|
||||
public function test_mysql2date_should_format_time_with_changed_time_zone() {
|
||||
$timezone = 'Europe/Kiev';
|
||||
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
|
||||
date_default_timezone_set( $timezone );
|
||||
@ -62,7 +62,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 28992
|
||||
*/
|
||||
function test_mysql2date_should_return_wp_timestamp() {
|
||||
public function test_mysql2date_should_return_wp_timestamp() {
|
||||
$timezone = 'Europe/Kiev';
|
||||
update_option( 'timezone_string', $timezone );
|
||||
$datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
|
||||
@ -76,7 +76,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 28992
|
||||
*/
|
||||
function test_mysql2date_should_return_unix_timestamp_for_gmt_time() {
|
||||
public function test_mysql2date_should_return_unix_timestamp_for_gmt_time() {
|
||||
$timezone = 'Europe/Kiev';
|
||||
update_option( 'timezone_string', $timezone );
|
||||
$datetime = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
|
||||
|
||||
@ -88,7 +88,7 @@ class Tests_Date_TheDate extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 33750
|
||||
*/
|
||||
function test_the_date() {
|
||||
public function test_the_date() {
|
||||
ob_start();
|
||||
the_date();
|
||||
$actual = ob_get_clean();
|
||||
@ -128,7 +128,7 @@ class Tests_Date_TheDate extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 47354
|
||||
*/
|
||||
function test_the_weekday_date() {
|
||||
public function test_the_weekday_date() {
|
||||
ob_start();
|
||||
the_weekday_date();
|
||||
$actual = ob_get_clean();
|
||||
|
||||
@ -212,7 +212,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
|
||||
*
|
||||
* @covers wp_xmlrpc_server::wp_editComment
|
||||
*/
|
||||
function test_date_edit_comment() {
|
||||
public function test_date_edit_comment() {
|
||||
$timezone = 'Europe/Kiev';
|
||||
update_option( 'timezone_string', $timezone );
|
||||
|
||||
|
||||
@ -121,7 +121,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 10041
|
||||
*/
|
||||
function test_esc_like() {
|
||||
public function test_esc_like() {
|
||||
global $wpdb;
|
||||
|
||||
$inputs = array(
|
||||
@ -157,12 +157,12 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
* @param $like string The like phrase, raw.
|
||||
* @param $result string The expected comparison result; '1' = true, '0' = false
|
||||
*/
|
||||
function test_like_query( $data, $like, $result ) {
|
||||
public function test_like_query( $data, $like, $result ) {
|
||||
global $wpdb;
|
||||
return $this->assertSame( $result, $wpdb->get_var( $wpdb->prepare( 'SELECT %s LIKE %s', $data, $wpdb->esc_like( $like ) ) ) );
|
||||
}
|
||||
|
||||
function data_like_query() {
|
||||
public function data_like_query() {
|
||||
return array(
|
||||
array(
|
||||
'aaa',
|
||||
@ -220,7 +220,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 18510
|
||||
*/
|
||||
function test_wpdb_supposedly_protected_properties() {
|
||||
public function test_wpdb_supposedly_protected_properties() {
|
||||
global $wpdb;
|
||||
|
||||
$this->assertNotEmpty( $wpdb->dbh );
|
||||
@ -236,7 +236,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21212
|
||||
*/
|
||||
function test_wpdb_actually_protected_properties() {
|
||||
public function test_wpdb_actually_protected_properties() {
|
||||
global $wpdb;
|
||||
|
||||
$new_meta = "HAHA I HOPE THIS DOESN'T WORK";
|
||||
@ -251,7 +251,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 18510
|
||||
*/
|
||||
function test_wpdb_nonexistent_properties() {
|
||||
public function test_wpdb_nonexistent_properties() {
|
||||
global $wpdb;
|
||||
|
||||
$this->assertTrue( empty( $wpdb->nonexistent_property ) );
|
||||
@ -282,7 +282,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 26847
|
||||
*/
|
||||
function test_set_sql_mode() {
|
||||
public function test_set_sql_mode() {
|
||||
global $wpdb;
|
||||
|
||||
$current_modes = $wpdb->get_var( 'SELECT @@SESSION.sql_mode;' );
|
||||
@ -302,7 +302,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 26847
|
||||
*/
|
||||
function test_set_incompatible_sql_mode() {
|
||||
public function test_set_incompatible_sql_mode() {
|
||||
global $wpdb;
|
||||
|
||||
$current_modes = $wpdb->get_var( 'SELECT @@SESSION.sql_mode;' );
|
||||
@ -320,7 +320,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 26847
|
||||
*/
|
||||
function test_set_allowed_incompatible_sql_mode() {
|
||||
public function test_set_allowed_incompatible_sql_mode() {
|
||||
global $wpdb;
|
||||
|
||||
$current_modes = $wpdb->get_var( 'SELECT @@SESSION.sql_mode;' );
|
||||
@ -353,7 +353,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
* @ticket 25604
|
||||
* @expectedIncorrectUsage wpdb::prepare
|
||||
*/
|
||||
function test_prepare_without_arguments() {
|
||||
public function test_prepare_without_arguments() {
|
||||
global $wpdb;
|
||||
$id = 0;
|
||||
// This, obviously, is an incorrect prepare.
|
||||
@ -362,7 +362,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
$this->assertSame( "SELECT * FROM $wpdb->users WHERE id = 0", $prepared );
|
||||
}
|
||||
|
||||
function test_prepare_sprintf() {
|
||||
public function test_prepare_sprintf() {
|
||||
global $wpdb;
|
||||
|
||||
$prepared = $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", 1, 'admin' );
|
||||
@ -372,7 +372,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @expectedIncorrectUsage wpdb::prepare
|
||||
*/
|
||||
function test_prepare_sprintf_invalid_args() {
|
||||
public function test_prepare_sprintf_invalid_args() {
|
||||
global $wpdb;
|
||||
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
||||
@ -384,7 +384,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
$this->assertSame( "SELECT * FROM $wpdb->users WHERE id = 0 AND user_login = 'admin'", $prepared );
|
||||
}
|
||||
|
||||
function test_prepare_vsprintf() {
|
||||
public function test_prepare_vsprintf() {
|
||||
global $wpdb;
|
||||
|
||||
$prepared = $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", array( 1, 'admin' ) );
|
||||
@ -394,7 +394,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @expectedIncorrectUsage wpdb::prepare
|
||||
*/
|
||||
function test_prepare_vsprintf_invalid_args() {
|
||||
public function test_prepare_vsprintf_invalid_args() {
|
||||
global $wpdb;
|
||||
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
||||
@ -471,13 +471,13 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function test_db_version() {
|
||||
public function test_db_version() {
|
||||
global $wpdb;
|
||||
|
||||
$this->assertTrue( version_compare( $wpdb->db_version(), '5.0', '>=' ) );
|
||||
}
|
||||
|
||||
function test_get_caller() {
|
||||
public function test_get_caller() {
|
||||
global $wpdb;
|
||||
$str = $wpdb->get_caller();
|
||||
$calls = explode( ', ', $str );
|
||||
@ -485,7 +485,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
$this->assertSame( $called, end( $calls ) );
|
||||
}
|
||||
|
||||
function test_has_cap() {
|
||||
public function test_has_cap() {
|
||||
global $wpdb;
|
||||
$this->assertTrue( $wpdb->has_cap( 'collation' ) );
|
||||
$this->assertTrue( $wpdb->has_cap( 'group_concat' ) );
|
||||
@ -506,24 +506,24 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @expectedDeprecated supports_collation
|
||||
*/
|
||||
function test_supports_collation() {
|
||||
public function test_supports_collation() {
|
||||
global $wpdb;
|
||||
$this->assertTrue( $wpdb->supports_collation() );
|
||||
}
|
||||
|
||||
function test_check_database_version() {
|
||||
public function test_check_database_version() {
|
||||
global $wpdb;
|
||||
$this->assertEmpty( $wpdb->check_database_version() );
|
||||
}
|
||||
|
||||
function test_bail() {
|
||||
public function test_bail() {
|
||||
global $wpdb;
|
||||
|
||||
$this->expectException( 'WPDieException' );
|
||||
$wpdb->bail( 'Database is dead.' );
|
||||
}
|
||||
|
||||
function test_timers() {
|
||||
public function test_timers() {
|
||||
global $wpdb;
|
||||
|
||||
$wpdb->timer_start();
|
||||
@ -534,7 +534,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
$this->assertGreaterThan( $stop, $wpdb->time_start );
|
||||
}
|
||||
|
||||
function test_get_col_info() {
|
||||
public function test_get_col_info() {
|
||||
global $wpdb;
|
||||
|
||||
$wpdb->get_results( "SELECT ID FROM $wpdb->users" );
|
||||
@ -544,7 +544,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
$this->assertSame( $wpdb->users, $wpdb->get_col_info( 'table', 0 ) );
|
||||
}
|
||||
|
||||
function test_query_and_delete() {
|
||||
public function test_query_and_delete() {
|
||||
global $wpdb;
|
||||
$rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" );
|
||||
$this->assertSame( 1, $rows );
|
||||
@ -553,7 +553,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
$this->assertSame( 1, $d_rows );
|
||||
}
|
||||
|
||||
function test_get_row() {
|
||||
public function test_get_row() {
|
||||
global $wpdb;
|
||||
$rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" );
|
||||
$this->assertSame( 1, $rows );
|
||||
@ -576,7 +576,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 45299
|
||||
*/
|
||||
function test_get_col( $query, $expected, $last_result, $column ) {
|
||||
public function test_get_col( $query, $expected, $last_result, $column ) {
|
||||
global $wpdb;
|
||||
|
||||
$wpdb->last_result = $last_result;
|
||||
@ -606,7 +606,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
* @type arrray|string|null $last_result The value to assign to `$wpdb->last_result`.
|
||||
* @type int|string $column The column index to retrieve.
|
||||
*/
|
||||
function data_test_get_col() {
|
||||
public function data_test_get_col() {
|
||||
global $wpdb;
|
||||
|
||||
return array(
|
||||
@ -655,7 +655,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function test_replace() {
|
||||
public function test_replace() {
|
||||
global $wpdb;
|
||||
$rows1 = $wpdb->insert( $wpdb->users, array( 'display_name' => 'Walter Sobchak' ) );
|
||||
$this->assertSame( 1, $rows1 );
|
||||
@ -683,7 +683,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 26106
|
||||
*/
|
||||
function test_empty_where_on_update() {
|
||||
public function test_empty_where_on_update() {
|
||||
global $wpdb;
|
||||
$suppress = $wpdb->suppress_errors( true );
|
||||
$wpdb->update( $wpdb->posts, array( 'post_name' => 'burrito' ), array() );
|
||||
@ -705,7 +705,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 28155
|
||||
*/
|
||||
function test_mysqli_flush_sync() {
|
||||
public function test_mysqli_flush_sync() {
|
||||
global $wpdb;
|
||||
if ( ! $wpdb->use_mysqli ) {
|
||||
$this->markTestSkipped( 'mysqli not being used.' );
|
||||
@ -741,7 +741,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
* @ticket 21212
|
||||
* @ticket 32763
|
||||
*/
|
||||
function data_get_table_from_query() {
|
||||
public function data_get_table_from_query() {
|
||||
$table = 'a_test_table_name';
|
||||
$more_tables = array(
|
||||
// table_name => expected_value
|
||||
@ -865,11 +865,11 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
* @dataProvider data_get_table_from_query
|
||||
* @ticket 21212
|
||||
*/
|
||||
function test_get_table_from_query( $query, $table ) {
|
||||
public function test_get_table_from_query( $query, $table ) {
|
||||
$this->assertSame( $table, self::$_wpdb->get_table_from_query( $query ) );
|
||||
}
|
||||
|
||||
function data_get_table_from_query_false() {
|
||||
public function data_get_table_from_query_false() {
|
||||
$table = 'a_test_table_name';
|
||||
return array(
|
||||
array( "LOL THIS ISN'T EVEN A QUERY $table" ),
|
||||
@ -880,14 +880,14 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
* @dataProvider data_get_table_from_query_false
|
||||
* @ticket 21212
|
||||
*/
|
||||
function test_get_table_from_query_false( $query ) {
|
||||
public function test_get_table_from_query_false( $query ) {
|
||||
$this->assertFalse( self::$_wpdb->get_table_from_query( $query ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 38751
|
||||
*/
|
||||
function data_get_escaped_table_from_show_query() {
|
||||
public function data_get_escaped_table_from_show_query() {
|
||||
return array(
|
||||
// Equality.
|
||||
array( "SHOW TABLE STATUS WHERE Name = 'test_name'", 'test_name' ),
|
||||
@ -907,14 +907,14 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
* @dataProvider data_get_escaped_table_from_show_query
|
||||
* @ticket 38751
|
||||
*/
|
||||
function test_get_escaped_table_from_show_query( $query, $table ) {
|
||||
public function test_get_escaped_table_from_show_query( $query, $table ) {
|
||||
$this->assertSame( $table, self::$_wpdb->get_table_from_query( $query ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 21212
|
||||
*/
|
||||
function data_process_field_formats() {
|
||||
public function data_process_field_formats() {
|
||||
$core_db_fields_no_format_specified = array(
|
||||
array(
|
||||
'post_content' => 'foo',
|
||||
@ -1022,7 +1022,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
* @dataProvider data_process_field_formats
|
||||
* @ticket 21212
|
||||
*/
|
||||
function test_process_field_formats( $data, $format, $expected, $message ) {
|
||||
public function test_process_field_formats( $data, $format, $expected, $message ) {
|
||||
$actual = self::$_wpdb->process_field_formats( $data, $format );
|
||||
$this->assertSame( $expected, $actual, $message );
|
||||
}
|
||||
@ -1030,7 +1030,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21212
|
||||
*/
|
||||
function test_process_fields() {
|
||||
public function test_process_fields() {
|
||||
global $wpdb;
|
||||
|
||||
if ( $wpdb->charset ) {
|
||||
@ -1060,7 +1060,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
* @ticket 21212
|
||||
* @depends test_process_fields
|
||||
*/
|
||||
function test_process_fields_on_nonexistent_table( $data ) {
|
||||
public function test_process_fields_on_nonexistent_table( $data ) {
|
||||
self::$_wpdb->suppress_errors( true );
|
||||
$data = array( 'post_content' => '¡foo foo foo!' );
|
||||
$this->assertFalse( self::$_wpdb->process_fields( 'nonexistent_table', $data, null ) );
|
||||
@ -1070,35 +1070,35 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21212
|
||||
*/
|
||||
function test_pre_get_table_charset_filter() {
|
||||
public function test_pre_get_table_charset_filter() {
|
||||
add_filter( 'pre_get_table_charset', array( $this, 'filter_pre_get_table_charset' ), 10, 2 );
|
||||
$charset = self::$_wpdb->get_table_charset( 'some_table' );
|
||||
remove_filter( 'pre_get_table_charset', array( $this, 'filter_pre_get_table_charset' ), 10 );
|
||||
|
||||
$this->assertSame( $charset, 'fake_charset' );
|
||||
}
|
||||
function filter_pre_get_table_charset( $charset, $table ) {
|
||||
public function filter_pre_get_table_charset( $charset, $table ) {
|
||||
return 'fake_charset';
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 21212
|
||||
*/
|
||||
function test_pre_get_col_charset_filter() {
|
||||
public function test_pre_get_col_charset_filter() {
|
||||
add_filter( 'pre_get_col_charset', array( $this, 'filter_pre_get_col_charset' ), 10, 3 );
|
||||
$charset = self::$_wpdb->get_col_charset( 'some_table', 'some_col' );
|
||||
remove_filter( 'pre_get_col_charset', array( $this, 'filter_pre_get_col_charset' ), 10 );
|
||||
|
||||
$this->assertSame( $charset, 'fake_col_charset' );
|
||||
}
|
||||
function filter_pre_get_col_charset( $charset, $table, $column ) {
|
||||
public function filter_pre_get_col_charset( $charset, $table, $column ) {
|
||||
return 'fake_col_charset';
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 15158
|
||||
*/
|
||||
function test_null_insert() {
|
||||
public function test_null_insert() {
|
||||
global $wpdb;
|
||||
|
||||
$key = 'null_insert_key';
|
||||
@ -1120,7 +1120,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 15158
|
||||
*/
|
||||
function test_null_update_value() {
|
||||
public function test_null_update_value() {
|
||||
global $wpdb;
|
||||
|
||||
$key = 'null_update_value_key';
|
||||
@ -1158,7 +1158,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 15158
|
||||
*/
|
||||
function test_null_update_where() {
|
||||
public function test_null_update_where() {
|
||||
global $wpdb;
|
||||
|
||||
$key = 'null_update_where_key';
|
||||
@ -1196,7 +1196,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 15158
|
||||
*/
|
||||
function test_null_delete() {
|
||||
public function test_null_delete() {
|
||||
global $wpdb;
|
||||
|
||||
$key = 'null_update_where_key';
|
||||
@ -1232,7 +1232,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34903
|
||||
*/
|
||||
function test_close() {
|
||||
public function test_close() {
|
||||
global $wpdb;
|
||||
|
||||
$this->assertTrue( $wpdb->close() );
|
||||
@ -1251,7 +1251,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 36917
|
||||
*/
|
||||
function test_charset_not_determined_when_disconnected() {
|
||||
public function test_charset_not_determined_when_disconnected() {
|
||||
global $wpdb;
|
||||
|
||||
$charset = 'utf8';
|
||||
@ -1269,7 +1269,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 36917
|
||||
*/
|
||||
function test_charset_switched_to_utf8mb4() {
|
||||
public function test_charset_switched_to_utf8mb4() {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! $wpdb->has_cap( 'utf8mb4' ) ) {
|
||||
@ -1288,7 +1288,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
* @ticket 32105
|
||||
* @ticket 36917
|
||||
*/
|
||||
function test_collate_switched_to_utf8mb4_520() {
|
||||
public function test_collate_switched_to_utf8mb4_520() {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! $wpdb->has_cap( 'utf8mb4_520' ) ) {
|
||||
@ -1307,7 +1307,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
* @ticket 32405
|
||||
* @ticket 36917
|
||||
*/
|
||||
function test_non_unicode_collations() {
|
||||
public function test_non_unicode_collations() {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! $wpdb->has_cap( 'utf8mb4' ) ) {
|
||||
@ -1325,7 +1325,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 37982
|
||||
*/
|
||||
function test_charset_switched_to_utf8() {
|
||||
public function test_charset_switched_to_utf8() {
|
||||
global $wpdb;
|
||||
|
||||
if ( $wpdb->has_cap( 'utf8mb4' ) ) {
|
||||
@ -1344,7 +1344,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data_prepare_with_placeholders
|
||||
*/
|
||||
function test_prepare_with_placeholders_and_individual_args( $sql, $values, $incorrect_usage, $expected ) {
|
||||
public function test_prepare_with_placeholders_and_individual_args( $sql, $values, $incorrect_usage, $expected ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( $incorrect_usage ) {
|
||||
@ -1363,7 +1363,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data_prepare_with_placeholders
|
||||
*/
|
||||
function test_prepare_with_placeholders_and_array_args( $sql, $values, $incorrect_usage, $expected ) {
|
||||
public function test_prepare_with_placeholders_and_array_args( $sql, $values, $incorrect_usage, $expected ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( $incorrect_usage ) {
|
||||
@ -1379,7 +1379,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
$this->assertSame( $expected, $sql );
|
||||
}
|
||||
|
||||
function data_prepare_with_placeholders() {
|
||||
public function data_prepare_with_placeholders() {
|
||||
global $wpdb;
|
||||
|
||||
return array(
|
||||
@ -1557,7 +1557,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data_escape_and_prepare
|
||||
*/
|
||||
function test_escape_and_prepare( $escape, $sql, $values, $incorrect_usage, $expected ) {
|
||||
public function test_escape_and_prepare( $escape, $sql, $values, $incorrect_usage, $expected ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( $incorrect_usage ) {
|
||||
@ -1574,7 +1574,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
function data_escape_and_prepare() {
|
||||
public function data_escape_and_prepare() {
|
||||
global $wpdb;
|
||||
return array(
|
||||
array(
|
||||
@ -1604,7 +1604,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
/**
|
||||
* @expectedIncorrectUsage wpdb::prepare
|
||||
*/
|
||||
function test_double_prepare() {
|
||||
public function test_double_prepare() {
|
||||
global $wpdb;
|
||||
|
||||
$part = $wpdb->prepare( ' AND meta_value = %s', ' %s ' );
|
||||
@ -1614,7 +1614,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
$this->assertNull( $query );
|
||||
}
|
||||
|
||||
function test_prepare_numeric_placeholders_float_args() {
|
||||
public function test_prepare_numeric_placeholders_float_args() {
|
||||
global $wpdb;
|
||||
|
||||
$actual = $wpdb->prepare(
|
||||
@ -1629,7 +1629,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
$this->assertStringContainsString( ' second=2.2', $actual );
|
||||
}
|
||||
|
||||
function test_prepare_numeric_placeholders_float_array() {
|
||||
public function test_prepare_numeric_placeholders_float_array() {
|
||||
global $wpdb;
|
||||
|
||||
$actual = $wpdb->prepare(
|
||||
@ -1643,7 +1643,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
$this->assertStringContainsString( ' second=2.2', $actual );
|
||||
}
|
||||
|
||||
function test_query_unescapes_placeholders() {
|
||||
public function test_query_unescapes_placeholders() {
|
||||
global $wpdb;
|
||||
|
||||
$value = ' %s ';
|
||||
@ -1662,7 +1662,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
$this->assertSame( $value, $actual );
|
||||
}
|
||||
|
||||
function test_esc_sql_with_unsupported_placeholder_type() {
|
||||
public function test_esc_sql_with_unsupported_placeholder_type() {
|
||||
global $wpdb;
|
||||
|
||||
$sql = $wpdb->prepare( ' %s %1$c ', 'foo' );
|
||||
|
||||
@ -35,7 +35,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21212
|
||||
*/
|
||||
function data_strip_invalid_text() {
|
||||
public function data_strip_invalid_text() {
|
||||
$fields = array(
|
||||
'latin1' => array(
|
||||
// latin1. latin1 never changes.
|
||||
@ -479,7 +479,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::strip_invalid_text
|
||||
*/
|
||||
function test_strip_invalid_text( $data, $expected, $message ) {
|
||||
public function test_strip_invalid_text( $data, $expected, $message ) {
|
||||
$charset = self::$_wpdb->charset;
|
||||
if ( isset( $data[0]['connection_charset'] ) ) {
|
||||
$new_charset = $data[0]['connection_charset'];
|
||||
@ -512,7 +512,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::process_fields
|
||||
*/
|
||||
function test_process_fields_failure() {
|
||||
public function test_process_fields_failure() {
|
||||
global $wpdb;
|
||||
|
||||
$charset = $wpdb->get_col_charset( $wpdb->posts, 'post_content' );
|
||||
@ -528,7 +528,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21212
|
||||
*/
|
||||
function data_process_field_charsets() {
|
||||
public function data_process_field_charsets() {
|
||||
if ( $GLOBALS['wpdb']->charset ) {
|
||||
$charset = $GLOBALS['wpdb']->charset;
|
||||
} else {
|
||||
@ -599,7 +599,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::process_field_charsets
|
||||
*/
|
||||
function test_process_field_charsets( $data, $expected, $message ) {
|
||||
public function test_process_field_charsets( $data, $expected, $message ) {
|
||||
$actual = self::$_wpdb->process_field_charsets( $data, $GLOBALS['wpdb']->posts );
|
||||
$this->assertSame( $expected, $actual, $message );
|
||||
}
|
||||
@ -611,7 +611,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
* @ticket 21212
|
||||
* @depends test_process_field_charsets
|
||||
*/
|
||||
function test_process_field_charsets_on_nonexistent_table() {
|
||||
public function test_process_field_charsets_on_nonexistent_table() {
|
||||
$data = array(
|
||||
'post_content' => array(
|
||||
'value' => '¡foo foo foo!',
|
||||
@ -628,7 +628,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::check_ascii
|
||||
*/
|
||||
function test_check_ascii() {
|
||||
public function test_check_ascii() {
|
||||
$ascii = "\0\t\n\r '" . '!"#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
|
||||
$this->assertTrue( self::$_wpdb->check_ascii( $ascii ) );
|
||||
}
|
||||
@ -638,7 +638,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::check_ascii
|
||||
*/
|
||||
function test_check_ascii_false() {
|
||||
public function test_check_ascii_false() {
|
||||
$this->assertFalse( self::$_wpdb->check_ascii( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ¡©«' ) );
|
||||
}
|
||||
|
||||
@ -647,7 +647,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::strip_invalid_text_for_column
|
||||
*/
|
||||
function test_strip_invalid_text_for_column() {
|
||||
public function test_strip_invalid_text_for_column() {
|
||||
global $wpdb;
|
||||
|
||||
$charset = $wpdb->get_col_charset( $wpdb->posts, 'post_content' );
|
||||
@ -737,7 +737,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21212
|
||||
*/
|
||||
function data_test_get_table_charset() {
|
||||
public function data_test_get_table_charset() {
|
||||
$table_name = 'test_get_table_charset';
|
||||
|
||||
$vars = array();
|
||||
@ -757,7 +757,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::get_table_charset
|
||||
*/
|
||||
function test_get_table_charset( $drop, $create, $table, $expected_charset ) {
|
||||
public function test_get_table_charset( $drop, $create, $table, $expected_charset ) {
|
||||
self::$_wpdb->query( $drop );
|
||||
|
||||
if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) {
|
||||
@ -778,7 +778,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21212
|
||||
*/
|
||||
function data_test_get_column_charset() {
|
||||
public function data_test_get_column_charset() {
|
||||
$table_name = 'test_get_column_charset';
|
||||
|
||||
$vars = array();
|
||||
@ -798,7 +798,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::get_col_charset
|
||||
*/
|
||||
function test_get_column_charset( $drop, $create, $table, $expected_charset ) {
|
||||
public function test_get_column_charset( $drop, $create, $table, $expected_charset ) {
|
||||
self::$_wpdb->query( $drop );
|
||||
|
||||
if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) {
|
||||
@ -821,7 +821,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::get_col_charset
|
||||
*/
|
||||
function test_get_column_charset_non_mysql( $drop, $create, $table, $columns ) {
|
||||
public function test_get_column_charset_non_mysql( $drop, $create, $table, $columns ) {
|
||||
self::$_wpdb->query( $drop );
|
||||
|
||||
if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) {
|
||||
@ -848,7 +848,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::get_col_charset
|
||||
*/
|
||||
function test_get_column_charset_is_mysql_undefined( $drop, $create, $table, $columns ) {
|
||||
public function test_get_column_charset_is_mysql_undefined( $drop, $create, $table, $columns ) {
|
||||
self::$_wpdb->query( $drop );
|
||||
|
||||
if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) {
|
||||
@ -872,7 +872,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21212
|
||||
*/
|
||||
function data_strip_invalid_text_from_query() {
|
||||
public function data_strip_invalid_text_from_query() {
|
||||
$table_name = 'strip_invalid_text_from_query_table';
|
||||
$data = array(
|
||||
array(
|
||||
@ -908,7 +908,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::strip_invalid_text_from_query
|
||||
*/
|
||||
function test_strip_invalid_text_from_query( $create, $query, $expected, $drop ) {
|
||||
public function test_strip_invalid_text_from_query( $create, $query, $expected, $drop ) {
|
||||
self::$_wpdb->query( $drop );
|
||||
|
||||
if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) {
|
||||
@ -926,7 +926,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 32104
|
||||
*/
|
||||
function data_dont_strip_text_from_schema_queries() {
|
||||
public function data_dont_strip_text_from_schema_queries() {
|
||||
// An obviously invalid and fake table name.
|
||||
$table_name = "\xff\xff\xff\xff";
|
||||
|
||||
@ -952,7 +952,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::strip_invalid_text_from_query
|
||||
*/
|
||||
function test_dont_strip_text_from_schema_queries( $query ) {
|
||||
public function test_dont_strip_text_from_schema_queries( $query ) {
|
||||
$return = self::$_wpdb->strip_invalid_text_from_query( $query );
|
||||
$this->assertSame( $query, $return );
|
||||
}
|
||||
@ -962,7 +962,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::query
|
||||
*/
|
||||
function test_invalid_characters_in_query() {
|
||||
public function test_invalid_characters_in_query() {
|
||||
global $wpdb;
|
||||
|
||||
$charset = $wpdb->get_col_charset( $wpdb->posts, 'post_content' );
|
||||
@ -976,7 +976,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21212
|
||||
*/
|
||||
function data_table_collation_check() {
|
||||
public function data_table_collation_check() {
|
||||
$table_name = 'table_collation_check';
|
||||
$data = array(
|
||||
array(
|
||||
@ -1034,7 +1034,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::check_safe_collation
|
||||
*/
|
||||
function test_table_collation_check( $create, $expected, $query, $drop, $always_true ) {
|
||||
public function test_table_collation_check( $create, $expected, $query, $drop, $always_true ) {
|
||||
self::$_wpdb->query( $drop );
|
||||
|
||||
self::$_wpdb->query( $create );
|
||||
@ -1053,7 +1053,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
/**
|
||||
* @covers wpdb::strip_invalid_text_for_column
|
||||
*/
|
||||
function test_strip_invalid_text_for_column_bails_if_ascii_input_too_long() {
|
||||
public function test_strip_invalid_text_for_column_bails_if_ascii_input_too_long() {
|
||||
global $wpdb;
|
||||
|
||||
// TEXT column.
|
||||
@ -1070,7 +1070,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::strip_invalid_text_from_query
|
||||
*/
|
||||
function test_strip_invalid_text_from_query_cp1251_is_safe() {
|
||||
public function test_strip_invalid_text_from_query_cp1251_is_safe() {
|
||||
$tablename = 'test_cp1251_query_' . rand_str( 5 );
|
||||
if ( ! self::$_wpdb->query( "CREATE TABLE $tablename ( a VARCHAR(50) ) DEFAULT CHARSET 'cp1251'" ) ) {
|
||||
$this->markTestSkipped( "Test requires the 'cp1251' charset." );
|
||||
@ -1089,7 +1089,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::strip_invalid_text_from_query
|
||||
*/
|
||||
function test_no_db_charset_defined() {
|
||||
public function test_no_db_charset_defined() {
|
||||
$tablename = 'test_cp1251_query_' . rand_str( 5 );
|
||||
if ( ! self::$_wpdb->query( "CREATE TABLE $tablename ( a VARCHAR(50) ) DEFAULT CHARSET 'cp1251'" ) ) {
|
||||
$this->markTestSkipped( "Test requires the 'cp1251' charset." );
|
||||
@ -1113,7 +1113,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers wpdb::set_charset
|
||||
*/
|
||||
function test_set_charset_changes_the_connection_collation() {
|
||||
public function test_set_charset_changes_the_connection_collation() {
|
||||
self::$_wpdb->set_charset( self::$_wpdb->dbh, 'utf8', 'utf8_general_ci' );
|
||||
$results = self::$_wpdb->get_results( "SHOW VARIABLES WHERE Variable_name='collation_connection'" );
|
||||
$this->assertSame( 'utf8_general_ci', $results[0]->Value );
|
||||
|
||||
@ -21,7 +21,7 @@ class Tests_DB_RealEscape extends WP_UnitTestCase {
|
||||
* @param mixed $input The input to escape.
|
||||
* @param string $expected The expected function output.
|
||||
*/
|
||||
function test_real_escape_input_type_handling( $input, $expected ) {
|
||||
public function test_real_escape_input_type_handling( $input, $expected ) {
|
||||
global $wpdb;
|
||||
|
||||
$this->assertSame( $expected, $wpdb->_real_escape( $input ) );
|
||||
|
||||
@ -405,7 +405,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 31869
|
||||
*/
|
||||
function test_truncated_index() {
|
||||
public function test_truncated_index() {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! $wpdb->has_cap( 'utf8mb4' ) ) {
|
||||
@ -445,7 +445,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 36748
|
||||
*/
|
||||
function test_dont_downsize_text_fields() {
|
||||
public function test_dont_downsize_text_fields() {
|
||||
global $wpdb;
|
||||
|
||||
$result = dbDelta(
|
||||
@ -470,7 +470,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 36748
|
||||
*/
|
||||
function test_dont_downsize_blob_fields() {
|
||||
public function test_dont_downsize_blob_fields() {
|
||||
global $wpdb;
|
||||
|
||||
$result = dbDelta(
|
||||
@ -495,7 +495,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 36748
|
||||
*/
|
||||
function test_upsize_text_fields() {
|
||||
public function test_upsize_text_fields() {
|
||||
global $wpdb;
|
||||
|
||||
$result = dbDelta(
|
||||
@ -526,7 +526,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 36748
|
||||
*/
|
||||
function test_upsize_blob_fields() {
|
||||
public function test_upsize_blob_fields() {
|
||||
global $wpdb;
|
||||
|
||||
$result = dbDelta(
|
||||
@ -557,7 +557,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20263
|
||||
*/
|
||||
function test_query_with_backticks_does_not_throw_an_undefined_index_warning() {
|
||||
public function test_query_with_backticks_does_not_throw_an_undefined_index_warning() {
|
||||
global $wpdb;
|
||||
|
||||
$schema = "
|
||||
@ -582,7 +582,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 36948
|
||||
*/
|
||||
function test_spatial_indices() {
|
||||
public function test_spatial_indices() {
|
||||
global $wpdb;
|
||||
|
||||
$db_version = $wpdb->db_version();
|
||||
@ -643,7 +643,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20263
|
||||
*/
|
||||
function test_query_with_backticks_does_not_cause_a_query_to_alter_all_columns_and_indices_to_run_even_if_none_have_changed() {
|
||||
public function test_query_with_backticks_does_not_cause_a_query_to_alter_all_columns_and_indices_to_run_even_if_none_have_changed() {
|
||||
global $wpdb;
|
||||
|
||||
$schema = "
|
||||
@ -672,7 +672,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20263
|
||||
*/
|
||||
function test_index_with_a_reserved_keyword_can_be_created() {
|
||||
public function test_index_with_a_reserved_keyword_can_be_created() {
|
||||
global $wpdb;
|
||||
|
||||
$updates = dbDelta(
|
||||
@ -708,7 +708,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20263
|
||||
*/
|
||||
function test_wp_get_db_schema_does_no_alter_queries_on_existing_install() {
|
||||
public function test_wp_get_db_schema_does_no_alter_queries_on_existing_install() {
|
||||
$updates = dbDelta( wp_get_db_schema() );
|
||||
|
||||
$this->assertEmpty( $updates );
|
||||
@ -717,7 +717,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20263
|
||||
*/
|
||||
function test_key_and_index_and_fulltext_key_and_fulltext_index_and_unique_key_and_unique_index_indicies() {
|
||||
public function test_key_and_index_and_fulltext_key_and_fulltext_index_and_unique_key_and_unique_index_indicies() {
|
||||
global $wpdb;
|
||||
|
||||
$schema = "
|
||||
@ -755,7 +755,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20263
|
||||
*/
|
||||
function test_index_and_key_are_synonyms_and_do_not_recreate_indices() {
|
||||
public function test_index_and_key_are_synonyms_and_do_not_recreate_indices() {
|
||||
global $wpdb;
|
||||
|
||||
$updates = dbDelta(
|
||||
@ -779,7 +779,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20263
|
||||
*/
|
||||
function test_indices_with_prefix_limits_are_created_and_do_not_recreate_indices() {
|
||||
public function test_indices_with_prefix_limits_are_created_and_do_not_recreate_indices() {
|
||||
global $wpdb;
|
||||
|
||||
$schema = "
|
||||
@ -813,7 +813,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34959
|
||||
*/
|
||||
function test_index_col_names_with_order_do_not_recreate_indices() {
|
||||
public function test_index_col_names_with_order_do_not_recreate_indices() {
|
||||
global $wpdb;
|
||||
|
||||
$updates = dbDelta(
|
||||
@ -837,7 +837,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34873
|
||||
*/
|
||||
function test_primary_key_with_single_space_does_not_recreate_index() {
|
||||
public function test_primary_key_with_single_space_does_not_recreate_index() {
|
||||
global $wpdb;
|
||||
|
||||
$updates = dbDelta(
|
||||
@ -861,7 +861,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34869
|
||||
*/
|
||||
function test_index_definitions_with_spaces_do_not_recreate_indices() {
|
||||
public function test_index_definitions_with_spaces_do_not_recreate_indices() {
|
||||
global $wpdb;
|
||||
|
||||
$updates = dbDelta(
|
||||
@ -885,7 +885,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34871
|
||||
*/
|
||||
function test_index_types_are_not_case_sensitive_and_do_not_recreate_indices() {
|
||||
public function test_index_types_are_not_case_sensitive_and_do_not_recreate_indices() {
|
||||
global $wpdb;
|
||||
|
||||
$updates = dbDelta(
|
||||
@ -909,7 +909,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34874
|
||||
*/
|
||||
function test_key_names_are_not_case_sensitive_and_do_not_recreate_indices() {
|
||||
public function test_key_names_are_not_case_sensitive_and_do_not_recreate_indices() {
|
||||
global $wpdb;
|
||||
|
||||
$updates = dbDelta(
|
||||
@ -934,7 +934,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34870
|
||||
*/
|
||||
function test_unchanged_key_lengths_do_not_recreate_index() {
|
||||
public function test_unchanged_key_lengths_do_not_recreate_index() {
|
||||
global $wpdb;
|
||||
|
||||
$updates = dbDelta(
|
||||
@ -959,7 +959,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34870
|
||||
*/
|
||||
function test_changed_key_lengths_do_not_recreate_index() {
|
||||
public function test_changed_key_lengths_do_not_recreate_index() {
|
||||
global $wpdb;
|
||||
|
||||
$updates = dbDelta(
|
||||
@ -1043,7 +1043,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 31679
|
||||
*/
|
||||
function test_column_type_change_with_hyphens_in_name() {
|
||||
public function test_column_type_change_with_hyphens_in_name() {
|
||||
global $wpdb;
|
||||
|
||||
$schema = "
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* @group scripts
|
||||
*/
|
||||
class Tests_Dependencies extends WP_UnitTestCase {
|
||||
function test_add() {
|
||||
public function test_add() {
|
||||
$dep = new WP_Dependencies;
|
||||
|
||||
$this->assertTrue( $dep->add( 'one', '' ) );
|
||||
@ -17,7 +17,7 @@ class Tests_Dependencies extends WP_UnitTestCase {
|
||||
$this->assertFalse( $dep->add( 'one', '' ) );
|
||||
}
|
||||
|
||||
function test_remove() {
|
||||
public function test_remove() {
|
||||
$dep = new WP_Dependencies;
|
||||
|
||||
$this->assertTrue( $dep->add( 'one', '' ) );
|
||||
@ -30,7 +30,7 @@ class Tests_Dependencies extends WP_UnitTestCase {
|
||||
|
||||
}
|
||||
|
||||
function test_enqueue() {
|
||||
public function test_enqueue() {
|
||||
$dep = new WP_Dependencies;
|
||||
|
||||
$this->assertTrue( $dep->add( 'one', '' ) );
|
||||
@ -46,7 +46,7 @@ class Tests_Dependencies extends WP_UnitTestCase {
|
||||
$this->assertTrue( $dep->query( 'two', 'queue' ) );
|
||||
}
|
||||
|
||||
function test_dequeue() {
|
||||
public function test_dequeue() {
|
||||
$dep = new WP_Dependencies;
|
||||
|
||||
$this->assertTrue( $dep->add( 'one', '' ) );
|
||||
@ -66,7 +66,7 @@ class Tests_Dependencies extends WP_UnitTestCase {
|
||||
$this->assertFalse( $dep->query( 'two', 'queue' ) );
|
||||
}
|
||||
|
||||
function test_enqueue_args() {
|
||||
public function test_enqueue_args() {
|
||||
$dep = new WP_Dependencies;
|
||||
|
||||
$this->assertTrue( $dep->add( 'one', '' ) );
|
||||
@ -84,7 +84,7 @@ class Tests_Dependencies extends WP_UnitTestCase {
|
||||
$this->assertSame( 'arg', $dep->args['two'] );
|
||||
}
|
||||
|
||||
function test_dequeue_args() {
|
||||
public function test_dequeue_args() {
|
||||
$dep = new WP_Dependencies;
|
||||
|
||||
$this->assertTrue( $dep->add( 'one', '' ) );
|
||||
@ -111,7 +111,7 @@ class Tests_Dependencies extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21741
|
||||
*/
|
||||
function test_query_and_registered_enqueued() {
|
||||
public function test_query_and_registered_enqueued() {
|
||||
$dep = new WP_Dependencies;
|
||||
|
||||
$this->assertTrue( $dep->add( 'one', '' ) );
|
||||
|
||||
@ -9,7 +9,7 @@ class Tests_Dependencies_jQuery extends WP_UnitTestCase {
|
||||
/**
|
||||
* @covers WP_Scripts::query
|
||||
*/
|
||||
function test_location_of_jquery() {
|
||||
public function test_location_of_jquery() {
|
||||
$scripts = new WP_Scripts;
|
||||
wp_default_scripts( $scripts );
|
||||
|
||||
@ -46,7 +46,7 @@ class Tests_Dependencies_jQuery extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::wp_script_is
|
||||
*/
|
||||
function test_dont_allow_deregister_core_scripts_in_admin() {
|
||||
public function test_dont_allow_deregister_core_scripts_in_admin() {
|
||||
set_current_screen( 'edit.php' );
|
||||
$this->assertTrue( is_admin() );
|
||||
$libraries = array(
|
||||
@ -89,7 +89,7 @@ class Tests_Dependencies_jQuery extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::wp_script_is
|
||||
*/
|
||||
function test_wp_script_is_dep_enqueued() {
|
||||
public function test_wp_script_is_dep_enqueued() {
|
||||
wp_enqueue_script( 'jquery-ui-accordion' );
|
||||
|
||||
$this->assertTrue( wp_script_is( 'jquery', 'enqueued' ) );
|
||||
@ -105,7 +105,7 @@ class Tests_Dependencies_jQuery extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers WP_Scripts::do_items
|
||||
*/
|
||||
function test_jquery_in_footer() {
|
||||
public function test_jquery_in_footer() {
|
||||
$scripts = new WP_Scripts;
|
||||
$scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ) );
|
||||
$scripts->add( 'jquery-core', '/jquery.js', array() );
|
||||
|
||||
@ -14,7 +14,7 @@ class Tests_Dependencies_Scripts extends WP_UnitTestCase {
|
||||
|
||||
protected $wp_scripts_print_translations_output;
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
$this->old_wp_scripts = isset( $GLOBALS['wp_scripts'] ) ? $GLOBALS['wp_scripts'] : null;
|
||||
remove_action( 'wp_default_scripts', 'wp_default_scripts' );
|
||||
@ -34,7 +34,7 @@ JS;
|
||||
$this->wp_scripts_print_translations_output .= "\n";
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$GLOBALS['wp_scripts'] = $this->old_wp_scripts;
|
||||
add_action( 'wp_default_scripts', 'wp_default_scripts' );
|
||||
parent::tear_down();
|
||||
@ -45,7 +45,7 @@ JS;
|
||||
*
|
||||
* @ticket 11315
|
||||
*/
|
||||
function test_wp_enqueue_script() {
|
||||
public function test_wp_enqueue_script() {
|
||||
wp_enqueue_script( 'no-deps-no-version', 'example.com', array() );
|
||||
wp_enqueue_script( 'empty-deps-no-version', 'example.com' );
|
||||
wp_enqueue_script( 'empty-deps-version', 'example.com', array(), 1.2 );
|
||||
@ -66,7 +66,7 @@ JS;
|
||||
/**
|
||||
* @ticket 42804
|
||||
*/
|
||||
function test_wp_enqueue_script_with_html5_support_does_not_contain_type_attribute() {
|
||||
public function test_wp_enqueue_script_with_html5_support_does_not_contain_type_attribute() {
|
||||
add_theme_support( 'html5', array( 'script' ) );
|
||||
|
||||
$GLOBALS['wp_scripts'] = new WP_Scripts();
|
||||
@ -152,7 +152,7 @@ JS;
|
||||
*
|
||||
* @ticket 16024
|
||||
*/
|
||||
function test_wp_script_add_data_with_data_key() {
|
||||
public function test_wp_script_add_data_with_data_key() {
|
||||
// Enqueue and add data.
|
||||
wp_enqueue_script( 'test-only-data', 'example.com', array(), null );
|
||||
wp_script_add_data( 'test-only-data', 'data', 'testing' );
|
||||
@ -171,7 +171,7 @@ JS;
|
||||
*
|
||||
* @ticket 16024
|
||||
*/
|
||||
function test_wp_script_add_data_with_conditional_key() {
|
||||
public function test_wp_script_add_data_with_conditional_key() {
|
||||
// Enqueue and add conditional comments.
|
||||
wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null );
|
||||
wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' );
|
||||
@ -189,7 +189,7 @@ JS;
|
||||
*
|
||||
* @ticket 16024
|
||||
*/
|
||||
function test_wp_script_add_data_with_data_and_conditional_keys() {
|
||||
public function test_wp_script_add_data_with_data_and_conditional_keys() {
|
||||
// Enqueue and add data plus conditional comments for both.
|
||||
wp_enqueue_script( 'test-conditional-with-data', 'example.com', array(), null );
|
||||
wp_script_add_data( 'test-conditional-with-data', 'data', 'testing' );
|
||||
@ -209,7 +209,7 @@ JS;
|
||||
*
|
||||
* @ticket 16024
|
||||
*/
|
||||
function test_wp_script_add_data_with_invalid_key() {
|
||||
public function test_wp_script_add_data_with_invalid_key() {
|
||||
// Enqueue and add an invalid key.
|
||||
wp_enqueue_script( 'test-invalid', 'example.com', array(), null );
|
||||
wp_script_add_data( 'test-invalid', 'invalid', 'testing' );
|
||||
@ -227,7 +227,7 @@ JS;
|
||||
*
|
||||
* @ticket 31126
|
||||
*/
|
||||
function test_wp_register_script() {
|
||||
public function test_wp_register_script() {
|
||||
$this->assertTrue( wp_register_script( 'duplicate-handler', 'http://example.com' ) );
|
||||
$this->assertFalse( wp_register_script( 'duplicate-handler', 'http://example.com' ) );
|
||||
}
|
||||
@ -235,7 +235,7 @@ JS;
|
||||
/**
|
||||
* @ticket 35229
|
||||
*/
|
||||
function test_wp_register_script_with_handle_without_source() {
|
||||
public function test_wp_register_script_with_handle_without_source() {
|
||||
$expected = "<script type='text/javascript' src='http://example.com?ver=1' id='handle-one-js'></script>\n";
|
||||
$expected .= "<script type='text/javascript' src='http://example.com?ver=2' id='handle-two-js'></script>\n";
|
||||
|
||||
@ -251,7 +251,7 @@ JS;
|
||||
/**
|
||||
* @ticket 35643
|
||||
*/
|
||||
function test_wp_enqueue_script_footer_alias() {
|
||||
public function test_wp_enqueue_script_footer_alias() {
|
||||
wp_register_script( 'foo', false, array( 'bar', 'baz' ), '1.0', true );
|
||||
wp_register_script( 'bar', home_url( 'bar.js' ), array(), '1.0', true );
|
||||
wp_register_script( 'baz', home_url( 'baz.js' ), array(), '1.0', true );
|
||||
@ -319,7 +319,7 @@ JS;
|
||||
/**
|
||||
* @ticket 35873
|
||||
*/
|
||||
function test_wp_register_script_with_dependencies_in_head_and_footer() {
|
||||
public function test_wp_register_script_with_dependencies_in_head_and_footer() {
|
||||
wp_register_script( 'parent', '/parent.js', array( 'child-head' ), null, true ); // In footer.
|
||||
wp_register_script( 'child-head', '/child-head.js', array( 'child-footer' ), null, false ); // In head.
|
||||
wp_register_script( 'child-footer', '/child-footer.js', array(), null, true ); // In footer.
|
||||
@ -340,7 +340,7 @@ JS;
|
||||
/**
|
||||
* @ticket 35956
|
||||
*/
|
||||
function test_wp_register_script_with_dependencies_in_head_and_footer_in_reversed_order() {
|
||||
public function test_wp_register_script_with_dependencies_in_head_and_footer_in_reversed_order() {
|
||||
wp_register_script( 'child-head', '/child-head.js', array(), null, false ); // In head.
|
||||
wp_register_script( 'child-footer', '/child-footer.js', array(), null, true ); // In footer.
|
||||
wp_register_script( 'parent', '/parent.js', array( 'child-head', 'child-footer' ), null, true ); // In footer.
|
||||
@ -361,7 +361,7 @@ JS;
|
||||
/**
|
||||
* @ticket 35956
|
||||
*/
|
||||
function test_wp_register_script_with_dependencies_in_head_and_footer_in_reversed_order_and_two_parent_scripts() {
|
||||
public function test_wp_register_script_with_dependencies_in_head_and_footer_in_reversed_order_and_two_parent_scripts() {
|
||||
wp_register_script( 'grandchild-head', '/grandchild-head.js', array(), null, false ); // In head.
|
||||
wp_register_script( 'child-head', '/child-head.js', array(), null, false ); // In head.
|
||||
wp_register_script( 'child-footer', '/child-footer.js', array( 'grandchild-head' ), null, true ); // In footer.
|
||||
@ -392,7 +392,7 @@ JS;
|
||||
/**
|
||||
* @ticket 14853
|
||||
*/
|
||||
function test_wp_add_inline_script_returns_bool() {
|
||||
public function test_wp_add_inline_script_returns_bool() {
|
||||
$this->assertFalse( wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ) );
|
||||
wp_enqueue_script( 'test-example', 'example.com', array(), null );
|
||||
$this->assertTrue( wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ) );
|
||||
@ -401,7 +401,7 @@ JS;
|
||||
/**
|
||||
* @ticket 14853
|
||||
*/
|
||||
function test_wp_add_inline_script_unknown_handle() {
|
||||
public function test_wp_add_inline_script_unknown_handle() {
|
||||
$this->assertFalse( wp_add_inline_script( 'test-invalid', 'console.log("before");', 'before' ) );
|
||||
$this->assertSame( '', get_echo( 'wp_print_scripts' ) );
|
||||
}
|
||||
@ -409,7 +409,7 @@ JS;
|
||||
/**
|
||||
* @ticket 14853
|
||||
*/
|
||||
function test_wp_add_inline_script_before() {
|
||||
public function test_wp_add_inline_script_before() {
|
||||
wp_enqueue_script( 'test-example', 'example.com', array(), null );
|
||||
wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
|
||||
|
||||
@ -422,7 +422,7 @@ JS;
|
||||
/**
|
||||
* @ticket 14853
|
||||
*/
|
||||
function test_wp_add_inline_script_after() {
|
||||
public function test_wp_add_inline_script_after() {
|
||||
wp_enqueue_script( 'test-example', 'example.com', array(), null );
|
||||
wp_add_inline_script( 'test-example', 'console.log("after");' );
|
||||
|
||||
@ -435,7 +435,7 @@ JS;
|
||||
/**
|
||||
* @ticket 14853
|
||||
*/
|
||||
function test_wp_add_inline_script_before_and_after() {
|
||||
public function test_wp_add_inline_script_before_and_after() {
|
||||
wp_enqueue_script( 'test-example', 'example.com', array(), null );
|
||||
wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
|
||||
wp_add_inline_script( 'test-example', 'console.log("after");' );
|
||||
@ -450,7 +450,7 @@ JS;
|
||||
/**
|
||||
* @ticket 44551
|
||||
*/
|
||||
function test_wp_add_inline_script_before_for_handle_without_source() {
|
||||
public function test_wp_add_inline_script_before_for_handle_without_source() {
|
||||
wp_register_script( 'test-example', '' );
|
||||
wp_enqueue_script( 'test-example' );
|
||||
wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
|
||||
@ -463,7 +463,7 @@ JS;
|
||||
/**
|
||||
* @ticket 44551
|
||||
*/
|
||||
function test_wp_add_inline_script_after_for_handle_without_source() {
|
||||
public function test_wp_add_inline_script_after_for_handle_without_source() {
|
||||
wp_register_script( 'test-example', '' );
|
||||
wp_enqueue_script( 'test-example' );
|
||||
wp_add_inline_script( 'test-example', 'console.log("after");' );
|
||||
@ -476,7 +476,7 @@ JS;
|
||||
/**
|
||||
* @ticket 44551
|
||||
*/
|
||||
function test_wp_add_inline_script_before_and_after_for_handle_without_source() {
|
||||
public function test_wp_add_inline_script_before_and_after_for_handle_without_source() {
|
||||
wp_register_script( 'test-example', '' );
|
||||
wp_enqueue_script( 'test-example' );
|
||||
wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
|
||||
@ -491,7 +491,7 @@ JS;
|
||||
/**
|
||||
* @ticket 14853
|
||||
*/
|
||||
function test_wp_add_inline_script_multiple() {
|
||||
public function test_wp_add_inline_script_multiple() {
|
||||
wp_enqueue_script( 'test-example', 'example.com', array(), null );
|
||||
wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
|
||||
wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
|
||||
@ -508,7 +508,7 @@ JS;
|
||||
/**
|
||||
* @ticket 14853
|
||||
*/
|
||||
function test_wp_add_inline_script_localized_data_is_added_first() {
|
||||
public function test_wp_add_inline_script_localized_data_is_added_first() {
|
||||
wp_enqueue_script( 'test-example', 'example.com', array(), null );
|
||||
wp_localize_script( 'test-example', 'testExample', array( 'foo' => 'bar' ) );
|
||||
wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
|
||||
|
||||
@ -12,7 +12,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase {
|
||||
private $old_wp_styles;
|
||||
private $old_wp_scripts;
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
if ( empty( $GLOBALS['wp_styles'] ) ) {
|
||||
@ -37,7 +37,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase {
|
||||
$GLOBALS['wp_scripts']->default_version = get_bloginfo( 'version' );
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$GLOBALS['wp_styles'] = $this->old_wp_styles;
|
||||
$GLOBALS['wp_scripts'] = $this->old_wp_scripts;
|
||||
|
||||
@ -56,7 +56,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 11315
|
||||
*/
|
||||
function test_wp_enqueue_style() {
|
||||
public function test_wp_enqueue_style() {
|
||||
wp_enqueue_style( 'no-deps-no-version', 'example.com' );
|
||||
wp_enqueue_style( 'no-deps-version', 'example.com', array(), 1.2 );
|
||||
wp_enqueue_style( 'no-deps-null-version', 'example.com', array(), null );
|
||||
@ -77,7 +77,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 42804
|
||||
*/
|
||||
function test_wp_enqueue_style_with_html5_support_does_not_contain_type_attribute() {
|
||||
public function test_wp_enqueue_style_with_html5_support_does_not_contain_type_attribute() {
|
||||
add_theme_support( 'html5', array( 'style' ) );
|
||||
|
||||
$GLOBALS['wp_styles'] = new WP_Styles();
|
||||
@ -285,7 +285,7 @@ CSS;
|
||||
*
|
||||
* @ticket 31126
|
||||
*/
|
||||
function test_wp_register_style() {
|
||||
public function test_wp_register_style() {
|
||||
$this->assertTrue( wp_register_style( 'duplicate-handler', 'http://example.com' ) );
|
||||
$this->assertFalse( wp_register_style( 'duplicate-handler', 'http://example.com' ) );
|
||||
}
|
||||
@ -293,7 +293,7 @@ CSS;
|
||||
/**
|
||||
* @ticket 35229
|
||||
*/
|
||||
function test_wp_add_inline_style_for_handle_without_source() {
|
||||
public function test_wp_add_inline_style_for_handle_without_source() {
|
||||
$style = 'a { color: blue; }';
|
||||
|
||||
$expected = "<link rel='stylesheet' id='handle-one-css' href='http://example.com?ver=1' type='text/css' media='all' />\n";
|
||||
@ -316,12 +316,12 @@ CSS;
|
||||
* @ticket 35921
|
||||
* @dataProvider data_styles_with_media
|
||||
*/
|
||||
function test_wp_enqueue_style_with_media( $expected, $media ) {
|
||||
public function test_wp_enqueue_style_with_media( $expected, $media ) {
|
||||
wp_enqueue_style( 'handle', 'http://example.com', array(), 1, $media );
|
||||
$this->assertStringContainsString( $expected, get_echo( 'wp_print_styles' ) );
|
||||
}
|
||||
|
||||
function data_styles_with_media() {
|
||||
public function data_styles_with_media() {
|
||||
return array(
|
||||
array(
|
||||
"media='all'",
|
||||
@ -357,7 +357,7 @@ CSS;
|
||||
*
|
||||
* @covers ::wp_enqueue_style
|
||||
*/
|
||||
function test_block_styles_for_editing_without_theme_support() {
|
||||
public function test_block_styles_for_editing_without_theme_support() {
|
||||
// Confirm we are without theme support by default.
|
||||
$this->assertFalse( current_theme_supports( 'wp-block-styles' ) );
|
||||
|
||||
@ -375,7 +375,7 @@ CSS;
|
||||
*
|
||||
* @covers ::wp_common_block_scripts_and_styles
|
||||
*/
|
||||
function test_block_styles_for_editing_with_theme_support() {
|
||||
public function test_block_styles_for_editing_with_theme_support() {
|
||||
add_theme_support( 'wp-block-styles' );
|
||||
|
||||
wp_default_styles( $GLOBALS['wp_styles'] );
|
||||
@ -393,7 +393,7 @@ CSS;
|
||||
*
|
||||
* @covers ::wp_enqueue_style
|
||||
*/
|
||||
function test_no_block_styles_for_viewing_without_theme_support() {
|
||||
public function test_no_block_styles_for_viewing_without_theme_support() {
|
||||
// Confirm we are without theme support by default.
|
||||
$this->assertFalse( current_theme_supports( 'wp-block-styles' ) );
|
||||
|
||||
@ -411,7 +411,7 @@ CSS;
|
||||
*
|
||||
* @covers ::wp_common_block_scripts_and_styles
|
||||
*/
|
||||
function test_block_styles_for_viewing_with_theme_support() {
|
||||
public function test_block_styles_for_viewing_with_theme_support() {
|
||||
add_theme_support( 'wp-block-styles' );
|
||||
|
||||
wp_default_styles( $GLOBALS['wp_styles'] );
|
||||
@ -428,7 +428,7 @@ CSS;
|
||||
*
|
||||
* @covers ::wp_default_styles
|
||||
*/
|
||||
function test_block_styles_for_viewing_without_split_styles() {
|
||||
public function test_block_styles_for_viewing_without_split_styles() {
|
||||
add_filter( 'should_load_separate_core_block_assets', '__return_false' );
|
||||
wp_default_styles( $GLOBALS['wp_styles'] );
|
||||
|
||||
@ -445,7 +445,7 @@ CSS;
|
||||
*
|
||||
* @covers ::wp_default_styles
|
||||
*/
|
||||
function test_block_styles_for_viewing_with_split_styles() {
|
||||
public function test_block_styles_for_viewing_with_split_styles() {
|
||||
add_filter( 'should_load_separate_core_block_assets', '__return_true' );
|
||||
wp_default_styles( $GLOBALS['wp_styles'] );
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
*/
|
||||
class Tests_Functions_wpSanitizeScriptAttributes extends WP_UnitTestCase {
|
||||
|
||||
function test_sanitize_script_attributes_type_set() {
|
||||
public function test_sanitize_script_attributes_type_set() {
|
||||
add_theme_support( 'html5', array( 'script' ) );
|
||||
|
||||
$this->assertSame(
|
||||
@ -39,7 +39,7 @@ class Tests_Functions_wpSanitizeScriptAttributes extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function test_sanitize_script_attributes_type_not_set() {
|
||||
public function test_sanitize_script_attributes_type_not_set() {
|
||||
add_theme_support( 'html5', array( 'script' ) );
|
||||
|
||||
$this->assertSame(
|
||||
@ -68,7 +68,7 @@ class Tests_Functions_wpSanitizeScriptAttributes extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
|
||||
function test_sanitize_script_attributes_no_attributes() {
|
||||
public function test_sanitize_script_attributes_no_attributes() {
|
||||
add_theme_support( 'html5', array( 'script' ) );
|
||||
|
||||
$this->assertSame(
|
||||
@ -79,7 +79,7 @@ class Tests_Functions_wpSanitizeScriptAttributes extends WP_UnitTestCase {
|
||||
remove_theme_support( 'html5' );
|
||||
}
|
||||
|
||||
function test_sanitize_script_attributes_relative_src() {
|
||||
public function test_sanitize_script_attributes_relative_src() {
|
||||
add_theme_support( 'html5', array( 'script' ) );
|
||||
|
||||
$this->assertSame(
|
||||
@ -97,7 +97,7 @@ class Tests_Functions_wpSanitizeScriptAttributes extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
|
||||
function test_sanitize_script_attributes_only_false_boolean_attributes() {
|
||||
public function test_sanitize_script_attributes_only_false_boolean_attributes() {
|
||||
add_theme_support( 'html5', array( 'script' ) );
|
||||
|
||||
$this->assertSame(
|
||||
@ -113,7 +113,7 @@ class Tests_Functions_wpSanitizeScriptAttributes extends WP_UnitTestCase {
|
||||
remove_theme_support( 'html5' );
|
||||
}
|
||||
|
||||
function test_sanitize_script_attributes_only_true_boolean_attributes() {
|
||||
public function test_sanitize_script_attributes_only_true_boolean_attributes() {
|
||||
add_theme_support( 'html5', array( 'script' ) );
|
||||
|
||||
$this->assertSame(
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
*/
|
||||
class Tests_Functions_wpScriptTag extends WP_UnitTestCase {
|
||||
|
||||
function get_script_tag_type_set() {
|
||||
public function get_script_tag_type_set() {
|
||||
add_theme_support( 'html5', array( 'script' ) );
|
||||
|
||||
$this->assertSame(
|
||||
@ -41,7 +41,7 @@ class Tests_Functions_wpScriptTag extends WP_UnitTestCase {
|
||||
/**
|
||||
* @covers ::wp_get_script_tag
|
||||
*/
|
||||
function test_get_script_tag_type_not_set() {
|
||||
public function test_get_script_tag_type_not_set() {
|
||||
add_theme_support( 'html5', array( 'script' ) );
|
||||
|
||||
$this->assertSame(
|
||||
@ -61,7 +61,7 @@ class Tests_Functions_wpScriptTag extends WP_UnitTestCase {
|
||||
/**
|
||||
* @covers ::wp_print_script_tag
|
||||
*/
|
||||
function test_print_script_tag_prints_get_script_tag() {
|
||||
public function test_print_script_tag_prints_get_script_tag() {
|
||||
add_filter(
|
||||
'wp_script_attributes',
|
||||
static function ( $attributes ) {
|
||||
|
||||
@ -9,7 +9,7 @@ class Tests_External_HTTP_Basic extends WP_UnitTestCase {
|
||||
* @covers ::wp_remote_retrieve_response_code
|
||||
* @covers ::wp_remote_retrieve_body
|
||||
*/
|
||||
function test_readme() {
|
||||
public function test_readme() {
|
||||
// This test is designed to only run on trunk/master.
|
||||
$this->skipOnAutomatedBranches();
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ class Tests_Feed_Atom extends WP_UnitTestCase {
|
||||
/**
|
||||
* This is a bit of a hack used to buffer feed content.
|
||||
*/
|
||||
function do_atom() {
|
||||
private function do_atom() {
|
||||
ob_start();
|
||||
// Nasty hack! In the future it would better to leverage do_feed( 'atom' ).
|
||||
global $post;
|
||||
@ -85,7 +85,7 @@ class Tests_Feed_Atom extends WP_UnitTestCase {
|
||||
* Test the <feed> element to make sure its present and populated
|
||||
* with the expected child elements and attributes.
|
||||
*/
|
||||
function test_feed_element() {
|
||||
public function test_feed_element() {
|
||||
$this->go_to( '/?feed=atom' );
|
||||
$feed = $this->do_atom();
|
||||
$xml = xml_to_array( $feed );
|
||||
@ -129,7 +129,7 @@ class Tests_Feed_Atom extends WP_UnitTestCase {
|
||||
/**
|
||||
* Validate <entry> child elements.
|
||||
*/
|
||||
function test_entry_elements() {
|
||||
public function test_entry_elements() {
|
||||
$this->go_to( '/?feed=atom' );
|
||||
$feed = $this->do_atom();
|
||||
$xml = xml_to_array( $feed );
|
||||
@ -209,7 +209,7 @@ class Tests_Feed_Atom extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 33591
|
||||
*/
|
||||
function test_atom_enclosure_with_extended_url_length_type_parsing() {
|
||||
public function test_atom_enclosure_with_extended_url_length_type_parsing() {
|
||||
$enclosures = array(
|
||||
array(
|
||||
// URL, length, type.
|
||||
|
||||
@ -78,7 +78,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
/**
|
||||
* This is a bit of a hack used to buffer feed content.
|
||||
*/
|
||||
function do_rss2() {
|
||||
private function do_rss2() {
|
||||
ob_start();
|
||||
// Nasty hack! In the future it would better to leverage do_feed( 'rss2' ).
|
||||
global $post;
|
||||
@ -97,7 +97,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
* Test the <rss> element to make sure its present and populated
|
||||
* with the expected child elements and attributes.
|
||||
*/
|
||||
function test_rss_element() {
|
||||
public function test_rss_element() {
|
||||
$this->go_to( '/?feed=rss2' );
|
||||
$feed = $this->do_rss2();
|
||||
$xml = xml_to_array( $feed );
|
||||
@ -122,7 +122,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function test_channel_element() {
|
||||
public function test_channel_element() {
|
||||
$this->go_to( '/?feed=rss2' );
|
||||
$feed = $this->do_rss2();
|
||||
$xml = xml_to_array( $feed );
|
||||
@ -152,7 +152,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 39141
|
||||
*/
|
||||
function test_channel_pubdate_element_translated() {
|
||||
public function test_channel_pubdate_element_translated() {
|
||||
$original_locale = $GLOBALS['wp_locale'];
|
||||
/* @var WP_Locale $locale */
|
||||
$locale = clone $GLOBALS['wp_locale'];
|
||||
@ -175,7 +175,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
$this->assertStringNotContainsString( 'Tue_Translated', $pubdate[0]['content'] );
|
||||
}
|
||||
|
||||
function test_item_elements() {
|
||||
public function test_item_elements() {
|
||||
$this->go_to( '/?feed=rss2' );
|
||||
$feed = $this->do_rss2();
|
||||
$xml = xml_to_array( $feed );
|
||||
@ -266,7 +266,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 9134
|
||||
*/
|
||||
function test_items_comments_closed() {
|
||||
public function test_items_comments_closed() {
|
||||
add_filter( 'comments_open', '__return_false' );
|
||||
|
||||
$this->go_to( '/?feed=rss2' );
|
||||
@ -301,7 +301,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 30210
|
||||
*/
|
||||
function test_valid_home_feed_endpoint() {
|
||||
public function test_valid_home_feed_endpoint() {
|
||||
// An example of a valid home feed endpoint.
|
||||
$this->go_to( 'feed/' );
|
||||
|
||||
@ -329,7 +329,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 30210
|
||||
*/
|
||||
function test_valid_taxonomy_feed_endpoint() {
|
||||
public function test_valid_taxonomy_feed_endpoint() {
|
||||
// An example of an valid taxonomy feed endpoint.
|
||||
$this->go_to( 'category/foo/feed/' );
|
||||
|
||||
@ -357,7 +357,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 30210
|
||||
*/
|
||||
function test_valid_main_comment_feed_endpoint() {
|
||||
public function test_valid_main_comment_feed_endpoint() {
|
||||
// Generate a bunch of comments.
|
||||
foreach ( self::$posts as $post ) {
|
||||
self::factory()->comment->create_post_comments( $post, 3 );
|
||||
@ -390,7 +390,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 30210
|
||||
*/
|
||||
function test_valid_archive_feed_endpoint() {
|
||||
public function test_valid_archive_feed_endpoint() {
|
||||
// An example of an valid date archive feed endpoint.
|
||||
$this->go_to( '2003/05/27/feed/' );
|
||||
|
||||
@ -418,7 +418,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 30210
|
||||
*/
|
||||
function test_valid_single_post_comment_feed_endpoint() {
|
||||
public function test_valid_single_post_comment_feed_endpoint() {
|
||||
// An example of an valid date archive feed endpoint.
|
||||
$this->go_to( get_post_comments_feed_link( self::$posts[0] ) );
|
||||
|
||||
@ -446,7 +446,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 30210
|
||||
*/
|
||||
function test_valid_search_feed_endpoint() {
|
||||
public function test_valid_search_feed_endpoint() {
|
||||
// An example of an valid search feed endpoint.
|
||||
$this->go_to( '?s=Lorem&feed=rss' );
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
*/
|
||||
class Tests_File extends WP_UnitTestCase {
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
$this->dir = untrailingslashit( get_temp_dir() );
|
||||
@ -17,7 +17,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
* @group plugins
|
||||
* @group themes
|
||||
*/
|
||||
function test_get_file_data() {
|
||||
public function test_get_file_data() {
|
||||
$theme_headers = array(
|
||||
'Name' => 'Theme Name',
|
||||
'ThemeURI' => 'Theme URI',
|
||||
@ -48,7 +48,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
* @group plugins
|
||||
* @group themes
|
||||
*/
|
||||
function test_get_file_data_with_cr_line_endings() {
|
||||
public function test_get_file_data_with_cr_line_endings() {
|
||||
$headers = array(
|
||||
'SomeHeader' => 'Some Header',
|
||||
'Description' => 'Description',
|
||||
@ -72,7 +72,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
* @group plugins
|
||||
* @group themes
|
||||
*/
|
||||
function test_get_file_data_with_php_open_tag_prefix() {
|
||||
public function test_get_file_data_with_php_open_tag_prefix() {
|
||||
$headers = array(
|
||||
'TemplateName' => 'Template Name',
|
||||
);
|
||||
@ -87,7 +87,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function is_unique_writable_file( $path, $filename ) {
|
||||
private function is_unique_writable_file( $path, $filename ) {
|
||||
$fullpath = $path . DIRECTORY_SEPARATOR . $filename;
|
||||
|
||||
$fp = fopen( $fullpath, 'x' );
|
||||
@ -110,7 +110,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function test_unique_filename_is_valid() {
|
||||
public function test_unique_filename_is_valid() {
|
||||
// Make sure it produces a valid, writable, unique filename.
|
||||
$filename = wp_unique_filename( $this->dir, __FUNCTION__ . '.txt' );
|
||||
|
||||
@ -119,7 +119,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
unlink( $this->dir . DIRECTORY_SEPARATOR . $filename );
|
||||
}
|
||||
|
||||
function test_unique_filename_is_unique() {
|
||||
public function test_unique_filename_is_unique() {
|
||||
// Make sure it produces two unique filenames.
|
||||
$name = __FUNCTION__;
|
||||
|
||||
@ -135,7 +135,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
unlink( $this->dir . DIRECTORY_SEPARATOR . $filename2 );
|
||||
}
|
||||
|
||||
function test_unique_filename_is_sanitized() {
|
||||
public function test_unique_filename_is_sanitized() {
|
||||
$name = __FUNCTION__;
|
||||
$filename = wp_unique_filename( $this->dir, $name . $this->badchars . '.txt' );
|
||||
|
||||
@ -147,7 +147,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
unlink( $this->dir . DIRECTORY_SEPARATOR . $filename );
|
||||
}
|
||||
|
||||
function test_unique_filename_with_slashes() {
|
||||
public function test_unique_filename_with_slashes() {
|
||||
$name = __FUNCTION__;
|
||||
// "foo/foo.txt"
|
||||
$filename = wp_unique_filename( $this->dir, $name . '/' . $name . '.txt' );
|
||||
@ -160,7 +160,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
unlink( $this->dir . DIRECTORY_SEPARATOR . $filename );
|
||||
}
|
||||
|
||||
function test_unique_filename_multiple_ext() {
|
||||
public function test_unique_filename_multiple_ext() {
|
||||
$name = __FUNCTION__;
|
||||
$filename = wp_unique_filename( $this->dir, $name . '.php.txt' );
|
||||
|
||||
@ -172,7 +172,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
unlink( $this->dir . DIRECTORY_SEPARATOR . $filename );
|
||||
}
|
||||
|
||||
function test_unique_filename_no_ext() {
|
||||
public function test_unique_filename_no_ext() {
|
||||
$name = __FUNCTION__;
|
||||
$filename = wp_unique_filename( $this->dir, $name );
|
||||
|
||||
@ -186,13 +186,13 @@ class Tests_File extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data_wp_tempnam_filenames
|
||||
*/
|
||||
function test_wp_tempnam( $case ) {
|
||||
public function test_wp_tempnam( $case ) {
|
||||
$file = wp_tempnam( $case );
|
||||
unlink( $file );
|
||||
|
||||
$this->assertNotEmpty( basename( basename( $file, '.tmp' ), '.zip' ) );
|
||||
}
|
||||
function data_wp_tempnam_filenames() {
|
||||
public function data_wp_tempnam_filenames() {
|
||||
return array(
|
||||
array( '0.zip' ),
|
||||
array( '0.1.2.3.zip' ),
|
||||
@ -206,7 +206,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 47186
|
||||
*/
|
||||
function test_file_signature_functions_as_expected() {
|
||||
public function test_file_signature_functions_as_expected() {
|
||||
$file = wp_tempnam();
|
||||
file_put_contents( $file, 'WordPress' );
|
||||
|
||||
@ -239,7 +239,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 47186
|
||||
*/
|
||||
function test_file_signature_expected_failure() {
|
||||
public function test_file_signature_expected_failure() {
|
||||
$file = wp_tempnam();
|
||||
file_put_contents( $file, 'WordPress' );
|
||||
|
||||
@ -256,7 +256,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
$this->assertSame( 'signature_verification_failed', $verify->get_error_code() );
|
||||
}
|
||||
|
||||
function filter_trust_plus85Tq_key( $keys ) {
|
||||
public function filter_trust_plus85Tq_key( $keys ) {
|
||||
// A static once-off key used to verify verify_file_signature() works as expected.
|
||||
$keys[] = '+85TqMhxQVAYVW4BSCVkJQvZH4q7z8I9lePbvngvf7A=';
|
||||
|
||||
|
||||
@ -4,14 +4,14 @@
|
||||
* This class is designed to make use of MockFS, a Virtual in-memory filesystem compatible with WP_Filesystem
|
||||
*/
|
||||
abstract class WP_Filesystem_UnitTestCase extends WP_UnitTestCase {
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
add_filter( 'filesystem_method_file', array( $this, 'filter_abstraction_file' ) );
|
||||
add_filter( 'filesystem_method', array( $this, 'filter_fs_method' ) );
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
global $wp_filesystem;
|
||||
remove_filter( 'filesystem_method_file', array( $this, 'filter_abstraction_file' ) );
|
||||
remove_filter( 'filesystem_method', array( $this, 'filter_fs_method' ) );
|
||||
@ -20,14 +20,14 @@ abstract class WP_Filesystem_UnitTestCase extends WP_UnitTestCase {
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
function filter_fs_method( $method ) {
|
||||
public function filter_fs_method( $method ) {
|
||||
return 'MockFS';
|
||||
}
|
||||
function filter_abstraction_file( $file ) {
|
||||
public function filter_abstraction_file( $file ) {
|
||||
return dirname( dirname( __DIR__ ) ) . '/includes/mock-fs.php';
|
||||
}
|
||||
|
||||
function test_is_MockFS_sane() {
|
||||
public function test_is_MockFS_sane() {
|
||||
global $wp_filesystem;
|
||||
$this->assertInstanceOf( 'WP_Filesystem_MockFS', $wp_filesystem );
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ require_once __DIR__ . '/base.php';
|
||||
*/
|
||||
class WP_Filesystem_Find_Folder_Test extends WP_Filesystem_UnitTestCase {
|
||||
|
||||
function test_ftp_has_root_access() {
|
||||
public function test_ftp_has_root_access() {
|
||||
global $wp_filesystem;
|
||||
$fs = $wp_filesystem;
|
||||
$fs->init(
|
||||
@ -27,7 +27,7 @@ class WP_Filesystem_Find_Folder_Test extends WP_Filesystem_UnitTestCase {
|
||||
|
||||
}
|
||||
|
||||
function test_sibling_wordpress_in_subdir() {
|
||||
public function test_sibling_wordpress_in_subdir() {
|
||||
global $wp_filesystem;
|
||||
$fs = $wp_filesystem;
|
||||
$fs->init(
|
||||
@ -57,7 +57,7 @@ class WP_Filesystem_Find_Folder_Test extends WP_Filesystem_UnitTestCase {
|
||||
* example.com at /
|
||||
* wp.example.com at /wp.example.com/wordpress/
|
||||
*/
|
||||
function test_subdir_of_another() {
|
||||
public function test_subdir_of_another() {
|
||||
global $wp_filesystem;
|
||||
$fs = $wp_filesystem;
|
||||
$fs->init(
|
||||
@ -84,7 +84,7 @@ class WP_Filesystem_Find_Folder_Test extends WP_Filesystem_UnitTestCase {
|
||||
*
|
||||
* @ticket 20934
|
||||
*/
|
||||
function test_multiple_tokens_in_path1() {
|
||||
public function test_multiple_tokens_in_path1() {
|
||||
global $wp_filesystem;
|
||||
$fs = $wp_filesystem;
|
||||
$fs->init(
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
*/
|
||||
class Tests_Filters extends WP_UnitTestCase {
|
||||
|
||||
function test_simple_filter() {
|
||||
public function test_simple_filter() {
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
@ -25,7 +25,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$this->assertSame( array( $val ), $args );
|
||||
}
|
||||
|
||||
function test_remove_filter() {
|
||||
public function test_remove_filter() {
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
@ -45,7 +45,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
|
||||
}
|
||||
|
||||
function test_has_filter() {
|
||||
public function test_has_filter() {
|
||||
$tag = __FUNCTION__;
|
||||
$func = __FUNCTION__ . '_func';
|
||||
|
||||
@ -60,7 +60,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
// One tag with multiple filters.
|
||||
function test_multiple_filters() {
|
||||
public function test_multiple_filters() {
|
||||
$a1 = new MockAction();
|
||||
$a2 = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
@ -77,7 +77,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$this->assertSame( 1, $a2->get_call_count() );
|
||||
}
|
||||
|
||||
function test_filter_args_1() {
|
||||
public function test_filter_args_1() {
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
@ -92,7 +92,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$this->assertSame( array( $val, $arg1 ), array_pop( $argsvar ) );
|
||||
}
|
||||
|
||||
function test_filter_args_2() {
|
||||
public function test_filter_args_2() {
|
||||
$a1 = new MockAction();
|
||||
$a2 = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
@ -117,7 +117,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$this->assertSame( array( $val ), array_pop( $argsvar2 ) );
|
||||
}
|
||||
|
||||
function test_filter_priority() {
|
||||
public function test_filter_priority() {
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
@ -148,7 +148,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$this->assertSame( $expected, $a->get_events() );
|
||||
}
|
||||
|
||||
function test_all_filter() {
|
||||
public function test_all_filter() {
|
||||
$a = new MockAction();
|
||||
$tag1 = __FUNCTION__ . '_1';
|
||||
$tag2 = __FUNCTION__ . '_2';
|
||||
@ -172,7 +172,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
|
||||
}
|
||||
|
||||
function test_remove_all_filter() {
|
||||
public function test_remove_all_filter() {
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
@ -199,7 +199,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20920
|
||||
*/
|
||||
function test_remove_all_filters_should_respect_the_priority_argument() {
|
||||
public function test_remove_all_filters_should_respect_the_priority_argument() {
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
@ -218,7 +218,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 9886
|
||||
*/
|
||||
function test_filter_ref_array() {
|
||||
public function test_filter_ref_array() {
|
||||
$obj = new stdClass();
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
@ -237,7 +237,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 12723
|
||||
*/
|
||||
function test_filter_ref_array_result() {
|
||||
public function test_filter_ref_array_result() {
|
||||
$obj = new stdClass();
|
||||
$a = new MockAction();
|
||||
$b = new MockAction();
|
||||
@ -264,15 +264,10 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
|
||||
}
|
||||
|
||||
function _self_removal( $tag ) {
|
||||
remove_action( $tag, array( $this, '_self_removal' ), 10, 1 );
|
||||
return $tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 29070
|
||||
*/
|
||||
function test_has_filter_after_remove_all_filters() {
|
||||
public function test_has_filter_after_remove_all_filters() {
|
||||
$a = new MockAction();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
@ -353,14 +348,14 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
* @ticket 39007
|
||||
*/
|
||||
public function test_current_priority() {
|
||||
add_action( 'test_current_priority', array( $this, '_current_priority_action' ), 99 );
|
||||
add_action( 'test_current_priority', array( $this, 'current_priority_action' ), 99 );
|
||||
do_action( 'test_current_priority' );
|
||||
remove_action( 'test_current_priority', array( $this, '_current_priority_action' ), 99 );
|
||||
remove_action( 'test_current_priority', array( $this, 'current_priority_action' ), 99 );
|
||||
|
||||
$this->assertSame( 99, $this->current_priority );
|
||||
}
|
||||
|
||||
public function _current_priority_action() {
|
||||
public function current_priority_action() {
|
||||
global $wp_filter;
|
||||
$this->current_priority = $wp_filter[ current_filter() ]->current_priority();
|
||||
}
|
||||
@ -369,14 +364,14 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
* @ticket 39007
|
||||
*/
|
||||
public function test_other_priority() {
|
||||
add_action( 'test_current_priority', array( $this, '_other_priority_action' ), 99 );
|
||||
add_action( 'test_current_priority', array( $this, 'other_priority_action' ), 99 );
|
||||
do_action( 'test_current_priority' );
|
||||
remove_action( 'test_current_priority', array( $this, '_other_priority_action' ), 99 );
|
||||
remove_action( 'test_current_priority', array( $this, 'other_priority_action' ), 99 );
|
||||
|
||||
$this->assertFalse( $this->current_priority );
|
||||
}
|
||||
|
||||
public function _other_priority_action() {
|
||||
public function other_priority_action() {
|
||||
global $wp_filter;
|
||||
$this->current_priority = $wp_filter['the_content']->current_priority();
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
*/
|
||||
class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
|
||||
function nestable_tags() {
|
||||
public function nestable_tags() {
|
||||
return array(
|
||||
array( 'blockquote' ),
|
||||
array( 'div' ),
|
||||
@ -16,7 +16,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
// This is a complete(?) listing of valid single/self-closing tags.
|
||||
function single_tags() {
|
||||
public function single_tags() {
|
||||
return array(
|
||||
array( 'area' ),
|
||||
array( 'base' ),
|
||||
@ -37,7 +37,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function supported_traditional_tag_names() {
|
||||
public function supported_traditional_tag_names() {
|
||||
return array(
|
||||
array( 'a' ),
|
||||
array( 'div' ),
|
||||
@ -49,7 +49,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function supported_custom_element_tag_names() {
|
||||
public function supported_custom_element_tag_names() {
|
||||
return array(
|
||||
array( 'custom-element' ),
|
||||
array( 'my-custom-element' ),
|
||||
@ -61,7 +61,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function invalid_tag_names() {
|
||||
public function invalid_tag_names() {
|
||||
return array(
|
||||
array( '<0-day>inside', '<0-day>inside' ), // Can't start with a number - handled by the "<3" fix.
|
||||
array( '<UPPERCASE-TAG>inside', '<UPPERCASE-TAG>inside' ), // Custom elements cannot be uppercase.
|
||||
@ -73,7 +73,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
*
|
||||
* @see https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name
|
||||
*/
|
||||
function unsupported_valid_tag_names() {
|
||||
public function unsupported_valid_tag_names() {
|
||||
return array(
|
||||
// We don't allow ending in a dash.
|
||||
array( '<what->inside' ),
|
||||
@ -133,7 +133,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
*
|
||||
* @see https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name
|
||||
*/
|
||||
function supported_invalid_tag_names() {
|
||||
public function supported_invalid_tag_names() {
|
||||
return array(
|
||||
// Reserved names for custom elements.
|
||||
array( 'annotation-xml' ),
|
||||
@ -151,7 +151,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
* @ticket 47014
|
||||
* @dataProvider supported_traditional_tag_names
|
||||
*/
|
||||
function test_detects_traditional_tag_names( $tag ) {
|
||||
public function test_detects_traditional_tag_names( $tag ) {
|
||||
$normalized = strtolower( $tag );
|
||||
|
||||
$this->assertSame( "<$normalized>inside</$normalized>", balanceTags( "<$tag>inside", true ) );
|
||||
@ -161,7 +161,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
* @ticket 47014
|
||||
* @dataProvider supported_custom_element_tag_names
|
||||
*/
|
||||
function test_detects_supported_custom_element_tag_names( $tag ) {
|
||||
public function test_detects_supported_custom_element_tag_names( $tag ) {
|
||||
$this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
* @ticket 47014
|
||||
* @dataProvider invalid_tag_names
|
||||
*/
|
||||
function test_ignores_invalid_tag_names( $input, $output ) {
|
||||
public function test_ignores_invalid_tag_names( $input, $output ) {
|
||||
$this->assertSame( $output, balanceTags( $input, true ) );
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
* @ticket 47014
|
||||
* @dataProvider unsupported_valid_tag_names
|
||||
*/
|
||||
function test_ignores_unsupported_custom_tag_names( $tag ) {
|
||||
public function test_ignores_unsupported_custom_tag_names( $tag ) {
|
||||
$this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) );
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
* @ticket 47014
|
||||
* @dataProvider supported_invalid_tag_names
|
||||
*/
|
||||
function test_detects_supported_invalid_tag_names( $tag ) {
|
||||
public function test_detects_supported_invalid_tag_names( $tag ) {
|
||||
$this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
* @ticket 1597
|
||||
* @dataProvider single_tags
|
||||
*/
|
||||
function test_selfcloses_unclosed_known_single_tags( $tag ) {
|
||||
public function test_selfcloses_unclosed_known_single_tags( $tag ) {
|
||||
$this->assertSame( "<$tag />", balanceTags( "<$tag>", true ) );
|
||||
}
|
||||
|
||||
@ -206,14 +206,14 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
* @ticket 1597
|
||||
* @dataProvider single_tags
|
||||
*/
|
||||
function test_selfcloses_known_single_tags_having_closing_tag( $tag ) {
|
||||
public function test_selfcloses_known_single_tags_having_closing_tag( $tag ) {
|
||||
$this->assertSame( "<$tag />", balanceTags( "<$tag></$tag>", true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 1597
|
||||
*/
|
||||
function test_closes_unknown_single_tags_with_closing_tag() {
|
||||
public function test_closes_unknown_single_tags_with_closing_tag() {
|
||||
|
||||
$inputs = array(
|
||||
'<strong/>',
|
||||
@ -236,7 +236,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_closes_unclosed_single_tags_having_attributes() {
|
||||
public function test_closes_unclosed_single_tags_having_attributes() {
|
||||
$inputs = array(
|
||||
'<img src="/images/example.png">',
|
||||
'<input type="text" name="example">',
|
||||
@ -251,7 +251,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_allows_validly_closed_single_tags() {
|
||||
public function test_allows_validly_closed_single_tags() {
|
||||
$inputs = array(
|
||||
'<br />',
|
||||
'<hr />',
|
||||
@ -267,7 +267,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider nestable_tags
|
||||
*/
|
||||
function test_balances_nestable_tags( $tag ) {
|
||||
public function test_balances_nestable_tags( $tag ) {
|
||||
$inputs = array(
|
||||
"<$tag>Test<$tag>Test</$tag>",
|
||||
"<$tag><$tag>Test",
|
||||
@ -284,7 +284,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_allows_adjacent_nestable_tags() {
|
||||
public function test_allows_adjacent_nestable_tags() {
|
||||
$inputs = array(
|
||||
'<blockquote><blockquote>Example quote</blockquote></blockquote>',
|
||||
'<div class="container"><div>This is allowed></div></div>',
|
||||
@ -301,12 +301,12 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20401
|
||||
*/
|
||||
function test_allows_immediately_nested_object_tags() {
|
||||
public function test_allows_immediately_nested_object_tags() {
|
||||
$object = '<object id="obj1"><param name="param1"/><object id="obj2"><param name="param2"/></object></object>';
|
||||
$this->assertSame( $object, balanceTags( $object, true ) );
|
||||
}
|
||||
|
||||
function test_balances_nested_non_nestable_tags() {
|
||||
public function test_balances_nested_non_nestable_tags() {
|
||||
$inputs = array(
|
||||
'<b><b>This is bold</b></b>',
|
||||
'<b>Some text here <b>This is bold</b></b>',
|
||||
@ -321,7 +321,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_fixes_improper_closing_tag_sequence() {
|
||||
public function test_fixes_improper_closing_tag_sequence() {
|
||||
$inputs = array(
|
||||
'<p>Here is a <strong class="part">bold <em>and emphasis</p></em></strong>',
|
||||
'<ul><li>Aaa</li><li>Bbb</ul></li>',
|
||||
@ -336,7 +336,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_adds_missing_closing_tags() {
|
||||
public function test_adds_missing_closing_tags() {
|
||||
$inputs = array(
|
||||
'<b><i>Test</b>',
|
||||
'<p>Test',
|
||||
@ -357,7 +357,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_removes_extraneous_closing_tags() {
|
||||
public function test_removes_extraneous_closing_tags() {
|
||||
$inputs = array(
|
||||
'<b>Test</b></b>',
|
||||
'<div>Test</div></div><div>Test',
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* @group formatting
|
||||
*/
|
||||
class Tests_Formatting_CapitalPDangit extends WP_UnitTestCase {
|
||||
function test_esc_attr_quotes() {
|
||||
public function test_esc_attr_quotes() {
|
||||
global $wp_current_filter;
|
||||
$this->assertSame( 'Something about WordPress', capital_P_dangit( 'Something about Wordpress' ) );
|
||||
$this->assertSame( 'Something about (WordPress', capital_P_dangit( 'Something about (Wordpress' ) );
|
||||
|
||||
@ -9,14 +9,14 @@
|
||||
*/
|
||||
class Tests_Formatting_CleanPre extends WP_UnitTestCase {
|
||||
|
||||
function test_removes_self_closing_br_with_space() {
|
||||
public function test_removes_self_closing_br_with_space() {
|
||||
$source = 'a b c\n<br />sldfj<br />';
|
||||
$res = 'a b c\nsldfj';
|
||||
|
||||
$this->assertSame( $res, clean_pre( $source ) );
|
||||
}
|
||||
|
||||
function test_removes_self_closing_br_without_space() {
|
||||
public function test_removes_self_closing_br_without_space() {
|
||||
$source = 'a b c\n<br/>sldfj<br/>';
|
||||
$res = 'a b c\nsldfj';
|
||||
$this->assertSame( $res, clean_pre( $source ) );
|
||||
@ -26,13 +26,13 @@ class Tests_Formatting_CleanPre extends WP_UnitTestCase {
|
||||
// <br> is changed to <br /> elsewhere. Left in because
|
||||
// that replacement shouldn't happen (what if you want
|
||||
// HTML 4 output?).
|
||||
function test_removes_html_br() {
|
||||
public function test_removes_html_br() {
|
||||
$source = 'a b c\n<br>sldfj<br>';
|
||||
$res = 'a b c\nsldfj';
|
||||
$this->assertSame( $res, clean_pre( $source ) );
|
||||
}
|
||||
|
||||
function test_removes_p() {
|
||||
public function test_removes_p() {
|
||||
$source = "<p>isn't this exciting!</p><p>oh indeed!</p>";
|
||||
$res = "\nisn't this exciting!\noh indeed!";
|
||||
$this->assertSame( $res, clean_pre( $source ) );
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* @group formatting
|
||||
*/
|
||||
class Tests_Formatting_ConvertInvalidEntities extends WP_UnitTestCase {
|
||||
function test_replaces_windows1252_entities_with_unicode_ones() {
|
||||
public function test_replaces_windows1252_entities_with_unicode_ones() {
|
||||
$input = '‚ƒ„…†‡ˆ‰Š‹Œ‘’“”•–—˜™š›œŸ';
|
||||
$output = '‚ƒ„…†‡ˆ‰Š‹Œ‘’“”•–—˜™š›œŸ';
|
||||
$this->assertSame( $output, convert_invalid_entities( $input ) );
|
||||
@ -13,13 +13,13 @@ class Tests_Formatting_ConvertInvalidEntities extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20503
|
||||
*/
|
||||
function test_replaces_latin_letter_z_with_caron() {
|
||||
public function test_replaces_latin_letter_z_with_caron() {
|
||||
$input = 'Žž';
|
||||
$output = 'Žž';
|
||||
$this->assertSame( $output, convert_invalid_entities( $input ) );
|
||||
}
|
||||
|
||||
function test_escapes_lone_ampersands() {
|
||||
public function test_escapes_lone_ampersands() {
|
||||
$this->assertSame( 'at&t', convert_chars( 'at&t' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ class Tests_Formatting_ConvertSmilies extends WP_UnitTestCase {
|
||||
* Basic Validation Test to confirm that smilies are converted to image
|
||||
* when use_smilies = 1 and not when use_smilies = 0
|
||||
*/
|
||||
function test_convert_standard_smilies( $in_txt, $converted_txt ) {
|
||||
public function test_convert_standard_smilies( $in_txt, $converted_txt ) {
|
||||
// Standard smilies, use_smilies: ON.
|
||||
update_option( 'use_smilies', 1 );
|
||||
|
||||
@ -91,7 +91,7 @@ class Tests_Formatting_ConvertSmilies extends WP_UnitTestCase {
|
||||
*
|
||||
* Validate Custom Smilies are converted to images when use_smilies = 1
|
||||
*/
|
||||
function test_convert_custom_smilies( $in_txt, $converted_txt ) {
|
||||
public function test_convert_custom_smilies( $in_txt, $converted_txt ) {
|
||||
global $wpsmiliestrans;
|
||||
|
||||
// Custom smilies, use_smilies: ON.
|
||||
@ -299,7 +299,7 @@ class Tests_Formatting_ConvertSmilies extends WP_UnitTestCase {
|
||||
* @ticket 22692
|
||||
* @dataProvider get_spaces_around_smilies
|
||||
*/
|
||||
function test_spaces_around_smilies( $in_txt, $converted_txt ) {
|
||||
public function test_spaces_around_smilies( $in_txt, $converted_txt ) {
|
||||
// Standard smilies, use_smilies: ON.
|
||||
update_option( 'use_smilies', 1 );
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 20328
|
||||
*/
|
||||
function test_get_date_from_gmt_outside_of_dst() {
|
||||
public function test_get_date_from_gmt_outside_of_dst() {
|
||||
update_option( 'timezone_string', 'Europe/London' );
|
||||
$local = '2012-01-01 12:34:56';
|
||||
$gmt = $local;
|
||||
@ -23,7 +23,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 20328
|
||||
*/
|
||||
function test_get_date_from_gmt_during_dst() {
|
||||
public function test_get_date_from_gmt_during_dst() {
|
||||
update_option( 'timezone_string', 'Europe/London' );
|
||||
$gmt = '2012-06-01 12:34:56';
|
||||
$local = '2012-06-01 13:34:56';
|
||||
@ -33,7 +33,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20328
|
||||
*/
|
||||
function test_get_gmt_from_date_outside_of_dst() {
|
||||
public function test_get_gmt_from_date_outside_of_dst() {
|
||||
update_option( 'timezone_string', 'Europe/London' );
|
||||
$local = '2012-01-01 12:34:56';
|
||||
$gmt = $local;
|
||||
@ -43,7 +43,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20328
|
||||
*/
|
||||
function test_get_gmt_from_date_during_dst() {
|
||||
public function test_get_gmt_from_date_during_dst() {
|
||||
update_option( 'timezone_string', 'Europe/London' );
|
||||
$local = '2012-06-01 12:34:56';
|
||||
$gmt = '2012-06-01 11:34:56';
|
||||
@ -53,7 +53,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34279
|
||||
*/
|
||||
function test_get_date_and_time_from_gmt_no_timezone() {
|
||||
public function test_get_date_and_time_from_gmt_no_timezone() {
|
||||
$local = '2012-01-01 12:34:56';
|
||||
$gmt = $local;
|
||||
$this->assertSame( $gmt, get_date_from_gmt( $local ) );
|
||||
@ -62,7 +62,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34279
|
||||
*/
|
||||
function test_get_gmt_from_date_no_timezone() {
|
||||
public function test_get_gmt_from_date_no_timezone() {
|
||||
$gmt = '2012-12-01 00:00:00';
|
||||
$date = '2012-12-01';
|
||||
$this->assertSame( $gmt, get_gmt_from_date( $date ) );
|
||||
@ -71,7 +71,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34279
|
||||
*/
|
||||
function test_get_gmt_from_date_short_date() {
|
||||
public function test_get_gmt_from_date_short_date() {
|
||||
update_option( 'timezone_string', 'Europe/London' );
|
||||
$local = '2012-12-01';
|
||||
$gmt = '2012-12-01 00:00:00';
|
||||
@ -81,7 +81,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34279
|
||||
*/
|
||||
function test_get_gmt_from_date_string_date() {
|
||||
public function test_get_gmt_from_date_string_date() {
|
||||
update_option( 'timezone_string', 'Europe/London' );
|
||||
$local = 'now';
|
||||
$gmt = gmdate( 'Y-m-d H:i:s' );
|
||||
@ -91,7 +91,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 34279
|
||||
*/
|
||||
function test_get_gmt_from_date_string_date_no_timezone() {
|
||||
public function test_get_gmt_from_date_string_date_no_timezone() {
|
||||
$local = 'now';
|
||||
$gmt = gmdate( 'Y-m-d H:i:s' );
|
||||
$this->assertEqualsWithDelta( strtotime( $gmt ), strtotime( get_gmt_from_date( $local ) ), 2, 'The dates should be equal' );
|
||||
|
||||
@ -7,7 +7,7 @@ class Tests_Formatting_Ent2ncr extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider entities
|
||||
*/
|
||||
function test_converts_named_entities_to_numeric_character_references( $entity, $ncr ) {
|
||||
public function test_converts_named_entities_to_numeric_character_references( $entity, $ncr ) {
|
||||
$entity = '&' . $entity . ';';
|
||||
$ncr = '&#' . $ncr . ';';
|
||||
$this->assertSame( $ncr, ent2ncr( $entity ), $entity );
|
||||
@ -17,7 +17,7 @@ class Tests_Formatting_Ent2ncr extends WP_UnitTestCase {
|
||||
* Get test data from files, one test per line.
|
||||
* Comments start with "###".
|
||||
*/
|
||||
function entities() {
|
||||
public function entities() {
|
||||
$entities = file( DIR_TESTDATA . '/formatting/entities.txt' );
|
||||
$data_provided = array();
|
||||
foreach ( $entities as $line ) {
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* @group formatting
|
||||
*/
|
||||
class Tests_Formatting_EscAttr extends WP_UnitTestCase {
|
||||
function test_esc_attr_quotes() {
|
||||
public function test_esc_attr_quotes() {
|
||||
$attr = '"double quotes"';
|
||||
$this->assertSame( '"double quotes"', esc_attr( $attr ) );
|
||||
|
||||
@ -25,7 +25,7 @@ class Tests_Formatting_EscAttr extends WP_UnitTestCase {
|
||||
$this->assertSame( ''mixed' "quotes"', esc_attr( esc_attr( $attr ) ) );
|
||||
}
|
||||
|
||||
function test_esc_attr_amp() {
|
||||
public function test_esc_attr_amp() {
|
||||
$out = esc_attr( 'foo & bar &baz; ' );
|
||||
$this->assertSame( 'foo & bar &baz; ', $out );
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* @group formatting
|
||||
*/
|
||||
class Tests_Formatting_EscHtml extends WP_UnitTestCase {
|
||||
function test_esc_html_basics() {
|
||||
public function test_esc_html_basics() {
|
||||
// Simple string.
|
||||
$html = 'The quick brown fox.';
|
||||
$this->assertSame( $html, esc_html( $html ) );
|
||||
@ -20,19 +20,19 @@ class Tests_Formatting_EscHtml extends WP_UnitTestCase {
|
||||
$this->assertSame( $escaped, esc_html( $html ) );
|
||||
}
|
||||
|
||||
function test_escapes_ampersands() {
|
||||
public function test_escapes_ampersands() {
|
||||
$source = 'penn & teller & at&t';
|
||||
$res = 'penn & teller & at&t';
|
||||
$this->assertSame( $res, esc_html( $source ) );
|
||||
}
|
||||
|
||||
function test_escapes_greater_and_less_than() {
|
||||
public function test_escapes_greater_and_less_than() {
|
||||
$source = 'this > that < that <randomhtml />';
|
||||
$res = 'this > that < that <randomhtml />';
|
||||
$this->assertSame( $res, esc_html( $source ) );
|
||||
}
|
||||
|
||||
function test_ignores_existing_entities() {
|
||||
public function test_ignores_existing_entities() {
|
||||
$source = '& £ " &';
|
||||
$res = '& £ " &';
|
||||
$this->assertSame( $res, esc_html( $source ) );
|
||||
|
||||
@ -4,41 +4,41 @@
|
||||
* @group formatting
|
||||
*/
|
||||
class Tests_Formatting_EscJs extends WP_UnitTestCase {
|
||||
function test_js_escape_simple() {
|
||||
public function test_js_escape_simple() {
|
||||
$out = esc_js( 'foo bar baz();' );
|
||||
$this->assertSame( 'foo bar baz();', $out );
|
||||
}
|
||||
|
||||
function test_js_escape_quotes() {
|
||||
public function test_js_escape_quotes() {
|
||||
$out = esc_js( 'foo "bar" \'baz\'' );
|
||||
// Does it make any sense to change " into "? Why not \"?
|
||||
$this->assertSame( "foo "bar" \'baz\'", $out );
|
||||
}
|
||||
|
||||
function test_js_escape_backslash() {
|
||||
public function test_js_escape_backslash() {
|
||||
$bs = '\\';
|
||||
$out = esc_js( 'foo ' . $bs . 't bar ' . $bs . $bs . ' baz' );
|
||||
// \t becomes t - bug?
|
||||
$this->assertSame( 'foo t bar ' . $bs . $bs . ' baz', $out );
|
||||
}
|
||||
|
||||
function test_js_escape_amp() {
|
||||
public function test_js_escape_amp() {
|
||||
$out = esc_js( 'foo & bar &baz; ' );
|
||||
$this->assertSame( 'foo & bar &baz; ', $out );
|
||||
}
|
||||
|
||||
function test_js_escape_quote_entity() {
|
||||
public function test_js_escape_quote_entity() {
|
||||
$out = esc_js( 'foo ' bar ' baz &' );
|
||||
$this->assertSame( "foo \\' bar \\' baz &", $out );
|
||||
}
|
||||
|
||||
function test_js_no_carriage_return() {
|
||||
public function test_js_no_carriage_return() {
|
||||
$out = esc_js( "foo\rbar\nbaz\r" );
|
||||
// \r is stripped.
|
||||
$this->assertSame( "foobar\\nbaz", $out );
|
||||
}
|
||||
|
||||
function test_js_escape_rn() {
|
||||
public function test_js_escape_rn() {
|
||||
$out = esc_js( "foo\r\nbar\nbaz\r\n" );
|
||||
// \r is stripped.
|
||||
$this->assertSame( "foo\\nbar\\nbaz\\n", $out );
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
*/
|
||||
class Tests_Formatting_EscTextarea extends WP_UnitTestCase {
|
||||
|
||||
function _charset_iso_8859_1() {
|
||||
public function charset_iso_8859_1() {
|
||||
return 'iso-8859-1';
|
||||
}
|
||||
|
||||
@ -13,24 +13,24 @@ class Tests_Formatting_EscTextarea extends WP_UnitTestCase {
|
||||
* Only fails in PHP 5.4 onwards
|
||||
* @ticket 23688
|
||||
*/
|
||||
function test_esc_textarea_charset_iso_8859_1() {
|
||||
add_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) );
|
||||
public function test_esc_textarea_charset_iso_8859_1() {
|
||||
add_filter( 'pre_option_blog_charset', array( $this, 'charset_iso_8859_1' ) );
|
||||
$iso8859_1 = 'Fran' . chr( 135 ) . 'ais';
|
||||
$this->assertSame( $iso8859_1, esc_textarea( $iso8859_1 ) );
|
||||
remove_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) );
|
||||
remove_filter( 'pre_option_blog_charset', array( $this, 'charset_iso_8859_1' ) );
|
||||
}
|
||||
|
||||
function _charset_utf_8() {
|
||||
public function charset_utf_8() {
|
||||
return 'UTF-8';
|
||||
}
|
||||
|
||||
/*
|
||||
* @ticket 23688
|
||||
*/
|
||||
function test_esc_textarea_charset_utf_8() {
|
||||
add_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) );
|
||||
public function test_esc_textarea_charset_utf_8() {
|
||||
add_filter( 'pre_option_blog_charset', array( $this, 'charset_utf_8' ) );
|
||||
$utf8 = 'Fran' . chr( 195 ) . chr( 167 ) . 'ais';
|
||||
$this->assertSame( $utf8, esc_textarea( $utf8 ) );
|
||||
remove_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) );
|
||||
remove_filter( 'pre_option_blog_charset', array( $this, 'charset_utf_8' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 23605
|
||||
*/
|
||||
function test_spaces() {
|
||||
public function test_spaces() {
|
||||
$this->assertSame( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr WordPress' ) );
|
||||
$this->assertSame( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr%20WordPress' ) );
|
||||
$this->assertSame( 'http://example.com/Mr%20%20WordPress', esc_url( 'http://example.com/Mr%20%20WordPress' ) );
|
||||
@ -19,7 +19,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
|
||||
$this->assertSame( 'http://example.com/?foo=one%20two%20three&bar=four', esc_url( 'http://example.com/?foo=one%20two%20three&bar=four' ) );
|
||||
}
|
||||
|
||||
function test_bad_characters() {
|
||||
public function test_bad_characters() {
|
||||
$this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0Ago' ) );
|
||||
$this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0ago' ) );
|
||||
$this->assertSame( 'http://example.com/watchthecarriagereturngo', esc_url( 'http://example.com/watchthecarriagereturn%0Dgo' ) );
|
||||
@ -33,14 +33,14 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
|
||||
$this->assertSame( 'http://example.com/', esc_url( 'http://example.com/%0%0%0ADa' ) );
|
||||
}
|
||||
|
||||
function test_relative() {
|
||||
public function test_relative() {
|
||||
$this->assertSame( '/example.php', esc_url( '/example.php' ) );
|
||||
$this->assertSame( 'example.php', esc_url( 'example.php' ) );
|
||||
$this->assertSame( '#fragment', esc_url( '#fragment' ) );
|
||||
$this->assertSame( '?foo=bar', esc_url( '?foo=bar' ) );
|
||||
}
|
||||
|
||||
function test_all_url_parts() {
|
||||
public function test_all_url_parts() {
|
||||
$url = 'https://user:pass@host.example.com:1234/path;p=1?query=2&r[]=3#fragment';
|
||||
|
||||
$this->assertSame(
|
||||
@ -60,7 +60,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
|
||||
$this->assertSame( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', esc_url( $url ) );
|
||||
}
|
||||
|
||||
function test_bare() {
|
||||
public function test_bare() {
|
||||
$this->assertSame( 'http://example.com?foo', esc_url( 'example.com?foo' ) );
|
||||
$this->assertSame( 'http://example.com', esc_url( 'example.com' ) );
|
||||
$this->assertSame( 'http://localhost', esc_url( 'localhost' ) );
|
||||
@ -68,7 +68,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
|
||||
$this->assertSame( 'http://баба.org/баба', esc_url( 'баба.org/баба' ) );
|
||||
}
|
||||
|
||||
function test_encoding() {
|
||||
public function test_encoding() {
|
||||
$this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) );
|
||||
$this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) );
|
||||
$this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) );
|
||||
@ -81,7 +81,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
|
||||
$this->assertSame( "http://example.com?url={$param}", esc_url( "http://example.com?url={$param}" ) );
|
||||
}
|
||||
|
||||
function test_protocol() {
|
||||
public function test_protocol() {
|
||||
$this->assertSame( 'http://example.com', esc_url( 'http://example.com' ) );
|
||||
$this->assertSame( '', esc_url( 'nasty://example.com/' ) );
|
||||
$this->assertSame(
|
||||
@ -146,23 +146,23 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 23187
|
||||
*/
|
||||
function test_protocol_case() {
|
||||
public function test_protocol_case() {
|
||||
$this->assertSame( 'http://example.com', esc_url( 'HTTP://example.com' ) );
|
||||
$this->assertSame( 'http://example.com', esc_url( 'Http://example.com' ) );
|
||||
}
|
||||
|
||||
function test_display_extras() {
|
||||
public function test_display_extras() {
|
||||
$this->assertSame( 'http://example.com/'quoted'', esc_url( 'http://example.com/\'quoted\'' ) );
|
||||
$this->assertSame( 'http://example.com/\'quoted\'', esc_url( 'http://example.com/\'quoted\'', null, 'notdisplay' ) );
|
||||
}
|
||||
|
||||
function test_non_ascii() {
|
||||
public function test_non_ascii() {
|
||||
$this->assertSame( 'http://example.org/баба', esc_url( 'http://example.org/баба' ) );
|
||||
$this->assertSame( 'http://баба.org/баба', esc_url( 'http://баба.org/баба' ) );
|
||||
$this->assertSame( 'http://müller.com/', esc_url( 'http://müller.com/' ) );
|
||||
}
|
||||
|
||||
function test_feed() {
|
||||
public function test_feed() {
|
||||
$this->assertSame( '', esc_url( 'feed:javascript:alert(1)' ) );
|
||||
$this->assertSame( '', esc_url( 'feed:javascript:feed:alert(1)' ) );
|
||||
$this->assertSame( '', esc_url( 'feed:feed:javascript:alert(1)' ) );
|
||||
@ -173,7 +173,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 16859
|
||||
*/
|
||||
function test_square_brackets() {
|
||||
public function test_square_brackets() {
|
||||
$this->assertSame( '/example.php?one%5B%5D=two', esc_url( '/example.php?one[]=two' ) );
|
||||
$this->assertSame( '?foo%5Bbar%5D=baz', esc_url( '?foo[bar]=baz' ) );
|
||||
$this->assertSame( '//example.com/?foo%5Bbar%5D=baz', esc_url( '//example.com/?foo[bar]=baz' ) );
|
||||
@ -188,7 +188,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
|
||||
/**
|
||||
* Courtesy of http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding
|
||||
*/
|
||||
function test_reserved_characters() {
|
||||
public function test_reserved_characters() {
|
||||
$url = "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,==?/?:@-._~!$%27()*+,;=/?:@-._~!$%27()*+,;==#/?:@-._~!$&'()*+,;=";
|
||||
$this->assertSame( $url, esc_url_raw( $url ) );
|
||||
}
|
||||
@ -196,14 +196,14 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21974
|
||||
*/
|
||||
function test_protocol_relative_with_colon() {
|
||||
public function test_protocol_relative_with_colon() {
|
||||
$this->assertSame( '//example.com/foo?foo=abc:def', esc_url( '//example.com/foo?foo=abc:def' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 31632
|
||||
*/
|
||||
function test_mailto_with_newline() {
|
||||
public function test_mailto_with_newline() {
|
||||
$body = <<<EOT
|
||||
Hi there,
|
||||
|
||||
@ -218,7 +218,7 @@ EOT;
|
||||
/**
|
||||
* @ticket 31632
|
||||
*/
|
||||
function test_mailto_in_http_url_with_newline() {
|
||||
public function test_mailto_in_http_url_with_newline() {
|
||||
$body = <<<EOT
|
||||
Hi there,
|
||||
|
||||
@ -233,7 +233,7 @@ EOT;
|
||||
/**
|
||||
* @ticket 23605
|
||||
*/
|
||||
function test_mailto_with_spaces() {
|
||||
public function test_mailto_with_spaces() {
|
||||
$body = 'Hi there, I thought you might want to sign up for this newsletter';
|
||||
|
||||
$email_link = 'mailto:?body=' . $body;
|
||||
@ -244,14 +244,14 @@ EOT;
|
||||
/**
|
||||
* @ticket 28015
|
||||
*/
|
||||
function test_invalid_charaters() {
|
||||
public function test_invalid_charaters() {
|
||||
$this->assertEmpty( esc_url_raw( '"^<>{}`' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34202
|
||||
*/
|
||||
function test_ipv6_hosts() {
|
||||
public function test_ipv6_hosts() {
|
||||
$this->assertSame( '//[::127.0.0.1]', esc_url( '//[::127.0.0.1]' ) );
|
||||
$this->assertSame( 'http://[::FFFF::127.0.0.1]', esc_url( 'http://[::FFFF::127.0.0.1]' ) );
|
||||
$this->assertSame( 'http://[::127.0.0.1]', esc_url( 'http://[::127.0.0.1]' ) );
|
||||
|
||||
@ -50,7 +50,7 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase {
|
||||
*
|
||||
* @return string Block output.
|
||||
*/
|
||||
function render_fake_block() {
|
||||
public function render_fake_block() {
|
||||
return get_the_excerpt( self::$post_id );
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase {
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
self::$post_id = $this->factory()->post->create(
|
||||
array(
|
||||
@ -80,7 +80,7 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase {
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$registry = WP_Block_Type_Registry::get_instance();
|
||||
$registry->unregister( 'core/fake' );
|
||||
|
||||
@ -92,7 +92,7 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 46133
|
||||
*/
|
||||
function test_excerpt_remove_blocks() {
|
||||
public function test_excerpt_remove_blocks() {
|
||||
// Simple dynamic block..
|
||||
$content = '<!-- wp:core/block /-->';
|
||||
|
||||
@ -117,7 +117,7 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 46133
|
||||
*/
|
||||
function test_excerpt_infinite_loop() {
|
||||
public function test_excerpt_infinite_loop() {
|
||||
$query = new WP_Query(
|
||||
array(
|
||||
'post__in' => array( self::$post_id ),
|
||||
|
||||
@ -9,7 +9,7 @@ class Tests_Formatting_GetBloginfo extends WP_UnitTestCase {
|
||||
* @dataProvider locales
|
||||
* @ticket 28303
|
||||
*/
|
||||
function test_get_bloginfo_language( $test_locale, $expected ) {
|
||||
public function test_get_bloginfo_language( $test_locale, $expected ) {
|
||||
global $locale;
|
||||
|
||||
$old_locale = $locale;
|
||||
@ -20,7 +20,7 @@ class Tests_Formatting_GetBloginfo extends WP_UnitTestCase {
|
||||
$locale = $old_locale;
|
||||
}
|
||||
|
||||
function locales() {
|
||||
public function locales() {
|
||||
return array(
|
||||
// Locale, language code.
|
||||
array( 'en_US', 'en-US' ),
|
||||
@ -36,7 +36,7 @@ class Tests_Formatting_GetBloginfo extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 27942
|
||||
*/
|
||||
function test_bloginfo_sanitize_option() {
|
||||
public function test_bloginfo_sanitize_option() {
|
||||
$old_values = array(
|
||||
'blogname' => get_option( 'blogname' ),
|
||||
'blogdescription' => get_option( 'blogdescription' ),
|
||||
|
||||
@ -44,7 +44,7 @@ class Tests_Formatting_GetUrlInContent extends WP_UnitTestCase {
|
||||
*
|
||||
* @dataProvider get_input_output
|
||||
*/
|
||||
function test_get_url_in_content( $in_str, $exp_str ) {
|
||||
public function test_get_url_in_content( $in_str, $exp_str ) {
|
||||
$this->assertSame( $exp_str, get_url_in_content( $in_str ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,13 +11,13 @@ class Tests_Formatting_HumanTimeDiff extends WP_UnitTestCase {
|
||||
* @ticket 38773
|
||||
* @dataProvider data_test_human_time_diff
|
||||
*/
|
||||
function test_human_time_diff( $expected, $stopdate, $message ) {
|
||||
public function test_human_time_diff( $expected, $stopdate, $message ) {
|
||||
$startdate = new DateTime( '2016-01-01 12:00:00' );
|
||||
$this->assertSame( $expected, human_time_diff( $startdate->format( 'U' ), $stopdate->format( 'U' ) ), $message );
|
||||
}
|
||||
|
||||
// Data for test_human_time_diff.
|
||||
function data_test_human_time_diff() {
|
||||
public function data_test_human_time_diff() {
|
||||
return array(
|
||||
array(
|
||||
'37 seconds',
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* @group formatting
|
||||
*/
|
||||
class Tests_Formatting_IsEmail extends WP_UnitTestCase {
|
||||
function test_returns_the_email_address_if_it_is_valid() {
|
||||
public function test_returns_the_email_address_if_it_is_valid() {
|
||||
$data = array(
|
||||
'bob@example.com',
|
||||
'phil@example.info',
|
||||
@ -18,7 +18,7 @@ class Tests_Formatting_IsEmail extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_returns_false_if_given_an_invalid_email_address() {
|
||||
public function test_returns_false_if_given_an_invalid_email_address() {
|
||||
$data = array(
|
||||
'khaaaaaaaaaaaaaaan!',
|
||||
'http://bob.example.com/',
|
||||
|
||||
@ -8,7 +8,7 @@ class Tests_Formatting_LikeEscape extends WP_UnitTestCase {
|
||||
* @ticket 10041
|
||||
* @expectedDeprecated like_escape
|
||||
*/
|
||||
function test_like_escape() {
|
||||
public function test_like_escape() {
|
||||
|
||||
$inputs = array(
|
||||
'howdy%', // Single percent.
|
||||
|
||||
@ -96,7 +96,7 @@ class Tests_Formatting_LinksAddTarget extends WP_UnitTestCase {
|
||||
*
|
||||
* @dataProvider get_input_output
|
||||
*/
|
||||
function test_normalize_whitespace( $content, $target, $tags, $exp_str ) {
|
||||
public function test_normalize_whitespace( $content, $target, $tags, $exp_str ) {
|
||||
if ( true === is_null( $target ) ) {
|
||||
$this->assertSame( $exp_str, links_add_target( $content ) );
|
||||
} elseif ( true === is_null( $tags ) ) {
|
||||
|
||||
@ -4,12 +4,12 @@
|
||||
* @group formatting
|
||||
*/
|
||||
class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
function test_mailto_xss() {
|
||||
public function test_mailto_xss() {
|
||||
$in = 'testzzz@"STYLE="behavior:url(\'#default#time2\')"onBegin="alert(\'refresh-XSS\')"';
|
||||
$this->assertSame( $in, make_clickable( $in ) );
|
||||
}
|
||||
|
||||
function test_valid_mailto() {
|
||||
public function test_valid_mailto() {
|
||||
$valid_emails = array(
|
||||
'foo@example.com',
|
||||
'foo.bar@example.com',
|
||||
@ -22,7 +22,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_invalid_mailto() {
|
||||
public function test_invalid_mailto() {
|
||||
$invalid_emails = array(
|
||||
'foo',
|
||||
'foo@',
|
||||
@ -40,7 +40,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
* Tests that make_clickable() will not link trailing periods, commas,
|
||||
* and (semi-)colons in URLs with protocol (i.e. http://wordpress.org).
|
||||
*/
|
||||
function test_strip_trailing_with_protocol() {
|
||||
public function test_strip_trailing_with_protocol() {
|
||||
$urls_before = array(
|
||||
'http://wordpress.org/hello.html',
|
||||
'There was a spoon named http://wordpress.org. Alice!',
|
||||
@ -67,7 +67,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
* Tests that make_clickable() will not link trailing periods, commas,
|
||||
* and (semi-)colons in URLs with protocol (i.e. http://wordpress.org).
|
||||
*/
|
||||
function test_strip_trailing_with_protocol_nothing_afterwards() {
|
||||
public function test_strip_trailing_with_protocol_nothing_afterwards() {
|
||||
$urls_before = array(
|
||||
'http://wordpress.org/hello.html',
|
||||
'There was a spoon named http://wordpress.org.',
|
||||
@ -96,7 +96,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
* Tests that make_clickable() will not link trailing periods, commas,
|
||||
* and (semi-)colons in URLs without protocol (i.e. www.wordpress.org).
|
||||
*/
|
||||
function test_strip_trailing_without_protocol() {
|
||||
public function test_strip_trailing_without_protocol() {
|
||||
$urls_before = array(
|
||||
'www.wordpress.org',
|
||||
'There was a spoon named www.wordpress.org. Alice!',
|
||||
@ -123,7 +123,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
* Tests that make_clickable() will not link trailing periods, commas,
|
||||
* and (semi-)colons in URLs without protocol (i.e. www.wordpress.org).
|
||||
*/
|
||||
function test_strip_trailing_without_protocol_nothing_afterwards() {
|
||||
public function test_strip_trailing_without_protocol_nothing_afterwards() {
|
||||
$urls_before = array(
|
||||
'www.wordpress.org',
|
||||
'There was a spoon named www.wordpress.org.',
|
||||
@ -149,7 +149,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 4570
|
||||
*/
|
||||
function test_iri() {
|
||||
public function test_iri() {
|
||||
$urls_before = array(
|
||||
'http://www.詹姆斯.com/',
|
||||
'http://bg.wikipedia.org/Баба',
|
||||
@ -168,7 +168,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 10990
|
||||
*/
|
||||
function test_brackets_in_urls() {
|
||||
public function test_brackets_in_urls() {
|
||||
$urls_before = array(
|
||||
'http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)',
|
||||
'(http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software))',
|
||||
@ -207,7 +207,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 11211
|
||||
*/
|
||||
function test_real_world_examples() {
|
||||
public function test_real_world_examples() {
|
||||
$urls_before = array(
|
||||
'Example: WordPress, test (some text), I love example.com (http://example.org), it is brilliant',
|
||||
'Example: WordPress, test (some text), I love example.com (http://example.com), it is brilliant',
|
||||
@ -228,7 +228,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 14993
|
||||
*/
|
||||
function test_twitter_hash_bang() {
|
||||
public function test_twitter_hash_bang() {
|
||||
$urls_before = array(
|
||||
'http://twitter.com/#!/wordpress/status/25907440233',
|
||||
'This is a really good tweet http://twitter.com/#!/wordpress/status/25907440233 !',
|
||||
@ -244,7 +244,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_wrapped_in_angles() {
|
||||
public function test_wrapped_in_angles() {
|
||||
$before = array(
|
||||
'URL wrapped in angle brackets <http://example.com/>',
|
||||
'URL wrapped in angle brackets with padding < http://example.com/ >',
|
||||
@ -260,7 +260,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_preceded_by_punctuation() {
|
||||
public function test_preceded_by_punctuation() {
|
||||
$before = array(
|
||||
'Comma then URL,http://example.com/',
|
||||
'Period then URL.http://example.com/',
|
||||
@ -282,7 +282,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_dont_break_attributes() {
|
||||
public function test_dont_break_attributes() {
|
||||
$urls_before = array(
|
||||
"<img src='http://trunk.domain/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley'>",
|
||||
"(<img src='http://trunk.domain/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley'>)",
|
||||
@ -309,7 +309,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 23756
|
||||
*/
|
||||
function test_no_links_inside_pre_or_code() {
|
||||
public function test_no_links_inside_pre_or_code() {
|
||||
$before = array(
|
||||
'<pre>http://wordpress.org</pre>',
|
||||
'<code>http://wordpress.org</code>',
|
||||
@ -350,7 +350,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 16892
|
||||
*/
|
||||
function test_click_inside_html() {
|
||||
public function test_click_inside_html() {
|
||||
$urls_before = array(
|
||||
'<span>http://example.com</span>',
|
||||
'<p>http://example.com/</p>',
|
||||
@ -364,7 +364,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_no_links_within_links() {
|
||||
public function test_no_links_within_links() {
|
||||
$in = array(
|
||||
'Some text with a link <a href="http://example.com">http://example.com</a>',
|
||||
// '<a href="http://wordpress.org">This is already a link www.wordpress.org</a>', // Fails in 3.3.1 too.
|
||||
@ -377,7 +377,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 16892
|
||||
*/
|
||||
function test_no_segfault() {
|
||||
public function test_no_segfault() {
|
||||
$in = str_repeat( 'http://example.com/2011/03/18/post-title/', 256 );
|
||||
$out = make_clickable( $in );
|
||||
$this->assertSame( $in, $out );
|
||||
@ -386,7 +386,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 19028
|
||||
*/
|
||||
function test_line_break_in_existing_clickable_link() {
|
||||
public function test_line_break_in_existing_clickable_link() {
|
||||
$html = "<a
|
||||
href='mailto:someone@example.com'>someone@example.com</a>";
|
||||
$this->assertSame( $html, make_clickable( $html ) );
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user