mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-29 15:44:27 +00:00
Tests: First pass at using assertSame() instead of assertEquals() in most of the unit tests.
This ensures that not only the return values match the expected results, but also that their type is the same. Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable. Props johnbillion, jrf, SergeyBiryukov. See #38266. git-svn-id: https://develop.svn.wordpress.org/trunk@48937 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -22,10 +22,10 @@ class Tests_Query extends WP_UnitTestCase {
|
||||
$second_query = new WP_Query( array( 'post__in' => array( $nested_post_id ) ) );
|
||||
while ( $second_query->have_posts() ) {
|
||||
$second_query->the_post();
|
||||
$this->assertEquals( get_the_ID(), $nested_post_id );
|
||||
$this->assertSame( get_the_ID(), $nested_post_id );
|
||||
}
|
||||
$first_query->reset_postdata();
|
||||
$this->assertEquals( get_the_ID(), $post_id );
|
||||
$this->assertSame( get_the_ID(), $post_id );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class Tests_Query extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_default_query_var() {
|
||||
$query = new WP_Query;
|
||||
$this->assertEquals( '', $query->get( 'nonexistent' ) );
|
||||
$this->assertSame( '', $query->get( 'nonexistent' ) );
|
||||
$this->assertFalse( $query->get( 'nonexistent', false ) );
|
||||
$this->assertTrue( $query->get( 'nonexistent', true ) );
|
||||
}
|
||||
@@ -49,7 +49,7 @@ class Tests_Query extends WP_UnitTestCase {
|
||||
|
||||
$this->go_to( get_feed_link() );
|
||||
|
||||
$this->assertEquals( 30, get_query_var( 'posts_per_page' ) );
|
||||
$this->assertSame( 30, get_query_var( 'posts_per_page' ) );
|
||||
}
|
||||
|
||||
function filter_posts_per_page( &$query ) {
|
||||
@@ -519,7 +519,7 @@ class Tests_Query extends WP_UnitTestCase {
|
||||
remove_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) );
|
||||
|
||||
$this->assertFalse( $GLOBALS['wp_query']->is_404() );
|
||||
$this->assertEquals( $post_id, $GLOBALS['wp_query']->post->ID );
|
||||
$this->assertSame( $post_id, $GLOBALS['wp_query']->post->ID );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -552,7 +552,7 @@ class Tests_Query extends WP_UnitTestCase {
|
||||
remove_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) );
|
||||
|
||||
$this->assertFalse( $GLOBALS['wp_query']->is_404() );
|
||||
$this->assertEquals( $post_id, $GLOBALS['wp_query']->post->ID );
|
||||
$this->assertSame( $post_id, $GLOBALS['wp_query']->post->ID );
|
||||
}
|
||||
|
||||
public function filter_parse_query_to_modify_queried_post_id( $query ) {
|
||||
|
||||
Reference in New Issue
Block a user