WordPress.org

Make WordPress Core

Changeset 31515


Ignore:
Timestamp:
02/23/2015 01:07:18 AM (7 years ago)
Author:
boonebgorges
Message:

Ensure that a request URL is always set in WP_UnitTestCase::go_to().

Failure to set this variable meant that passing the home URL to go_to()
(without a trailing slash) resulted in a PHP notice, and failed to reset the
globals properly.

Props joostdevalk.
Fixes #31417.

Location:
trunk/tests/phpunit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase.php

    r31469 r31515  
    334334        $parts = parse_url($url);
    335335        if (isset($parts['scheme'])) {
    336             $req = $parts['path'];
     336            $req = isset( $parts['path'] ) ? $parts['path'] : '';
    337337            if (isset($parts['query'])) {
    338338                $req .= '?' . $parts['query'];
  • trunk/tests/phpunit/tests/includes/helpers.php

    r31306 r31515  
    186186    }
    187187
     188    /**
     189     * @ticket 31417
     190     */
     191    public function test_go_to_should_go_to_home_page_when_passing_the_untrailingslashed_home_url() {
     192        $this->assertFalse( is_home() );
     193        $home = untrailingslashit( get_option( 'home' ) );
     194        $this->go_to( $home );
     195        $this->assertTrue( is_home() );
     196    }
     197
    188198    protected function mock_deprecated() {
    189199        _deprecated_function( __METHOD__, '2.5' );
Note: See TracChangeset for help on using the changeset viewer.