Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/30/2020 05:53:06 PM (4 years ago)
Author:
imath
Message:

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

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:global-ignores
      •  

        old new  
        11.DS_Store
        22.gitignore
         3.wp-env.override.json
  • trunk/tests/phpunit/includes/define-constants.php

    r9819 r12712  
    2121 *   up the directory tree
    2222 */
    23 if ( false !== getenv( 'WP_TESTS_DIR' ) ) {
     23if ( false !== getenv( 'WP_PHPUNIT__DIR' ) ) {
     24    define( 'WP_TESTS_DIR', getenv( 'WP_PHPUNIT__DIR' ) );
     25    define( 'WP_ROOT_DIR', '/var/www/html' );
     26} elseif ( false !== getenv( 'WP_TESTS_DIR' ) ) {
    2427    define( 'WP_TESTS_DIR', getenv( 'WP_TESTS_DIR' ) );
    2528    define( 'WP_ROOT_DIR', WP_TESTS_DIR );
     
    3538}
    3639
    37 // Based on the tests directory, look for a config file
    38 if ( file_exists( WP_ROOT_DIR . '/wp-tests-config.php' ) ) {
    39     // Standard develop.svn.wordpress.org setup
    40     define( 'WP_TESTS_CONFIG_PATH', WP_ROOT_DIR . '/wp-tests-config.php' );
     40if ( ! defined( 'WP_TESTS_CONFIG_FILE_PATH' ) ) {
     41    // Based on the tests directory, look for a config file
     42    if ( file_exists( WP_ROOT_DIR . '/wp-tests-config.php' ) ) {
     43        // Standard develop.svn.wordpress.org setup
     44        define( 'WP_TESTS_CONFIG_PATH', WP_ROOT_DIR . '/wp-tests-config.php' );
    4145
    42 } elseif ( file_exists( WP_TESTS_DIR . '/wp-tests-config.php' ) ) {
    43     // Legacy unit-test.svn.wordpress.org setup
    44     define( 'WP_TESTS_CONFIG_PATH', WP_TESTS_DIR . '/wp-tests-config.php' );
     46    } elseif ( file_exists( WP_TESTS_DIR . '/wp-tests-config.php' ) ) {
     47        // Legacy unit-test.svn.wordpress.org setup
     48        define( 'WP_TESTS_CONFIG_PATH', WP_TESTS_DIR . '/wp-tests-config.php' );
    4549
    46 } elseif ( file_exists( dirname( dirname( WP_TESTS_DIR ) ) . '/wp-tests-config.php' ) ) {
    47     // Environment variable exists and points to tests/phpunit of
    48     // develop.svn.wordpress.org setup
    49     define( 'WP_TESTS_CONFIG_PATH', dirname( dirname( WP_TESTS_DIR ) ) . '/wp-tests-config.php' );
     50    } elseif ( file_exists( dirname( dirname( WP_TESTS_DIR ) ) . '/wp-tests-config.php' ) ) {
     51        // Environment variable exists and points to tests/phpunit of
     52        // develop.svn.wordpress.org setup
     53        define( 'WP_TESTS_CONFIG_PATH', dirname( dirname( WP_TESTS_DIR ) ) . '/wp-tests-config.php' );
    5054
    51 } else {
    52     die( "wp-tests-config.php could not be found.\n" );
     55    } else {
     56        die( "wp-tests-config.php could not be found.\n" );
     57    }
    5358}
Note: See TracChangeset for help on using the changeset viewer.