WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/09/2020 03:43:14 PM (13 months 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 [48937], [48939], [48940], [48944].

See #38266.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-request.php

    r49329 r49547  
    206206
    207207        // Check that JSON takes precedence.
    208         $this->assertEquals( $source, $this->request->get_param( 'source' ) );
     208        $this->assertSame( $source, $this->request->get_param( 'source' ) );
    209209        $this->assertEquals( $accept_json, $this->request->get_param( 'has_json_params' ) );
    210210    }
     
    234234
    235235        // Check for JSON content-type.
    236         $this->assertEquals( $is_json, $this->request->is_json_content_type() );
     236        $this->assertSame( $is_json, $this->request->is_json_content_type() );
    237237    }
    238238
     
    927927        $valid = $request->has_valid_params();
    928928        $this->assertWPError( $valid );
    929         $this->assertEquals( 'rest_invalid_param', $valid->get_error_code() );
     929        $this->assertSame( 'rest_invalid_param', $valid->get_error_code() );
    930930    }
    931931}
Note: See TracChangeset for help on using the changeset viewer.