Make WordPress Core

Opened 7 years ago

Last modified 6 years ago

#41451 new enhancement

Use pretty permalinks by default in the test suite

Reported by: johnbillion's profile johnbillion Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-patch needs-unit-tests
Focuses: Cc:

Description

There are 118 instances of $this->set_permalink_structure( ... ) in the test suite. The majority of these calls are present simply to enable pretty permalinks, regardless of the permastructure for posts.

Pretty permalinks should be enabled by default for the test suite. Let's try it and see if anything breaks.

Attachments (1)

41451.patch (91.0 KB) - added by Frank Klein 7 years ago.

Download all attachments as: .zip

Change History (7)

#1 @netweb
7 years ago

Previously: [34802], [34803], [34807], and [34810]

#2 @Frank Klein
7 years ago

Started working on this, and overall things don't look too bad.

#42452 is a blocker right now, because with pretty permalinks enabled, the majority of REST API tests fail.

#3 @rmccue
7 years ago

In 42250:

REST API: Ensure rest_url() consistently has leading slash.

rest_url() inconsistent addes slashes to the passed path depending on whether the site has pretty permalinks enabled. Apart from being inconsistent, this also caused the unit tests to fail when pretty permalinks are enabled.

Props frank-klein.
Fixes #42452. See #41451.

@Frank Klein
7 years ago

#5 @Frank Klein
7 years ago

The patch above contains the code that makes all the tests, except three multisite tests, pass with pretty permalinks enabled. I was unable to fix these, so I'd be happy if somebody else could look into this.

This Travis CI log contains the failing tests:

  • Tests_Query_VerbosePageRules: This keeps failing no matter what I try. The way WP_UnitTestCase::goto behaves is not very transparent, and I can't figure it out.
  • Tests_Rewrite_OldSlugRedirect and Tests_Feeds_RSS2 pass on local, but fail on Travis.

A few notes about the patch:

  • I did not account for non-Core test runs at this point. We could add a bunch of WP_RUN_CORE_TESTS checks, but I feel like a more elegant solution would be welcome.
  • I introduced helper functions for permalink handling. I'm not a fan of stuffing everything into WP_UnitTestCase if it doesn't need to be part of the class. The helper functions are also more efficient, as UnitTestCase::set_permalink_structure calls WP_Rewrite::init twice.
  • I did only adapt the existing tests so that they pass. This might not always be the past way for the thing being tested.

#6 @danielbachhuber
6 years ago

In 43766:

REST API: Ensure rest_url() consistently has leading slash.

rest_url() inconsistent addes slashes to the passed path depending on whether the site has pretty permalinks enabled. Apart from being inconsistent, this also caused the unit tests to fail when pretty permalinks are enabled.

Props frank-klein.
Merges [42250] to the 5.0 branch.
Partially reverts [43720].
Fixes #42452. See #41451, #45017.

Note: See TracTickets for help on using tickets.