Tests: Use assertSame() in WP_Query tests involving ::$max_num_pages property.

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.

Follow-up to [48937], [54402], [54768], [57648].

Props costdev.
See #58683, #59655.

git-svn-id: https://develop.svn.wordpress.org/trunk@57653 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2024-02-18 18:59:24 +00:00
parent ba644b94df
commit a9ba7fde79
3 changed files with 12 additions and 12 deletions

View File

@ -3988,7 +3988,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
);
$this->assertSame( 3, $q->found_comments );
$this->assertEquals( 2, $q->max_num_pages );
$this->assertSame( 2, $q->max_num_pages );
}
/**
@ -4017,7 +4017,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
);
$this->assertSame( 3, $q->found_comments );
$this->assertEquals( 2, $q->max_num_pages );
$this->assertSame( 2, $q->max_num_pages );
}
/**

View File

@ -631,7 +631,7 @@ class Tests_Post_Query extends WP_UnitTestCase {
);
$this->assertSame( 2, $q->found_posts );
$this->assertEquals( 2, $q->max_num_pages );
$this->assertSame( 2, $q->max_num_pages );
}
/**
@ -654,7 +654,7 @@ class Tests_Post_Query extends WP_UnitTestCase {
);
$this->assertSame( 2, $q->found_posts );
$this->assertEquals( 2, $q->max_num_pages );
$this->assertSame( 2, $q->max_num_pages );
}
/**
@ -680,7 +680,7 @@ class Tests_Post_Query extends WP_UnitTestCase {
remove_filter( 'split_the_query', '__return_true' );
$this->assertSame( 2, $q->found_posts );
$this->assertEquals( 2, $q->max_num_pages );
$this->assertSame( 2, $q->max_num_pages );
}
/**
@ -707,7 +707,7 @@ class Tests_Post_Query extends WP_UnitTestCase {
remove_filter( 'split_the_query', '__return_false' );
$this->assertSame( 2, $q->found_posts );
$this->assertEquals( 2, $q->max_num_pages );
$this->assertSame( 2, $q->max_num_pages );
}
/**

View File

@ -62,7 +62,7 @@ class Tests_Query_FieldsClause extends WP_UnitTestCase {
$this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
$this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
$this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
$this->assertSame( 1, $q->max_num_pages, 'Number of found pages is not one.' );
// Test the second query's results match.
$q2 = new WP_Query( $query_args );
@ -86,7 +86,7 @@ class Tests_Query_FieldsClause extends WP_UnitTestCase {
$this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
$this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
$this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
$this->assertSame( 1, $q->max_num_pages, 'Number of found pages is not one.' );
// Test the second query's results match.
$q2 = new WP_Query( $query_args );
@ -110,7 +110,7 @@ class Tests_Query_FieldsClause extends WP_UnitTestCase {
$this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
$this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
$this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
$this->assertSame( 1, $q->max_num_pages, 'Number of found pages is not one.' );
// Test the second query's results match.
$q2 = new WP_Query( $query_args );
@ -145,7 +145,7 @@ class Tests_Query_FieldsClause extends WP_UnitTestCase {
$this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
$this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
$this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
$this->assertSame( 1, $q->max_num_pages, 'Number of found pages is not one.' );
// Test the second query's results match.
$q2 = new WP_Query( $query_args );
@ -173,7 +173,7 @@ class Tests_Query_FieldsClause extends WP_UnitTestCase {
$this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
$this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
$this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
$this->assertSame( 1, $q->max_num_pages, 'Number of found pages is not one.' );
// Test the second query's results match.
$q2 = new WP_Query( $query_args );
@ -204,7 +204,7 @@ class Tests_Query_FieldsClause extends WP_UnitTestCase {
$this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
$this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
$this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
$this->assertSame( 1, $q->max_num_pages, 'Number of found pages is not one.' );
// Test the second query's results match.
$q2 = new WP_Query( $query_args );