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/general/paginateLinks.php

    r47122 r48937  
    2626
    2727        $links = paginate_links( array( 'total' => 50 ) );
    28         $this->assertEqualsIgnoreEOL( $expected, $links );
     28        $this->assertSameIgnoreEOL( $expected, $links );
    2929    }
    3030
     
    4949            )
    5050        );
    51         $this->assertEqualsIgnoreEOL( $expected, $links );
     51        $this->assertSameIgnoreEOL( $expected, $links );
    5252    }
    5353
     
    7474            )
    7575        );
    76         $this->assertEqualsIgnoreEOL( $expected, $links );
     76        $this->assertSameIgnoreEOL( $expected, $links );
    7777    }
    7878
     
    101101            )
    102102        );
    103         $this->assertEqualsIgnoreEOL( $expected, $links );
     103        $this->assertSameIgnoreEOL( $expected, $links );
    104104    }
    105105
     
    126126        // The links should be:
    127127        // < Previous 1 ... 49 50 51 ... 100 Next >
    128         $this->assertEquals( 5, $this->i18n_count );
     128        $this->assertSame( 5, $this->i18n_count );
    129129        remove_filter( 'number_format_i18n', array( $this, 'increment_i18n_count' ) );
    130130    }
     
    171171            $class = $tag->attributes->getNamedItem( 'class' )->value;
    172172
    173             $this->assertEquals( $attributes['href'], $href );
    174             $this->assertEquals( $attributes['class'], $class );
     173            $this->assertSame( $attributes['href'], $href );
     174            $this->assertSame( $attributes['class'], $class );
    175175        }
    176176
     
    191191
    192192        $class = $tag->attributes->getNamedItem( 'class' )->value;
    193         $this->assertEquals( 'page-numbers current', $class );
     193        $this->assertSame( 'page-numbers current', $class );
    194194
    195195        $document->loadHTML( $links[1] );
     
    198198
    199199        $href = $tag->attributes->getNamedItem( 'href' )->value;
    200         $this->assertEquals( get_pagenum_link( 2 ), $href );
     200        $this->assertSame( get_pagenum_link( 2 ), $href );
    201201    }
    202202
     
    245245
    246246            $href = $tag->attributes->getNamedItem( 'href' )->value;
    247             $this->assertEquals( $expected_href, $href );
     247            $this->assertSame( $expected_href, $href );
    248248        }
    249249    }
     
    285285
    286286            $href = $tag->attributes->getNamedItem( 'href' )->value;
    287             $this->assertEquals( $expected_href, $href );
     287            $this->assertSame( $expected_href, $href );
    288288        }
    289289    }
Note: See TracChangeset for help on using the changeset viewer.