Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/phpunit/tests/actions/callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/actions/closures.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/admin/includesFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
24 changes: 12 additions & 12 deletions tests/phpunit/tests/admin/includesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static function wpTearDownAfterClass() {
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(
Expand All @@ -35,7 +35,7 @@ function test_get_plugin_data() {
}
}

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' );
Expand Down Expand Up @@ -77,7 +77,7 @@ function test_menu_page_url() {
*
* @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();
Expand Down Expand Up @@ -125,7 +125,7 @@ function test_submenu_position( $position, $expected_position ) {
*
* @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;

Expand Down Expand Up @@ -227,7 +227,7 @@ function test_submenu_helpers_position( $position, $expected_position ) {
* }
* }
*/
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', '' ),
Expand All @@ -249,7 +249,7 @@ function submenus_to_add() {
* }
* }
*/
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.
Expand All @@ -268,7 +268,7 @@ function data_submenu_position() {
*
* @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.
Expand Down Expand Up @@ -300,7 +300,7 @@ function test_position_when_parent_slug_child_slug_are_the_same() {
*
* @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;

Expand All @@ -324,27 +324,27 @@ function test_passing_string_as_position_fires_doing_it_wrong() {
$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 );

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 );
Expand Down
10 changes: 5 additions & 5 deletions tests/phpunit/tests/admin/includesPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
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.
Expand Down Expand Up @@ -76,7 +76,7 @@ function test__wp_translate_postdata_cap_checks_contributor() {
$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.
Expand Down Expand Up @@ -131,7 +131,7 @@ function test__wp_translate_postdata_cap_checks_editor() {
*
* @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 );
Expand Down Expand Up @@ -789,7 +789,7 @@ public function test_post_exists_should_match_nonempty_title_content_and_date()
$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(
Expand Down Expand Up @@ -822,7 +822,7 @@ function test_use_block_editor_for_post() {
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',
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/tests/admin/includesSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function wpTearDownAfterClass() {
* @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;
Expand Down Expand Up @@ -183,7 +183,7 @@ public function data_populate_options() {
* @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;
Expand Down Expand Up @@ -227,7 +227,7 @@ public function data_populate_site_meta() {
* @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;
Expand Down
22 changes: 11 additions & 11 deletions tests/phpunit/tests/admin/includesScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -228,15 +228,15 @@ function test_set_current_screen_with_hook_suffix() {
}
}

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' );
$this->assertSame( $screen->id, 'page' );
$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' );
Expand All @@ -251,7 +251,7 @@ function test_post_type_with_special_suffix_as_hookname() {
$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' );
Expand All @@ -260,7 +260,7 @@ function test_taxonomy_with_special_suffix_as_hookname() {
$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' );
Expand All @@ -275,7 +275,7 @@ function test_post_type_with_edit_prefix() {
$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' );

Expand All @@ -295,7 +295,7 @@ function test_post_type_edit_collisions() {
$this->assertSame( $screen->base, 'post' );
}

function test_help_tabs() {
public function test_help_tabs() {
$tab = __FUNCTION__;
$tab_args = array(
'title' => 'Help!',
Expand Down Expand Up @@ -331,7 +331,7 @@ function test_help_tabs() {
/**
* @ticket 19828
*/
function test_help_tabs_priority() {
public function test_help_tabs_priority() {
$tab_1 = 'tab1';
$tab_1_args = array(
'title' => 'Help!',
Expand Down Expand Up @@ -427,7 +427,7 @@ function test_help_tabs_priority() {
/**
* @ticket 25799
*/
function test_options() {
public function test_options() {
$option = __FUNCTION__;
$option_args = array(
'label' => 'Option',
Expand All @@ -451,7 +451,7 @@ function test_options() {
$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' ) );
Expand Down
30 changes: 15 additions & 15 deletions tests/phpunit/tests/admin/includesTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@
*/
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'] );
parent::tear_down();
}

// 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;
}

Expand All @@ -42,7 +42,7 @@ function _theme_root( $dir ) {
* @expectedDeprecated get_theme
* @expectedDeprecated get_themes
*/
function test_page_templates() {
public function test_page_templates() {
$theme = get_theme( 'Page Template Theme' );
$this->assertNotEmpty( $theme );

Expand Down Expand Up @@ -75,7 +75,7 @@ function test_page_templates() {
/**
* @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 );

Expand All @@ -101,7 +101,7 @@ function test_page_templates_different_post_types() {
/**
* @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 );

Expand Down Expand Up @@ -133,7 +133,7 @@ function test_page_templates_for_post_types_with_trailing_periods() {
/**
* @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 );

Expand Down Expand Up @@ -216,7 +216,7 @@ public function test_get_post_templates_child_theme() {
* @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 );
Expand All @@ -230,7 +230,7 @@ function test_get_theme_featured_list_api() {
* @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 );
}
Expand Down
Loading