Make WordPress Core


Ignore:
Timestamp:
02/10/2021 01:24:24 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use assertSame() in some newly introduced 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.

Follow-up to [49904], [49925], [49992], [50012], [50013], [50065], [50075], [50131], [50150], [50157].

See #38266, #52482.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/https-migration.php

    r50131 r50284  
    6262        // Replaces URLs, including its encoded variant.
    6363        add_filter( 'wp_should_replace_insecure_home_url', '__return_true' );
    64         $this->assertEquals( $https_content, wp_replace_insecure_home_url( $http_content ) );
     64        $this->assertSame( $https_content, wp_replace_insecure_home_url( $http_content ) );
    6565
    6666        // Does not replace anything if determined as unnecessary.
    6767        add_filter( 'wp_should_replace_insecure_home_url', '__return_false' );
    68         $this->assertEquals( $http_content, wp_replace_insecure_home_url( $http_content ) );
     68        $this->assertSame( $http_content, wp_replace_insecure_home_url( $http_content ) );
    6969    }
    7070
     
    8787        // Update URLs to HTTPS (successfully).
    8888        $this->assertTrue( wp_update_urls_to_https() );
    89         $this->assertEquals( $https_url, get_option( 'home' ) );
    90         $this->assertEquals( $https_url, get_option( 'siteurl' ) );
     89        $this->assertSame( $https_url, get_option( 'home' ) );
     90        $this->assertSame( $https_url, get_option( 'siteurl' ) );
    9191
    9292        // Switch options back to use HTTP URLs, but now add filter to
     
    9999        // option. Therefore the change is expected to be reverted.
    100100        $this->assertFalse( wp_update_urls_to_https() );
    101         $this->assertEquals( $http_url, get_option( 'home' ) );
    102         $this->assertEquals( $http_url, get_option( 'siteurl' ) );
     101        $this->assertSame( $http_url, get_option( 'home' ) );
     102        $this->assertSame( $http_url, get_option( 'siteurl' ) );
    103103    }
    104104
     
    110110        update_option( 'fresh_site', '0' );
    111111        wp_update_https_migration_required( 'http://example.org', 'https://example.org' );
    112         $this->assertEquals( '1', get_option( 'https_migration_required' ) );
     112        $this->assertTrue( get_option( 'https_migration_required' ) );
    113113
    114114        // Changing another part than the scheme should delete/reset the flag because changing those parts (e.g. the
     
    120120        update_option( 'fresh_site', '1' );
    121121        wp_update_https_migration_required( 'http://example.org', 'https://example.org' );
    122         $this->assertEquals( '', get_option( 'https_migration_required' ) );
     122        $this->assertFalse( get_option( 'https_migration_required' ) );
    123123
    124124        // Changing (back) from HTTPS to HTTP should delete/reset the flag.
Note: See TracChangeset for help on using the changeset viewer.