Skip to content

Commit

Permalink
Tests: Restore the environment before performing assertions in some c…
Browse files Browse the repository at this point in the history
…anonical tests.

This aims to avoid affecting other tests in case of failure.

Follow-up to [28704], [45133].

See #61608.

git-svn-id: https://develop.svn.wordpress.org/trunk@59017 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Sep 12, 2024
1 parent 4712210 commit 8f90a7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions tests/phpunit/tests/canonical.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,11 @@ public function test_utf8_query_keys_canonical() {

$this->go_to( get_permalink( $p ) );

$url = redirect_canonical( add_query_arg( '%D0%BA%D0%BE%D0%BA%D0%BE%D0%BA%D0%BE', 1, site_url( '/' ) ), false );
$this->assertNull( $url );
$redirect = redirect_canonical( add_query_arg( '%D0%BA%D0%BE%D0%BA%D0%BE%D0%BA%D0%BE', 1, site_url( '/' ) ), false );

delete_option( 'page_on_front' );

$this->assertNull( $redirect );
}

/**
Expand All @@ -456,11 +457,12 @@ public function test_feed_canonical_with_not_exists_query() {
)
);

$url = redirect_canonical( get_term_feed_link( self::$terms['/category/parent/'] ), false );
$redirect = redirect_canonical( get_term_feed_link( self::$terms['/category/parent/'] ), false );

// Restore original global.
$GLOBALS['wp_query'] = $global_query;

$this->assertNull( $url );
$this->assertNull( $redirect );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/tests/canonical/https.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public function test_https_request_with_https_home() {

$redirect = redirect_canonical( $this->https, false );

$this->assertNull( $redirect );

remove_filter( 'home_url', array( $this, 'set_https' ) );

$this->assertNull( $redirect );
}
}

0 comments on commit 8f90a7e

Please sign in to comment.