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/doAction.php

    r46586 r48937  
    2828        $hook->do_action( array( $arg ) );
    2929
    30         $this->assertEquals( 1, $a->get_call_count() );
     30        $this->assertSame( 1, $a->get_call_count() );
    3131    }
    3232
     
    4444        $hook->do_action( array( $arg ) );
    4545
    46         $this->assertEquals( 2, $a->get_call_count() );
     46        $this->assertSame( 2, $a->get_call_count() );
    4747    }
    4848
     
    6262        $hook->do_action( array( $arg ) );
    6363
    64         $this->assertEquals( 1, $a->get_call_count() );
    65         $this->assertEquals( 1, $a->get_call_count() );
     64        $this->assertSame( 1, $a->get_call_count() );
     65        $this->assertSame( 1, $a->get_call_count() );
    6666    }
    6767
     
    8181        $hook->do_action( array( $arg ) );
    8282
    83         $this->assertEquals( 1, $a->get_call_count() );
    84         $this->assertEquals( 1, $a->get_call_count() );
     83        $this->assertSame( 1, $a->get_call_count() );
     84        $this->assertSame( 1, $a->get_call_count() );
    8585    }
    8686
Note: See TracChangeset for help on using the changeset viewer.