mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-09 07:04:34 +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:
@@ -2,7 +2,7 @@
|
||||
|
||||
class Tests_Query extends WP_UnitTestCase {
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
||||
@@ -12,7 +12,7 @@ class Tests_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 24785
|
||||
*/
|
||||
function test_nested_loop_reset_postdata() {
|
||||
public function test_nested_loop_reset_postdata() {
|
||||
$post_id = self::factory()->post->create();
|
||||
$nested_post_id = self::factory()->post->create();
|
||||
|
||||
@@ -32,7 +32,7 @@ class Tests_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 16471
|
||||
*/
|
||||
function test_default_query_var() {
|
||||
public function test_default_query_var() {
|
||||
$query = new WP_Query;
|
||||
$this->assertSame( '', $query->get( 'nonexistent' ) );
|
||||
$this->assertFalse( $query->get( 'nonexistent', false ) );
|
||||
@@ -42,7 +42,7 @@ class Tests_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 25380
|
||||
*/
|
||||
function test_pre_posts_per_page() {
|
||||
public function test_pre_posts_per_page() {
|
||||
self::factory()->post->create_many( 10 );
|
||||
|
||||
add_action( 'pre_get_posts', array( $this, 'filter_posts_per_page' ) );
|
||||
@@ -52,19 +52,19 @@ class Tests_Query extends WP_UnitTestCase {
|
||||
$this->assertSame( 30, get_query_var( 'posts_per_page' ) );
|
||||
}
|
||||
|
||||
function filter_posts_per_page( &$query ) {
|
||||
public function filter_posts_per_page( &$query ) {
|
||||
$query->set( 'posts_per_rss', 30 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 26627
|
||||
*/
|
||||
function test_tag_queried_object() {
|
||||
public function test_tag_queried_object() {
|
||||
$slug = 'tag-slug-26627';
|
||||
self::factory()->tag->create( array( 'slug' => $slug ) );
|
||||
$tag = get_term_by( 'slug', $slug, 'post_tag' );
|
||||
|
||||
add_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 );
|
||||
add_action( 'pre_get_posts', array( $this, 'tag_queried_object' ), 11 );
|
||||
|
||||
$this->go_to( get_term_link( $tag ) );
|
||||
|
||||
@@ -75,10 +75,10 @@ class Tests_Query extends WP_UnitTestCase {
|
||||
$this->assertCount( 1, get_query_var( 'tag_slug__in' ) );
|
||||
$this->assertEquals( get_queried_object(), $tag );
|
||||
|
||||
remove_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 );
|
||||
remove_action( 'pre_get_posts', array( $this, 'tag_queried_object' ), 11 );
|
||||
}
|
||||
|
||||
function _tag_queried_object( &$query ) {
|
||||
public function tag_queried_object( &$query ) {
|
||||
$tag = get_term_by( 'slug', 'tag-slug-26627', 'post_tag' );
|
||||
$this->assertTrue( $query->is_tag() );
|
||||
$this->assertTrue( $query->is_archive() );
|
||||
|
||||
Reference in New Issue
Block a user