Make WordPress Core


Ignore:
Timestamp:
02/18/2024 06:59:24 PM (2 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/fieldsClause.php

    r54890 r57653  
    6363        $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
    6464        $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
    65         $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
     65        $this->assertSame( 1, $q->max_num_pages, 'Number of found pages is not one.' );
    6666
    6767        // Test the second query's results match.
     
    8787        $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
    8888        $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
    89         $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
     89        $this->assertSame( 1, $q->max_num_pages, 'Number of found pages is not one.' );
    9090
    9191        // Test the second query's results match.
     
    111111        $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
    112112        $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
    113         $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
     113        $this->assertSame( 1, $q->max_num_pages, 'Number of found pages is not one.' );
    114114
    115115        // Test the second query's results match.
     
    146146        $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
    147147        $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
    148         $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
     148        $this->assertSame( 1, $q->max_num_pages, 'Number of found pages is not one.' );
    149149
    150150        // Test the second query's results match.
     
    174174        $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
    175175        $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
    176         $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
     176        $this->assertSame( 1, $q->max_num_pages, 'Number of found pages is not one.' );
    177177
    178178        // Test the second query's results match.
     
    205205        $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
    206206        $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
    207         $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
     207        $this->assertSame( 1, $q->max_num_pages, 'Number of found pages is not one.' );
    208208
    209209        // Test the second query's results match.
Note: See TracChangeset for help on using the changeset viewer.