Opened 10 years ago
Closed 10 years ago
#34346 closed defect (bug) (fixed)
WP_UnitTestCase::go_to() wipes out custom query vars
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 4.4 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Build/Test Tools | Keywords: | |
| Focuses: | Cc: |
Description
The go_to() method in the test suite re-instantiates the $wp global with a new WP object. This means that any custom query vars that have been added via $wp->add_query_var() get wiped out, making them untestable.
An affected function is add_rewrite_endpoint() which internally calls $wp->add_query_var().
This test demonstrates the problem:
$test_post_id = self::factory()->post->create(); add_rewrite_endpoint( 'foo', EP_PERMALINK ); flush_rewrite_rules(); $this->go_to( get_permalink( $test_post_id ) . 'foo/bar/' ); $this->assertTrue( is_single( $test_post_id ) ); // passes $this->assertEquals( 'bar', get_query_var( 'foo' ) ); // fails
Change History (3)
Note: See
TracTickets for help on using
tickets.
In 35258: