Skip to:
Content

BuddyPress.org

Changeset 13720


Ignore:
Timestamp:
01/31/2024 08:09:06 PM (12 months ago)
Author:
imath
Message:

Update wp-env to version 9.0.0 & adapt the PHPUnit tests suite to it

  • Update PHPUnit related npm scripts for wp-env 9.0.0.
  • Create test_multi: a new composer script to run Multisite Unit tests.
  • Remove our composer dependency to wp-phpunit/wp-phpunit.
  • Update the PHPUnit tests suite so that it stops using wp-phpunit/wp-phpunit when it's within the wp-env context.
  • Remove no more used PHPUnit specific configuration files.

Fixes #9053
Closes https://github.com/buddypress/buddypress/pull/211

Location:
trunk
Files:
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/composer.json

    r13684 r13720  
    4747    "require-dev": {
    4848        "buddypress/bp-coding-standards": "dev-trunk",
    49         "wp-phpunit/wp-phpunit": "^6.4",
    5049        "yoast/phpunit-polyfills": "^1.0"
    5150    },
    5251    "scripts": {
    5352        "test": "@php ./vendor/phpunit/phpunit/phpunit",
     53        "test_multi": "@php ./vendor/phpunit/phpunit/phpunit -c tests/phpunit/multisite.xml",
    5454        "phpcs": "@php ./vendor/bin/phpcs"
    5555    }
  • trunk/npm-shrinkwrap.json

    r13684 r13720  
    1212                "@wordpress/babel-preset-default": "^7.32.0",
    1313                "@wordpress/browserslist-config": "^5.31.0",
    14                 "@wordpress/env": "^5.6.0",
     14                "@wordpress/env": "^9.0.0",
    1515                "@wordpress/scripts": "^26.19.0",
    1616                "@wordpress/stylelint-config": "~19.1.0",
     
    50315031        },
    50325032        "node_modules/@wordpress/env": {
    5033             "version": "5.16.0",
    5034             "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-5.16.0.tgz",
    5035             "integrity": "sha512-zx6UO8PuJBrQ34cfeedK1HlGHLFaj7oWzTo9tTt+noB79Ttqc4+a0lYwDqBLLJhlHU+cWgcyOP2lB6TboXH0xA==",
     5033            "version": "9.0.0",
     5034            "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-9.0.0.tgz",
     5035            "integrity": "sha512-Fyec0k5N7kaXVIpTnJ2zO/n3CIiq8cPDsUaFoLVKI+yv2cVuq1dSQyc1lLXB9Gu+SNvmfbq7nNVVmNfKgpAkrw==",
    50365036            "dev": true,
    50375037            "dependencies": {
    50385038                "chalk": "^4.0.0",
    50395039                "copy-dir": "^1.3.0",
    5040                 "docker-compose": "^0.22.2",
     5040                "docker-compose": "^0.24.3",
    50415041                "extract-zip": "^1.6.7",
    50425042                "got": "^11.8.5",
     
    1111611116        },
    1111711117        "node_modules/docker-compose": {
    11118             "version": "0.22.2",
    11119             "resolved": "https://registry.npmjs.org/docker-compose/-/docker-compose-0.22.2.tgz",
    11120             "integrity": "sha512-iXWb5+LiYmylIMFXvGTYsjI1F+Xyx78Jm/uj1dxwwZLbWkUdH6yOXY5Nr3RjbYX15EgbGJCq78d29CmWQQQMPg==",
    11121             "dev": true,
     11118            "version": "0.24.3",
     11119            "resolved": "https://registry.npmjs.org/docker-compose/-/docker-compose-0.24.3.tgz",
     11120            "integrity": "sha512-x3/QN3AIOMe7j2c8f/jcycizMft7dl8MluoB9OGPAYCyKHHiPUFqI9GjCcsU0kYy24vYKMCcfR6+5ZaEyQlrxg==",
     11121            "dev": true,
     11122            "dependencies": {
     11123                "yaml": "^2.2.2"
     11124            },
    1112211125            "engines": {
    1112311126                "node": ">= 6.0.0"
     
    3145231455            "dev": true
    3145331456        },
     31457        "node_modules/yaml": {
     31458            "version": "2.3.4",
     31459            "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.4.tgz",
     31460            "integrity": "sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==",
     31461            "dev": true,
     31462            "engines": {
     31463                "node": ">= 14"
     31464            }
     31465        },
    3145431466        "node_modules/yargs": {
    3145531467            "version": "17.7.2",
  • trunk/package.json

    r13703 r13720  
    99        "@wordpress/browserslist-config": "^5.31.0",
    1010        "@wordpress/scripts": "^26.19.0",
    11         "@wordpress/env": "^5.6.0",
     11        "@wordpress/env": "^9.0.0",
    1212        "@wordpress/stylelint-config": "~19.1.0",
    1313        "autoprefixer": "^9.8.8",
     
    5252        "build:admin": "wp-scripts build --webpack-src-dir=src/js/admin --config src/js/admin/webpack.config.js && grunt move:admin:js",
    5353        "wp-env": "wp-env",
    54         "test-php": "npm run wp-env run phpunit 'php /var/www/html/wp-content/plugins/buddypress/vendor/phpunit/phpunit/phpunit -c /var/www/html/wp-content/plugins/buddypress/tests/phpunit/env.xml'",
    55         "test-php:group": "npm run wp-env run phpunit 'php /var/www/html/wp-content/plugins/buddypress/vendor/phpunit/phpunit/phpunit -c /var/www/html/wp-content/plugins/buddypress/tests/phpunit/env.xml --group $npm_confi_g'",
    56         "test-php-multisite": "npm run wp-env run phpunit 'php /var/www/html/wp-content/plugins/buddypress/vendor/phpunit/phpunit/phpunit -c /var/www/html/wp-content/plugins/buddypress/tests/phpunit/env.multisite.xml'",
    57         "test-php-multisite:group": "npm run wp-env run phpunit 'php /var/www/html/wp-content/plugins/buddypress/vendor/phpunit/phpunit/phpunit -c /var/www/html/wp-content/plugins/buddypress/tests/phpunit/env.multisite.xml --group $npm_confi_g'",
     54        "test-php": "npm run wp-env run cli -- --env-cwd=wp-content/plugins/buddypress composer test",
     55        "test-php:group": "npm run wp-env run cli -- --env-cwd=wp-content/plugins/buddypress composer test -- -- --group ",
     56        "test-php-multisite": "npm run wp-env run cli -- --env-cwd=wp-content/plugins/buddypress composer test_multi",
     57        "test-php-multisite:group": "npm run wp-env run cli -- --env-cwd=wp-content/plugins/buddypress composer test_multi -- -- --group ",
    5858        "download:cli": "curl -L -o 'cli-archive.zip' https://github.com/buddypress/wp-cli-buddypress/archive/2.0.2.zip && unzip -qq cli-archive.zip && mv wp-cli-buddypress-2.0.2 build/cli && rm cli-archive.zip",
    5959        "download:rest": "curl -L -o 'rest-archive.zip' https://github.com/buddypress/BP-REST/archive/master.zip && unzip -qq rest-archive.zip && mv BP-REST-master build/bp-rest && rm rest-archive.zip"
  • trunk/tests/phpunit/bootstrap.php

    r13314 r13720  
    11<?php
    22const WP_TESTS_PHPUNIT_POLYFILLS_PATH = __DIR__ . '/../../vendor/yoast/phpunit-polyfills';
    3 
    4 if ( defined( 'BP_USE_WP_ENV_TESTS' ) ) {
    5     // wp-env setup.
    6     define( 'WP_TESTS_CONFIG_FILE_PATH', dirname( __FILE__ ) . '/assets/phpunit-wp-config.php' );
    7     define( 'WP_TESTS_CONFIG_PATH', WP_TESTS_CONFIG_FILE_PATH );
    8 
    9     // Use WP PHPUnit.
    10     require_once dirname( dirname( dirname( __FILE__ ) ) ) . '/vendor/wp-phpunit/wp-phpunit/__loaded.php';
    11 }
    123
    134require( dirname( __FILE__ ) . '/includes/define-constants.php' );
  • trunk/tests/phpunit/includes/define-constants.php

    r12853 r13720  
    2121 *   up the directory tree
    2222 */
    23 if ( false !== getenv( 'WP_PHPUNIT__DIR' ) && defined( 'BP_USE_WP_ENV_TESTS' ) ) {
    24     define( 'WP_TESTS_DIR', getenv( 'WP_PHPUNIT__DIR' ) );
    25     define( 'WP_ROOT_DIR', '/var/www/html' );
    26 } elseif ( false !== getenv( 'WP_TESTS_DIR' ) ) {
     23if ( false !== getenv( 'WP_TESTS_DIR' ) ) {
    2724    define( 'WP_TESTS_DIR', getenv( 'WP_TESTS_DIR' ) );
    2825    define( 'WP_ROOT_DIR', WP_TESTS_DIR );
  • trunk/tests/phpunit/testcases/core/functions.php

    r13705 r13720  
    834834
    835835        $bp = buddypress();
     836        $reset_current_site = isset( $GLOBALS['current_site'] ) ? $GLOBALS['current_site'] : null;
    836837        $reset_bp_pages = $bp->pages;
    837838        $reset_bp_active_components = $bp->active_components;
     
    842843        ) );
    843844
     845        if ( defined( 'WP_HOME' ) ) {
     846            $GLOBALS['current_site']->domain = get_site( $b )->domain;
     847        }
     848
    844849        $bp->active_components['newcomponent'] = 1;
    845850        add_filter( 'bp_core_get_directory_page_default_titles', array( $this, 'add_newcomponent_page_title' ) );
     
    851856
    852857        $new_component_page_id = $bp_pages['newcomponent'];
     858
    853859        $this->assertNotSame( 'newcomponent', get_post_field( 'post_name', $new_component_page_id ), 'The component slug should not conflict with subsite name.' );
    854860
     
    858864        $bp->pages = $reset_bp_pages;
    859865        $bp->active_components = $reset_bp_active_components;
     866
     867        if ( defined( 'WP_HOME' ) ) {
     868            $GLOBALS['current_site'] = $reset_current_site;
     869        }
    860870    }
    861871
  • trunk/tests/phpunit/testcases/routing/members.php

    r13468 r13720  
    6565        remove_filter( 'bp_members_member_type_base', array( $this, 'filter_member_type_base' ) );
    6666
    67         $this->assertSame( $url, 'http://example.org/members/bp-member-type/foo/' );
     67        $this->assertSame( $url, 'http://' . trailingslashit( WP_TESTS_DOMAIN ) . 'members/bp-member-type/foo/' );
    6868    }
    6969
Note: See TracChangeset for help on using the changeset viewer.