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/term/wpInsertTerm.php

    r48840 r48937  
    212212        $this->assertWPError( $term7 );
    213213        $this->assertNotEmpty( $term7->errors );
    214         $this->assertEquals( $term6, $term7->error_data['term_exists'] );
     214        $this->assertSame( $term6, $term7->error_data['term_exists'] );
    215215
    216216        $terms = array_map( 'get_tag', array( $term3, $term4, $term5, $term6 ) );
     
    225225        $this->assertWPError( $term12 );
    226226        $this->assertNotEmpty( $term12->errors );
    227         $this->assertEquals( $term11, $term12->error_data['term_exists'] );
     227        $this->assertSame( $term11, $term12->error_data['term_exists'] );
    228228
    229229        $terms = array_map( 'get_tag', array( $term8, $term9, $term10, $term11 ) );
     
    818818        _unregister_taxonomy( 'wptests_tax' );
    819819
    820         $this->assertSame( false, wp_cache_get( 'all_ids', 'wptests_tax' ) );
    821         $this->assertSame( false, wp_cache_get( 'get', 'wptests_tax' ) );
     820        $this->assertFalse( wp_cache_get( 'all_ids', 'wptests_tax' ) );
     821        $this->assertFalse( wp_cache_get( 'get', 'wptests_tax' ) );
    822822
    823823        $cached_children = get_option( 'wptests_tax_children' );
     
    905905        $this->assertInternalType( 'array', $object_ids );
    906906        // Pesky string $this->assertInternalType( 'int', $tt_id );
    907         $this->assertEquals( $term, $deleted_term->term_id );
    908         $this->assertEquals( $taxonomy, $deleted_term->taxonomy );
     907        $this->assertSame( $term, $deleted_term->term_id );
     908        $this->assertSame( $taxonomy, $deleted_term->taxonomy );
    909909        $this->assertEquals( $tt_id, $deleted_term->term_taxonomy_id );
    910910        $this->assertEmpty( $object_ids );
Note: See TracChangeset for help on using the changeset viewer.