1
0
Fork 0
mirror of https://github.com/buddypress/buddypress.git synced 2026-07-21 20:54:17 +08:00
buddypress/tests/phpunit/includes/define-constants.php
Mathieu Viet f17a37b7f6 Build/Test Tools: include @wordpress/env into BuddyPress
`wp-env` requires Docker and the latest Node.js LTS version. It gives us a set of new `npm` commands to easily generate a local WordPress environment to unit test, develop and contribute to BuddyPress code.

To enjoy `wp-env`, make sure you have SVN or Git, composer, Node.js and Docker installed on your computer. Get the development version of BuddyPress using our SVN repository or its GitHub read-only mirror from this URL: https://buddypress.org/download/#trunk, and use the command to fetch the code locally into a `buddypress` folder. From your terminal software, move to this folder to install the needed libraries using the following commands.
`npm install`
`composer install`

Once done, you can set up your local development environment using this single command:
`npm run wp-env start`

You can now access to your local environment and finish the WordPress setup (permalinks etc..) from this URL:
`http://localhost:8888/wp-admin/`

The administration credentials are:
- Username: admin,
- Password: password

To stop the environment, you can use this command:
`npm run wp-env stop`

To run PHP unit tests, you can use this command:
`npm run test-php`

To run PHP unit tests on multisite, you can use this command:
`npm run test-php-multisite`

You can customize your local development setup using a file named `.wp-env.override.json `. Our default setup is using the WordPress development version and includes the BP REST plugin. For more details about `wp-env`, have a look at this documentation page: https://developer.wordpress.org/block-editor/packages/packages-env/

Props oztaser, mercime, vapvarun

Fixes #8317


git-svn-id: https://buddypress.svn.wordpress.org/trunk@12712 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
2020-08-30 17:53:06 +00:00

58 lines
2.1 KiB
PHP

<?php
/**
* Define constants needed by test suite.
*/
define( 'BP_PLUGIN_DIR', dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/src/' );
if ( ! defined( 'BP_TESTS_DIR' ) ) {
define( 'BP_TESTS_DIR', dirname( dirname( __FILE__ ) ) . '/' );
}
/**
* Determine where the WP test suite lives. Three options are supported:
*
* - Define a WP_DEVELOP_DIR environment variable, which points to a checkout
* of the develop.svn.wordpress.org repository (this is recommended)
* - Define a WP_TESTS_DIR environment variable, which points to a checkout of
* WordPress test suite
* - Assume that we are inside of a develop.svn.wordpress.org setup, and walk
* up the directory tree
*/
if ( false !== getenv( 'WP_PHPUNIT__DIR' ) ) {
define( 'WP_TESTS_DIR', getenv( 'WP_PHPUNIT__DIR' ) );
define( 'WP_ROOT_DIR', '/var/www/html' );
} elseif ( false !== getenv( 'WP_TESTS_DIR' ) ) {
define( 'WP_TESTS_DIR', getenv( 'WP_TESTS_DIR' ) );
define( 'WP_ROOT_DIR', WP_TESTS_DIR );
} else {
// Support WP_DEVELOP_DIR, as used by some plugins
if ( false !== getenv( 'WP_DEVELOP_DIR' ) ) {
define( 'WP_ROOT_DIR', getenv( 'WP_DEVELOP_DIR' ) );
} else {
define( 'WP_ROOT_DIR', dirname( dirname( dirname( dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) ) ) ) );
}
define( 'WP_TESTS_DIR', WP_ROOT_DIR . '/tests/phpunit' );
}
if ( ! defined( 'WP_TESTS_CONFIG_FILE_PATH' ) ) {
// Based on the tests directory, look for a config file
if ( file_exists( WP_ROOT_DIR . '/wp-tests-config.php' ) ) {
// Standard develop.svn.wordpress.org setup
define( 'WP_TESTS_CONFIG_PATH', WP_ROOT_DIR . '/wp-tests-config.php' );
} elseif ( file_exists( WP_TESTS_DIR . '/wp-tests-config.php' ) ) {
// Legacy unit-test.svn.wordpress.org setup
define( 'WP_TESTS_CONFIG_PATH', WP_TESTS_DIR . '/wp-tests-config.php' );
} elseif ( file_exists( dirname( dirname( WP_TESTS_DIR ) ) . '/wp-tests-config.php' ) ) {
// Environment variable exists and points to tests/phpunit of
// develop.svn.wordpress.org setup
define( 'WP_TESTS_CONFIG_PATH', dirname( dirname( WP_TESTS_DIR ) ) . '/wp-tests-config.php' );
} else {
die( "wp-tests-config.php could not be found.\n" );
}
}