Make WordPress Core

Changeset 57650


Ignore:
Timestamp:
02/17/2024 04:32:37 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use assertSame() in get_comment_pages_count() 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.

Follow-up to [27055], [48937], [54402], [57244], [57648].

Props costdev.
See #58683, #59655.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/getCommentsPagesCount.php

    r54402 r57650  
    7979                $comments = get_comments( array( 'post_id' => $post->ID ) );
    8080
    81                 $this->assertEquals( 3, get_comment_pages_count( $comments, 10, false ) );
    82                 $this->assertEquals( 2, get_comment_pages_count( $comments, 10, true ) );
    83                 $this->assertEquals( 4, get_comment_pages_count( $comments, 4, true ) );
     81                $this->assertSame( 3, get_comment_pages_count( $comments, 10, false ) );
     82                $this->assertSame( 2, get_comment_pages_count( $comments, 10, true ) );
     83                $this->assertSame( 4, get_comment_pages_count( $comments, 4, true ) );
    8484        }
    8585
    … …  
    102102                update_option( 'thread_comments', false );
    103103
    104                 $this->assertEquals( 3, get_comment_pages_count( $comments, 10, false ) );
    105                 $this->assertEquals( 2, get_comment_pages_count( $comments, 10, true ) );
    106                 $this->assertEquals( 3, get_comment_pages_count( $comments, 10, null ) );
    107                 $this->assertEquals( 3, get_comment_pages_count( $comments, 10 ) );
     104                $this->assertSame( 3, get_comment_pages_count( $comments, 10, false ) );
     105                $this->assertSame( 2, get_comment_pages_count( $comments, 10, true ) );
     106                $this->assertSame( 3, get_comment_pages_count( $comments, 10, null ) );
     107                $this->assertSame( 3, get_comment_pages_count( $comments, 10 ) );
    108108
    109109                update_option( 'thread_comments', true );
    110110
    111                 $this->assertEquals( 3, get_comment_pages_count( $comments, 10, false ) );
    112                 $this->assertEquals( 2, get_comment_pages_count( $comments, 10, true ) );
    113                 $this->assertEquals( 2, get_comment_pages_count( $comments, 10, null ) );
    114                 $this->assertEquals( 2, get_comment_pages_count( $comments, 10 ) );
     111                $this->assertSame( 3, get_comment_pages_count( $comments, 10, false ) );
     112                $this->assertSame( 2, get_comment_pages_count( $comments, 10, true ) );
     113                $this->assertSame( 2, get_comment_pages_count( $comments, 10, null ) );
     114                $this->assertSame( 2, get_comment_pages_count( $comments, 10 ) );
    115115        }
    116116
    … …  
    141141                update_option( 'comments_per_page', 25 );
    142142
    143                 $this->assertEquals( 3, get_comment_pages_count() );
    144                 $this->assertEquals( 2, get_comment_pages_count( null, 20 ) );
     143                $this->assertSame( 3, get_comment_pages_count() );
     144                $this->assertSame( 2, get_comment_pages_count( null, 20 ) );
    145145
    146146                $wp_query = new WP_Query(
    … …  
    152152                );
    153153
    154                 $this->assertEquals( 1, get_comment_pages_count() );
    155                 $this->assertEquals( 5, get_comment_pages_count( null, 5 ) );
     154                $this->assertSame( 1, get_comment_pages_count() );
     155                $this->assertSame( 5, get_comment_pages_count( null, 5 ) );
    156156
    157157                $wp_query->query_vars['comments_per_page'] = null;
    … …  
    159159                update_option( 'comments_per_page', 5 );
    160160
    161                 $this->assertEquals( 5, get_comment_pages_count() );
    162                 $this->assertEquals( 3, get_comment_pages_count( null, 11 ) );
    163                 $this->assertEquals( 5, get_comment_pages_count( null, 0 ) );
     161                $this->assertSame( 5, get_comment_pages_count() );
     162                $this->assertSame( 3, get_comment_pages_count( null, 11 ) );
     163                $this->assertSame( 5, get_comment_pages_count( null, 0 ) );
    164164        }
    165165
Note: See TracChangeset for help on using the changeset viewer.