Skip to:
Content

BuddyPress.org

Ticket #8317: 8317.3.patch

File 8317.3.patch, 9.8 KB (added by imath, 4 years ago)
  • .gitignore

    diff --git .gitignore .gitignore
    index f26f47fbd..cc3f92c79 100644
    npm-debug.log 
    2323
    2424# The build directory.
    2525build
     26
     27# The custom Docker config file.
     28.wp-env.override.json
  • new file .wp-env.json

    diff --git .wp-env.json .wp-env.json
    new file mode 100644
    index 000000000..5bbdc60b5
    - +  
     1{
     2        "core": "WordPress/WordPress#master",
     3        "plugins": [ ".", "buddypress/BP-REST#master" ],
     4        "config": {
     5                "WP_DEBUG": true,
     6                "SCRIPT_DEBUG": true
     7        }
     8}
  • composer.json

    diff --git composer.json composer.json
    index 216b1d8a6..d07167858 100644
     
    3232        },
    3333        "require-dev": {
    3434                "phpcompatibility/phpcompatibility-wp": "*",
    35                 "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3"
     35                "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3",
     36                "wp-phpunit/wp-phpunit": "^5.4"
    3637        }
    3738}
  • package.json

    diff --git package.json package.json
    index 93e123039..09f321716 100644
     
    88                "@babel/core": "~7.8.7",
    99                "@wordpress/babel-preset-default": "~4.10.0",
    1010                "@wordpress/browserslist-config": "~2.1.4",
     11                "@wordpress/env": "~1.6.0",
    1112                "autoprefixer": "~8.5.2",
    1213                "grunt": "~1.1.0",
    1314                "grunt-check-dependencies": "~1.0.0",
     
    4445                "build": "npm run build:components && parcel build src/js/bp-*/*s/blocks/*.js --out-dir build",
    4546                "watch:components": "parcel watch src/js/bp-core/js/block-components/block-components.js --out-dir src/bp-core/js --out-file block-components.js --no-source-maps --global bp",
    4647                "dev:components": "parcel build src/js/bp-core/js/block-components/block-components.js --out-dir src/bp-core/js --out-file block-components.js --no-source-maps --no-minify --global bp",
    47                 "build:components": "parcel build src/js/bp-core/js/block-components/block-components.js --out-dir build/bp-core/js --out-file block-components.js --global bp"
     48                "build:components": "parcel build src/js/bp-core/js/block-components/block-components.js --out-dir build/bp-core/js --out-file block-components.js --global bp",
     49                "wp-env": "wp-env",
     50                "test-php": "npm run wp-env run phpunit 'phpunit -c /var/www/html/wp-content/plugins/buddypress/tests/phpunit/env.xml'",
     51                "test-php-multisite": "npm run wp-env run phpunit 'phpunit -c /var/www/html/wp-content/plugins/buddypress/tests/phpunit/env.multisite.xml'"
    4852        },
    4953        "keywords": [
    5054                "activity",
  • new file tests/phpunit/assets/phpunit-wp-config.php

    diff --git tests/phpunit/assets/phpunit-wp-config.php tests/phpunit/assets/phpunit-wp-config.php
    new file mode 100644
    index 000000000..5113dd55b
    - +  
     1<?php
     2/**
     3 * The base configuration for WordPress
     4 *
     5 * The wp-config.php creation script uses this file during the
     6 * installation. You don't have to use the web site, you can
     7 * copy this file to "wp-config.php" and fill in the values.
     8 *
     9 * This file contains the following configurations:
     10 *
     11 * * MySQL settings
     12 * * Secret keys
     13 * * Database table prefix
     14 * * ABSPATH
     15 *
     16 * @link https://wordpress.org/support/article/editing-wp-config-php/
     17 *
     18 * @package WordPress
     19 */
     20
     21// ** MySQL settings - You can get this info from your web host ** //
     22/** The name of the database for WordPress */
     23define( 'DB_NAME', 'tests-wordpress');
     24
     25/** MySQL database username */
     26define( 'DB_USER', 'root');
     27
     28/** MySQL database password */
     29define( 'DB_PASSWORD', '');
     30
     31/** MySQL hostname */
     32define( 'DB_HOST', 'mysql');
     33
     34/** Database Charset to use in creating database tables. */
     35define( 'DB_CHARSET', 'utf8');
     36
     37/** The Database Collate type. Don't change this if in doubt. */
     38define( 'DB_COLLATE', '');
     39
     40/**#@+
     41 * Authentication Unique Keys and Salts.
     42 *
     43 * Change these to different unique phrases!
     44 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
     45 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
     46 *
     47 * @since 2.6.0
     48 */
     49define( 'AUTH_KEY',         'a89b7f2679fa896912a0bc6663b8c1dee8845e0e');
     50define( 'SECURE_AUTH_KEY',  '0819cb8ebad69f537adc5351b095a91e3fee5fbd');
     51define( 'LOGGED_IN_KEY',    'ea0ab2035e22b76f751a44df6a89d85c44f9ba1f');
     52define( 'NONCE_KEY',        '4665de6759a3f771be0509b8964c0dee8b12cc3e');
     53define( 'AUTH_SALT',        'cd8ff2945b6e3bf3257845f6f1c14de673f38bb1');
     54define( 'SECURE_AUTH_SALT', 'd9c8a7a96d41e863c0e8517632e0d4f1ab135d49');
     55define( 'LOGGED_IN_SALT',   '318a8828a24ea9fa51d10a0aabb92d419c716e3e');
     56define( 'NONCE_SALT',       '08e12a5848e0f7516e1b527497239c41f55904ab');
     57
     58/**#@-*/
     59
     60/**
     61 * WordPress Database Table prefix.
     62 *
     63 * You can have multiple installations in one database if you give each
     64 * a unique prefix. Only numbers, letters, and underscores please!
     65 */
     66$table_prefix = 'wptests_';
     67
     68/**
     69 * Test with WordPress debug mode (default).
     70 */
     71define( 'WP_DEBUG', true );
     72
     73// Set Site domain, email and title constants.
     74define( 'WP_TESTS_DOMAIN', 'example.org' );
     75define( 'WP_TESTS_EMAIL', 'admin@example.org' );
     76define( 'WP_TESTS_TITLE', 'Test BP' );
     77
     78define( 'WP_PHP_BINARY', 'php' );
     79
     80/** Absolute path to the WordPress directory. */
     81if ( ! defined( 'ABSPATH' ) ) {
     82        define( 'ABSPATH', '/var/www/html/' );
     83}
  • tests/phpunit/bootstrap.php

    diff --git tests/phpunit/bootstrap.php tests/phpunit/bootstrap.php
    index 4e517f9ab..18097fc1e 100644
     
    11<?php
    22
     3if ( defined( 'BP_USE_WP_ENV_TESTS' ) ) {
     4        // wp-env setup.
     5        define( 'WP_TESTS_CONFIG_FILE_PATH', dirname( __FILE__ ) . '/assets/phpunit-wp-config.php' );
     6        define( 'WP_TESTS_CONFIG_PATH', WP_TESTS_CONFIG_FILE_PATH );
     7
     8        // Use WP PHPUnit.
     9        require_once dirname( dirname( dirname( __FILE__ ) ) ) . '/vendor/wp-phpunit/wp-phpunit/__loaded.php';
     10}
     11
    312require( dirname( __FILE__ ) . '/includes/define-constants.php' );
    413
    514if ( ! file_exists( WP_TESTS_DIR . '/includes/functions.php' ) ) {
  • new file tests/phpunit/env.multisite.xml

    diff --git tests/phpunit/env.multisite.xml tests/phpunit/env.multisite.xml
    new file mode 100644
    index 000000000..e40b4b6ff
    - +  
     1<phpunit
     2        bootstrap="bootstrap.php"
     3        backupGlobals="false"
     4        colors="true"
     5        convertErrorsToExceptions="true"
     6        convertNoticesToExceptions="true"
     7        convertWarningsToExceptions="true"
     8        >
     9        <php>
     10                <const name="WP_TESTS_MULTISITE" value="1" />
     11                <const name="BP_USE_WP_ENV_TESTS" value="1" />
     12        </php>
     13        <testsuites>
     14                <testsuite name="default">
     15                        <directory suffix=".php">./testcases/</directory>
     16                </testsuite>
     17        </testsuites>
     18</phpunit>
  • new file tests/phpunit/env.xml

    diff --git tests/phpunit/env.xml tests/phpunit/env.xml
    new file mode 100644
    index 000000000..314564af1
    - +  
     1<phpunit
     2        bootstrap="bootstrap.php"
     3        backupGlobals="false"
     4        colors="true"
     5        convertErrorsToExceptions="true"
     6        convertNoticesToExceptions="true"
     7        convertWarningsToExceptions="true"
     8        >
     9        <php>
     10                <const name="BP_USE_WP_ENV_TESTS" value="1" />
     11        </php>
     12        <testsuites>
     13                <testsuite name="default">
     14                        <directory suffix=".php">./testcases/</directory>
     15                </testsuite>
     16        </testsuites>
     17</phpunit>
  • tests/phpunit/includes/define-constants.php

    diff --git tests/phpunit/includes/define-constants.php tests/phpunit/includes/define-constants.php
    index 1b4e0e9d9..a2805a73a 100644
    if ( ! defined( 'BP_TESTS_DIR' ) ) { 
    2020 * - Assume that we are inside of a develop.svn.wordpress.org setup, and walk
    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 );
    2629} else {
    if ( false !== getenv( 'WP_TESTS_DIR' ) ) { 
    3437        define( 'WP_TESTS_DIR', WP_ROOT_DIR . '/tests/phpunit' );
    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}
  • tests/phpunit/includes/loader.php

    diff --git tests/phpunit/includes/loader.php tests/phpunit/includes/loader.php
    index df7dc0b5f..db083bb0b 100644
    foreach ( $components as $component ) { 
    3737                        }
    3838                }
    3939        } );
    40 }
    41  No newline at end of file
     40}