Opened 10 years ago
Closed 9 years ago
#35452 closed defect (bug) (fixed)
WP_UnitTestCase::set_permalink_structure() doesn't set all permastructures
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.7 | Priority: | high |
| Severity: | normal | Version: | |
| Component: | Build/Test Tools | Keywords: | needs-patch needs-unit-tests |
| Focuses: | Cc: |
Description
Calling $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ) from within a unit test does not result in the $wp_rewrite->extra_permastructs property being populated.
The result is that categories and tags don't have pretty permalinks enabled. Posts, date archives, author archives, custom post type archives etc do have pretty permalinks enabled as expected.
Example failing test:
public function test_pretty_links() {
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
$term = self::factory()->term->create_and_get();
$expected = 'http://' . WP_TESTS_DOMAIN . '/tag/' . $term->slug . '/';
$actual = get_term_link( $term );
$this->assertEquals( $expected, $actual );
}
Attachments (1)
Change History (11)
#5
@
9 years ago
If there is an issue still related to this, it might be related to #37207 and the proposed patch there might resolve it.
#6
@
9 years ago
It looks like we have some cross-test leakage somewhere. Running this test on its own with phpunit --filter Tests_Rewrite_Pretty_Permalinks results in a failure:
1) Tests_Rewrite_Pretty_Permalinks::test_term_permalink Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'http://example.org/tag/term-18/' +'http://example.org/?tag=term-18'
But running it as part of the whole suite with phpunit or as part of the rewrite group with phpunit --group rewrite results in a pass.
#7
@
9 years ago
What can I do to help nudge this along? I'm really trying to get #30210 in for 4.7, and this is blocking.
I'm escalating the priority to 'high' since this is blocking both #30210 and #31935.