Make WordPress Core

Opened 16 months ago

Last modified 7 weeks ago

#39734 reviewing enhancement

Add ability to define file path of "wp-tests-config.php"

Reported by: clarinetlord Owned by: johnbillion
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:


There are several reasons why someone might want to define the location of wp-tests-config.php themselves instead of tests/phpunit/includes/bootstrap.php only checking in two distinct locations. Personally, I would like to define the location outside the project root so I can check the file into my project repositories and keep the develop core as a clean dependency directory. I suggest that the bootstrap check for a constant in the phpunit.xml.dist file, since this file can be copied and modified outside the project to be used by phpunit.

Attachments (2)

Added_optional_constant_to_define_wp_tests_config_php_path.patch (742 bytes) - added by clarinetlord 14 months ago.
Add_optional_constant_to_preset_tests_config_file.patch (2.4 KB) - added by clarinetlord 14 months ago.

Download all attachments as: .zip

Change History (9)

#1 @johnbillion
15 months ago

  • Keywords needs-patch good-first-bug added
  • Version trunk deleted

Thanks for the ticket, @clarinetlord. This is a sensible request. It would be nice if it could work in the same way as the bootstrap attribute on the phpunit element in phpunit.xml, but I'm not sure if that's possible. Otherwise, a constant makes sense.

#2 @johnbillion
15 months ago

  • Keywords good-first-bug removed

#3 @clarinetlord
14 months ago

  • Keywords has-patch added; needs-patch removed

Thanks @johnbillion, I think a PHP constant is the best option I can see here. There may be a way to add custom XML attributes to the phpunit.xml file, but it's probably more trouble than it's worth. As a constant, there's also the option to define it other places besides phpunit.xml. Here's a simple patch to bootstrap.php to add this feature.

#4 @johnbillion
14 months ago

Thanks for the patch. I think the WP_CONFIG_FILE_PATH constant should take precedence over the default location of wp-tests-config.php in case someone wants to do a particularly crazy setup where wp-tests-config.php is in place but they want to override it with WP_CONFIG_FILE_PATH.

#5 @clarinetlord
14 months ago

That's a good idea. Here's a modified patch that wraps the entire file location check with a check for the existence of that constant first. It seemed cleanest to also set the constant in the default procedure, so it's always defined no matter what. I replaced future variable references with the constant.

#6 follow-up: @johnbillion
14 months ago

  • Milestone changed from Awaiting Review to Future Release
  • Owner set to johnbillion
  • Status changed from new to reviewing

#7 in reply to: ↑ 6 @clarinetlord
7 weeks ago

Replying to johnbillion:

Hey @johnbillion, any chance we could get this into 5.0?

Note: See TracTickets for help on using tickets.