Skip to:

Opened 10 years ago

Closed 10 years ago

#5376 closed enhancement (fixed)

PHPUnit Test Environment Variable

Reported by: netweb's profile netweb Owned by: boonebgorges's profile boonebgorges
Milestone: 2.1 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch



There appears to be two methods to reference WordPress' Core PHPUnit Tests setting an environment variable.

  1. WP_TESTS_DIR - Used by BuddyPress and WP-CLI (
  2. WP_DEVELOP_DIR Used by @tierra/@bpetty and most probably WP-API and Jetpack

Presumably we'd all like to hook into each others PHPUnit Tests in the future and play nice together as per Boone's bootstrapping BP's tests in #4889.

I couldn't find any 'official docs' on which one we should use, either WP_TESTS_DIR or WP_DEVELOP_DIR but I think we should choose one that 'we all use' and I think the later appears to be the emerging theory, set the WP dev root and use it as the base for all the things.

(We have started to add PHPUnit Tests to bbPress #bbPress2542)

Attachments (1)

5376.2.diff (1.7 KB) - added by netweb 10 years ago.

Download all attachments as: .zip

Change History (7)

#1 @boonebgorges
10 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 2.0

Thanks for the report. Given that we're already supporting and recommending WP_TESTS_DIR, we don't want to drop support for it. But we should support WP_DEVELOP_DIR as well, and I'm happy for that to become the recommended option.

#2 @boonebgorges
10 years ago

  • Milestone changed from 2.0 to 2.1

I'm glad to fix this whenever, but I'm going to move it out of the milestone until it has a patch.

#3 @boonebgorges
10 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 8415:

Rework the way that the WP tests directory is inferred during test bootstrap, to support WP_DEVELOP_DIR

This provides greater flexibility, and better compatibility with other projects.

Fixes #5376

#4 @netweb
10 years ago

  • Keywords has-patch added; needs-patch removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Boone, thanks,

Though when WP_TESTS_DIR is not set and only WP_DEVELOP_DIR (same/equiv folder as WP_ROOT_DIR) is set an error occurs when defining WP_TESTS_DIR on Line#34 because WP_ROOT_DIR does not exist.

Attached patch fixes this by defining WP_ROOT_DIR == WP_DEVELOP_DIR

Then define( 'WP_TESTS_DIR', WP_ROOT_DIR . '/tests/phpunit' ); and all works as expected.

10 years ago

#5 @boonebgorges
10 years ago

Oops, slip of the finger. Thanks for the correction.

#6 @boonebgorges
10 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 8418:

Fix incorrect constant name when setting up phpunit constants

Fixes #5376

Props netweb

Note: See TracTickets for help on using tickets.