Coding Standards: Add visibility to methods in tests/phpunit/tests/.

Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods.

Adds a `private` visibility to helper methods within test classes.

Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit.

Props costdev, jrf, hellofromTonya.
Fixes #54177.

git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork
2021-11-04 15:22:47 +00:00
parent 80380cd374
commit 40ac5de838
327 changed files with 3656 additions and 3969 deletions

View File

@@ -29,7 +29,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
$role->add_cap( 'publish_unmapped_meta_caps' );
}
static function tear_down_after_class() {
public static function tear_down_after_class() {
$role = get_role( 'administrator' );
$role->remove_cap( 'publish_mapped_meta_caps' );
$role->remove_cap( 'publish_unmapped_meta_caps' );
@@ -37,7 +37,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
parent::tear_down_after_class();
}
function set_up() {
public function set_up() {
parent::set_up();
register_post_type(
@@ -68,7 +68,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
/**
* @ticket 11863
*/
function test_trashing_a_post_should_add_trashed_suffix_to_post_name() {
public function test_trashing_a_post_should_add_trashed_suffix_to_post_name() {
$trashed_about_page_id = self::factory()->post->create(
array(
'post_type' => 'page',
@@ -99,7 +99,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
/**
* @ticket 11863
*/
function test_trashed_posts_original_post_name_should_be_reassigned_after_untrashing() {
public function test_trashed_posts_original_post_name_should_be_reassigned_after_untrashing() {
$about_page_id = self::factory()->post->create(
array(
'post_type' => 'page',
@@ -116,7 +116,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
/**
* @ticket 11863
*/
function test_creating_a_new_post_should_add_trashed_suffix_to_post_name_of_trashed_posts_with_the_desired_slug() {
public function test_creating_a_new_post_should_add_trashed_suffix_to_post_name_of_trashed_posts_with_the_desired_slug() {
$trashed_about_page_id = self::factory()->post->create(
array(
'post_type' => 'page',
@@ -140,7 +140,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
/**
* @ticket 11863
*/
function test_untrashing_a_post_with_a_stored_desired_post_name_should_get_its_post_name_suffixed_if_another_post_has_taken_the_desired_post_name() {
public function test_untrashing_a_post_with_a_stored_desired_post_name_should_get_its_post_name_suffixed_if_another_post_has_taken_the_desired_post_name() {
$about_page_id = self::factory()->post->create(
array(
'post_type' => 'page',
@@ -174,7 +174,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
* @ticket 23022
* @dataProvider data_various_post_statuses
*/
function test_untrashing_a_post_should_always_restore_it_to_draft_status( $post_status ) {
public function test_untrashing_a_post_should_always_restore_it_to_draft_status( $post_status ) {
$page_id = self::factory()->post->create(
array(
'post_type' => 'page',
@@ -192,7 +192,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
* @ticket 23022
* @dataProvider data_various_post_statuses
*/
function test_wp_untrash_post_status_filter_restores_post_to_correct_status( $post_status ) {
public function test_wp_untrash_post_status_filter_restores_post_to_correct_status( $post_status ) {
add_filter( 'wp_untrash_post_status', 'wp_untrash_post_set_previous_status', 10, 3 );
$page_id = self::factory()->post->create(
@@ -215,7 +215,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
*
* @return array Array of test arguments.
*/
function data_various_post_types() {
public function data_various_post_types() {
return array(
array(
'mapped_meta_caps',
@@ -234,7 +234,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
*
* @return array Array of test arguments.
*/
function data_various_post_statuses() {
public function data_various_post_statuses() {
return array(
array(
'draft',
@@ -257,7 +257,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
* @ticket 42464
* @dataProvider data_various_post_types
*/
function test_contributor_cannot_set_post_slug( $post_type ) {
public function test_contributor_cannot_set_post_slug( $post_type ) {
wp_set_current_user( self::$user_ids['contributor'] );
$post_id = $this->factory()->post->create(
@@ -296,7 +296,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
* @ticket 42464
* @dataProvider data_various_post_types
*/
function test_administrator_can_set_post_slug( $post_type ) {
public function test_administrator_can_set_post_slug( $post_type ) {
wp_set_current_user( self::$user_ids['administrator'] );
$post_id = $this->factory()->post->create(
@@ -337,7 +337,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
*
* @ticket 42464
*/
function test_administrator_cannot_set_post_slug_on_post_type_they_cannot_publish() {
public function test_administrator_cannot_set_post_slug_on_post_type_they_cannot_publish() {
wp_set_current_user( self::$user_ids['administrator'] );
$post_id = $this->factory()->post->create(
@@ -373,7 +373,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
/**
* @ticket 25347
*/
function test_scheduled_post_with_a_past_date_should_be_published() {
public function test_scheduled_post_with_a_past_date_should_be_published() {
$now = new DateTimeImmutable( 'now', new DateTimeZone( 'UTC' ) );