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/hooks/addFilter.php

    r46586 r48937  
    2121
    2222        $function_index = _wp_filter_build_unique_id( $tag, $callback, $priority );
    23         $this->assertEquals( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] );
    24         $this->assertEquals( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] );
     23        $this->assertSame( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] );
     24        $this->assertSame( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] );
    2525    }
    2626
     
    3636
    3737        $function_index = _wp_filter_build_unique_id( $tag, $callback, $priority );
    38         $this->assertEquals( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] );
    39         $this->assertEquals( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] );
     38        $this->assertSame( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] );
     39        $this->assertSame( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] );
    4040    }
    4141
     
    5050
    5151        $function_index = _wp_filter_build_unique_id( $tag, $callback, $priority );
    52         $this->assertEquals( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] );
    53         $this->assertEquals( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] );
     52        $this->assertSame( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] );
     53        $this->assertSame( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] );
    5454    }
    5555
     
    125125        $hook->add_filter( $tag, array( $c, 'action' ), 8, 1 );
    126126
    127         $this->assertEquals( array( 5, 8, 10 ), array_keys( $hook->callbacks ) );
     127        $this->assertSame( array( 5, 8, 10 ), array_keys( $hook->callbacks ) );
    128128    }
    129129
Note: See TracChangeset for help on using the changeset viewer.