Skip to content
This repository has been archived by the owner on May 6, 2018. It is now read-only.

Add tests.wordpress-develop.dev site #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

westonruter
Copy link

This is an exploration into making available the tests.wordpress-develop.dev domain as an alias for the same Nginx docroot that serves src.wordpress-develop.dev, but which loads from the database used for unit testing instead of the normal database that the dev site reads from.

The reason for making the WordPress tests database available on its own site is for the sake of allowing for automated acceptance tests (such as via Codeception or Behat) to be run on this separate environment. See #34693. If the WordPress dev environment in VVV has a known URL at which a test install is accessible, then the test runners will know where to direct the automated browsers.

WP-CLI can be routed to the test site by means of supplying the --url. For example, to reset the database for the tests environment:

wp --url=http://tests.wordpress-develop.dev db reset

Though naturally the DB is reset with each unit test as well.

// Match any requests made via xip.io.
if ( isset( \$_SERVER['HTTP_HOST'] ) && preg_match('/^(src|build)(.wordpress-develop.)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(.xip.io)\z/', \$_SERVER['HTTP_HOST'] ) ) {
// Match any requests made via xip.io or tests.wordpress-develop.dev.
if ( isset( \$_SERVER['HTTP_HOST'] ) && preg_match('/^tests\.wordpress-develop\.dev$|^(src|build)(\.wordpress-develop\.)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(.xip.io)\z/', \$_SERVER['HTTP_HOST'] ) ) {
Copy link
Author

@westonruter westonruter Mar 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose the preg_match() arg could be better as:

'/^(tests\.wordpress-develop\.dev|^(src|build)(\.wordpress-develop\.)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(.xip.io))\z/'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant