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
+7 -7
View File
@@ -4,29 +4,29 @@
*/
class Tests_Link extends WP_UnitTestCase {
function _get_pagenum_link_cb( $url ) {
public function get_pagenum_link_cb( $url ) {
return $url . '/WooHoo';
}
/**
* @ticket 8847
*/
function test_get_pagenum_link_case_insensitivity() {
public function test_get_pagenum_link_case_insensitivity() {
$old_req_uri = $_SERVER['REQUEST_URI'];
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
add_filter( 'home_url', array( $this, '_get_pagenum_link_cb' ) );
add_filter( 'home_url', array( $this, 'get_pagenum_link_cb' ) );
$_SERVER['REQUEST_URI'] = '/woohoo';
$paged = get_pagenum_link( 2 );
remove_filter( 'home_url', array( $this, '_get_pagenum_link_cb' ) );
remove_filter( 'home_url', array( $this, 'get_pagenum_link_cb' ) );
$this->assertSame( $paged, home_url( '/WooHoo/page/2/' ) );
$_SERVER['REQUEST_URI'] = $old_req_uri;
}
function test_wp_get_shortlink() {
public function test_wp_get_shortlink() {
$post_id = self::factory()->post->create();
$post_id2 = self::factory()->post->create();
@@ -70,7 +70,7 @@ class Tests_Link extends WP_UnitTestCase {
$this->assertSame( home_url( '?p=' . $post_id ), wp_get_shortlink() );
}
function test_wp_get_shortlink_with_page() {
public function test_wp_get_shortlink_with_page() {
$post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
// Basic case.
@@ -85,7 +85,7 @@ class Tests_Link extends WP_UnitTestCase {
/**
* @ticket 26871
*/
function test_wp_get_shortlink_with_home_page() {
public function test_wp_get_shortlink_with_home_page() {
$post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
update_option( 'show_on_front', 'page' );
update_option( 'page_on_front', $post_id );