Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (3 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/link/getPreviewPostLink.php

    r46586 r48937  
    99        $post = self::factory()->post->create();
    1010
    11         $this->assertEquals( add_query_arg( 'preview', 'true', get_permalink( $post ) ), get_preview_post_link( $post ) );
     11        $this->assertSame( add_query_arg( 'preview', 'true', get_permalink( $post ) ), get_preview_post_link( $post ) );
    1212    }
    1313
     
    2424        );
    2525
    26         $this->assertEquals(
     26        $this->assertSame(
    2727            $expected,
    2828            get_preview_post_link(
     
    4141        $expected = 'https://google.com/?foo=bar&bar=baz&preview=true';
    4242
    43         $this->assertEquals(
     43        $this->assertSame(
    4444            $expected,
    4545            get_preview_post_link(
     
    6565        $GLOBALS['post'] = $post;
    6666
    67         $this->assertEquals( add_query_arg( 'preview', 'true', get_permalink( $post ) ), get_preview_post_link() );
     67        $this->assertSame( add_query_arg( 'preview', 'true', get_permalink( $post ) ), get_preview_post_link() );
    6868    }
    6969
Note: See TracChangeset for help on using the changeset viewer.