Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (4 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/hooks/applyFilters.php

    r46586 r48937  
    2121        $returned = $hook->apply_filters( $arg, array( $arg ) );
    2222
    23         $this->assertEquals( $returned, $arg );
    24         $this->assertEquals( 1, $a->get_call_count() );
     23        $this->assertSame( $returned, $arg );
     24        $this->assertSame( 1, $a->get_call_count() );
    2525    }
    2626
     
    3939        $returned_two = $hook->apply_filters( $returned_one, array( $returned_one ) );
    4040
    41         $this->assertEquals( $returned_two, $arg );
    42         $this->assertEquals( 2, $a->get_call_count() );
     41        $this->assertSame( $returned_two, $arg );
     42        $this->assertSame( 2, $a->get_call_count() );
    4343    }
    4444
Note: See TracChangeset for help on using the changeset viewer.