Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (5 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

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

    r46586 r48937  
    9595        $this->assertSame( 0, $data['multipage'] );
    9696        $this->assertSame( 1, $data['numpages'] );
    97         $this->assertEquals( array( 'Page 0' ), $data['pages'] );
     97        $this->assertSame( array( 'Page 0' ), $data['pages'] );
    9898    }
    9999
     
    111111        $this->assertSame( 1, $data['multipage'] );
    112112        $this->assertSame( 4, $data['numpages'] );
    113         $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $data['pages'] );
     113        $this->assertSame( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $data['pages'] );
    114114    }
    115115
     
    127127        $this->assertSame( 1, $data['multipage'] );
    128128        $this->assertSame( 3, $data['numpages'] );
    129         $this->assertEquals( array( 'Page 1', 'Page 2', 'Page 3' ), $data['pages'] );
     129        $this->assertSame( array( 'Page 1', 'Page 2', 'Page 3' ), $data['pages'] );
    130130    }
    131131
     
    141141        $data = generate_postdata( $post );
    142142
    143         $this->assertEquals( array( 'Page 0', "Page 1\nhas a line break", 'Page 2', "\nPage 3" ), $data['pages'] );
     143        $this->assertSame( array( 'Page 0', "Page 1\nhas a line break", 'Page 2', "\nPage 3" ), $data['pages'] );
    144144    }
    145145}
Note: See TracChangeset for help on using the changeset viewer.