WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (17 months 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/slashes.php

    r47122 r48937  
    4040            );
    4141            $term   = get_term( $insert['term_id'], $taxonomy );
    42             $this->assertEquals( wp_unslash( $this->slash_1 ), $term->name );
    43             $this->assertEquals( wp_unslash( $this->slash_3 ), $term->description );
     42            $this->assertSame( wp_unslash( $this->slash_1 ), $term->name );
     43            $this->assertSame( wp_unslash( $this->slash_3 ), $term->description );
    4444
    4545            $insert = wp_insert_term(
     
    5252            );
    5353            $term   = get_term( $insert['term_id'], $taxonomy );
    54             $this->assertEquals( wp_unslash( $this->slash_3 ), $term->name );
    55             $this->assertEquals( wp_unslash( $this->slash_5 ), $term->description );
     54            $this->assertSame( wp_unslash( $this->slash_3 ), $term->name );
     55            $this->assertSame( wp_unslash( $this->slash_5 ), $term->description );
    5656
    5757            $insert = wp_insert_term(
     
    6464            );
    6565            $term   = get_term( $insert['term_id'], $taxonomy );
    66             $this->assertEquals( wp_unslash( $this->slash_2 ), $term->name );
    67             $this->assertEquals( wp_unslash( $this->slash_4 ), $term->description );
     66            $this->assertSame( wp_unslash( $this->slash_2 ), $term->name );
     67            $this->assertSame( wp_unslash( $this->slash_4 ), $term->description );
    6868        }
    6969    }
     
    9494
    9595            $term = get_term( $id, $taxonomy );
    96             $this->assertEquals( wp_unslash( $this->slash_1 ), $term->name );
    97             $this->assertEquals( wp_unslash( $this->slash_3 ), $term->description );
     96            $this->assertSame( wp_unslash( $this->slash_1 ), $term->name );
     97            $this->assertSame( wp_unslash( $this->slash_3 ), $term->description );
    9898
    9999            $update = wp_update_term(
     
    106106            );
    107107            $term   = get_term( $id, $taxonomy );
    108             $this->assertEquals( wp_unslash( $this->slash_3 ), $term->name );
    109             $this->assertEquals( wp_unslash( $this->slash_5 ), $term->description );
     108            $this->assertSame( wp_unslash( $this->slash_3 ), $term->name );
     109            $this->assertSame( wp_unslash( $this->slash_5 ), $term->description );
    110110
    111111            $update = wp_update_term(
     
    118118            );
    119119            $term   = get_term( $id, $taxonomy );
    120             $this->assertEquals( wp_unslash( $this->slash_2 ), $term->name );
    121             $this->assertEquals( wp_unslash( $this->slash_4 ), $term->description );
     120            $this->assertSame( wp_unslash( $this->slash_2 ), $term->name );
     121            $this->assertSame( wp_unslash( $this->slash_4 ), $term->description );
    122122        }
    123123    }
Note: See TracChangeset for help on using the changeset viewer.