Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add PHPCS fixes to tests/phpunit/tests A-B-C-D files.
  • Loading branch information
costdev committed Oct 18, 2021
commit 7f4a1fea3f5dde5348f6434edaa121e7bb41b713
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 @@ -9,7 +9,7 @@ class Tests_Admin_IncludesFile extends WP_UnitTestCase {
/**
* @ticket 20449
*/
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
20 changes: 10 additions & 10 deletions tests/phpunit/tests/admin/includesListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Tests_Admin_IncludesListTable extends WP_UnitTestCase {
*/
protected $table;

function set_up() {
public function set_up() {
parent::set_up();
$this->table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => 'edit-page' ) );
}
Expand Down Expand Up @@ -76,7 +76,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
/**
* @ticket 15459
*/
function test_list_hierarchical_pages_first_page() {
public function test_list_hierarchical_pages_first_page() {
$this->_test_list_hierarchical_page(
array(
'paged' => 1,
Expand All @@ -92,7 +92,7 @@ function test_list_hierarchical_pages_first_page() {
/**
* @ticket 15459
*/
function test_list_hierarchical_pages_second_page() {
public function test_list_hierarchical_pages_second_page() {
$this->_test_list_hierarchical_page(
array(
'paged' => 2,
Expand All @@ -109,7 +109,7 @@ function test_list_hierarchical_pages_second_page() {
/**
* @ticket 15459
*/
function test_search_hierarchical_pages_first_page() {
public function test_search_hierarchical_pages_first_page() {
$this->_test_list_hierarchical_page(
array(
'paged' => 1,
Expand All @@ -126,7 +126,7 @@ function test_search_hierarchical_pages_first_page() {
/**
* @ticket 15459
*/
function test_search_hierarchical_pages_second_page() {
public function test_search_hierarchical_pages_second_page() {
$this->_test_list_hierarchical_page(
array(
'paged' => 2,
Expand All @@ -143,7 +143,7 @@ function test_search_hierarchical_pages_second_page() {
/**
* @ticket 15459
*/
function test_grandchildren_hierarchical_pages_first_page() {
public function test_grandchildren_hierarchical_pages_first_page() {
// Page 6 is the first page with grandchildren.
$this->_test_list_hierarchical_page(
array(
Expand All @@ -162,7 +162,7 @@ function test_grandchildren_hierarchical_pages_first_page() {
/**
* @ticket 15459
*/
function test_grandchildren_hierarchical_pages_second_page() {
public function test_grandchildren_hierarchical_pages_second_page() {
// Page 7 is the second page with grandchildren.
$this->_test_list_hierarchical_page(
array(
Expand Down Expand Up @@ -228,7 +228,7 @@ protected function _test_list_hierarchical_page( array $args, array $expected_id
/**
* @ticket 37407
*/
function test_filter_button_should_not_be_shown_if_there_are_no_posts() {
public function test_filter_button_should_not_be_shown_if_there_are_no_posts() {
// Set post type to a non-existent one.
$this->table->screen->post_type = 'foo';

Expand All @@ -242,7 +242,7 @@ function test_filter_button_should_not_be_shown_if_there_are_no_posts() {
/**
* @ticket 37407
*/
function test_months_dropdown_should_not_be_shown_if_there_are_no_posts() {
public function test_months_dropdown_should_not_be_shown_if_there_are_no_posts() {
// Set post type to a non-existent one.
$this->table->screen->post_type = 'foo';

Expand All @@ -256,7 +256,7 @@ function test_months_dropdown_should_not_be_shown_if_there_are_no_posts() {
/**
* @ticket 37407
*/
function test_category_dropdown_should_not_be_shown_if_there_are_no_posts() {
public function test_category_dropdown_should_not_be_shown_if_there_are_no_posts() {
// Set post type to a non-existent one.
$this->table->screen->post_type = 'foo';

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/admin/includesMisc.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @group admin
*/
class Tests_Admin_IncludesMisc extends WP_UnitTestCase {
function test_shorten_url() {
public function test_shorten_url() {
$tests = array(
'wordpress\.org/about/philosophy'
=> 'wordpress\.org/about/philosophy', // No longer strips slashes.
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
Loading