#39734 closed enhancement (fixed)
Add ability to define file path of "wp-tests-config.php"
Reported by: | clarinetlord | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | has-patch has-dev-note |
Focuses: | Cc: |
Description
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 (3)
Change History (16)
#3
@
8 years 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
@
8 years 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
@
8 years 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:
↓ 7
@
8 years ago
- Milestone changed from Awaiting Review to Future Release
- Owner set to johnbillion
- Status changed from new to reviewing
#7
in reply to:
↑ 6
@
7 years ago
Replying to johnbillion:
Hey @johnbillion, any chance we could get this into 5.0?
#8
@
7 years ago
It would be great to get this in for 5.0 especially since #43558 was already merged.
PHPUnit also supports defining environment variables but constants appear to be the WordPress way of doing it.
#10
@
7 years ago
39734.patch simplifies the patch a little and changes the constant name to WP_TESTS_CONFIG_FILE_PATH
.
#13
@
6 years ago
- Keywords has-dev-note added
This was detailed in a dev note: https://make.wordpress.org/core/2019/01/23/miscellaneous-developer-focused-changes-in-5-1/
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 thephpunit
element in phpunit.xml, but I'm not sure if that's possible. Otherwise, a constant makes sense.