WordPress.org

Make WordPress Core

Changeset 50602


Ignore:
Timestamp:
03/26/2021 05:21:35 PM (7 months ago)
Author:
desrosj
Message:

Build/Test Tools: Backport GitHub Action and build improvements to the 5.6 branch.

This backports several build and test tool improvements to the 5.6 branch. Most notably, this includes:

  • The changes required to allow each workflow to be triggered by the workflow_dispatch event so that tests can be run on a schedule [50590].
  • The ability to run PHPUnit tests from src instead of build [50441-50443].
  • Splitting single site and multisite tests into parallel jobs [50379].
  • Split slow tests into separate, parallel jobs for PHP 5.6 [50444].
  • Better branch and path scoping for GitHub Action workflows when running on pull_request [50432,50479].
  • Several devDependency updates.

Merges [50267,50299,50379,50387,50413,50416,50432,50435-50436,50441-50444,50446,50473-50474,50476,50479,50485-50487,50545,50579,50590,50592,50598] to the 5.6 branch.
See #50401, #51734, #51801, #51802, #52548, #52608, #52612, #52623, #52624, #52625, #52645, #52653, #52658, #52660, #52667, #52786.

Location:
branches/5.6
Files:
2 added
3 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

  • branches/5.6/.github/workflows/coding-standards.yml

    r50301 r50602  
    22
    33on:
     4  # JSHint was introduced in WordPress 3.8.
     5  # PHPCS checking was introduced in WordPress 5.1.
    46  push:
    57    branches:
    68      - master
    7       # JSHint was introduced in WordPress 3.8.
    8       # PHPCS checking was introduced in WordPress 5.1.
     9      - trunk
    910      - '3.[89]'
    1011      - '[4-9].[0-9]'
     
    1314      - '[4-9].[0-9]*'
    1415  pull_request:
     16    branches:
     17      - master
     18      - trunk
     19      - '3.[89]'
     20      - '[4-9].[0-9]'
     21    paths:
     22      # Any change to a PHP or JavaScript file should run checks.
     23      - '**.js'
     24      - '**.php'
     25      # These files configure NPM. Changes could affect the outcome.
     26      - 'package*.json'
     27      # These files configure Composer. Changes could affect the outcome.
     28      - 'composer.*'
     29      # This file configures JSHint. Changes could affect the outcome.
     30      - '.jshintrc'
     31      # This file configures PHPCS. Changes could affect the outcome.
     32      - 'phpcs.xml.dist'
     33      # Changes to workflow files should always verify all workflows are successful.
     34      - '.github/workflows/*.yml'
     35  workflow_dispatch:
    1536
    1637jobs:
     
    3657    steps:
    3758      - name: Checkout repository
    38         uses: actions/checkout@v2
     59        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    3960
    4061      - name: Set up PHP
    41         uses: shivammathur/setup-php@v2
     62        uses: shivammathur/setup-php@afefcaf556d98dc7896cca380e181decb609ca44 # v2.10.0
    4263        with:
    4364          php-version: '7.4'
     
    5172
    5273      - name: Install Composer dependencies
    53         uses: ramsey/composer-install@v1
     74        uses: ramsey/composer-install@92a7904348d4ad30236f3611e33b7f0c6f9edd70 # v1.1.0
    5475        with:
    5576          composer-options: "--no-progress --no-ansi --no-interaction"
     
    89110    steps:
    90111      - name: Checkout repository
    91         uses: actions/checkout@v2
     112        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    92113
    93114      - name: Log debug information
     
    99120
    100121      - name: Install NodeJS
    101         uses: actions/setup-node@v1
     122        uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
    102123        with:
    103124          node-version: 14
    104125
    105126      - name: Cache NodeJS modules
    106         uses: actions/cache@v2
     127        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    107128        env:
    108129          cache-name: cache-node-modules
     
    111132          path: ~/.npm
    112133          key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    113           restore-keys: |
    114             ${{ runner.os }}-npm-
    115134
    116135      - name: Log debug information
     
    120139
    121140      - name: Install Dependencies
    122         run: npx install-changed --install-command="npm ci"
     141        run: npm ci
    123142
    124143      - name: Run JSHint
  • branches/5.6/.github/workflows/javascript-tests.yml

    r50301 r50602  
    22
    33on:
     4  # JavaScript testing was introduced in WordPress 3.8.
    45  push:
    56    branches:
    67      - master
    7       # JavaScript testing was introduced in WordPress 3.8.
     8      - trunk
    89      - '3.[89]'
    910      - '[4-9].[0-9]'
     
    1213      - '[4-9].[0-9]*'
    1314  pull_request:
     15    branches:
     16      - master
     17      - trunk
     18      - '3.[89]'
     19      - '[4-9].[0-9]'
     20    paths:
     21      # Any change to a JavaScript file should run tests.
     22      - '**.js'
     23      # These files configure NPM. Changes could affect the outcome.
     24      - 'package*.json'
     25      # This file configures ESLint. Changes could affect the outcome.
     26      - '.eslintignore'
     27      # This file configures JSHint. Changes could affect the outcome.
     28      - '.jshintrc'
     29      # Any change to the QUnit directory should run tests.
     30      - 'tests/qunit/**'
     31      # Changes to workflow files should always verify all workflows are successful.
     32      - '.github/workflows/*.yml'
     33  workflow_dispatch:
    1434
    1535jobs:
     
    3454      - name: Cancel previous runs of this workflow (pull requests only)
    3555        if: ${{ github.event_name == 'pull_request' }}
    36         uses: styfle/cancel-workflow-action@0.5.0
    37         with:
    38           access_token: ${{ github.token }}
     56        uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0
    3957
    4058      - name: Checkout repository
    41         uses: actions/checkout@v2
     59        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    4260
    4361      - name: Log debug information
     
    4967
    5068      - name: Install NodeJS
    51         uses: actions/setup-node@v1
     69        uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
    5270        with:
    5371          node-version: 14
    5472
    5573      - name: Cache NodeJS modules
    56         uses: actions/cache@v2
     74        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    5775        env:
    5876          cache-name: cache-node-modules
     
    6179          path: ~/.npm
    6280          key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    63           restore-keys: |
    64             ${{ runner.os }}-npm-
    6581
    6682      - name: Log debug information
     
    7086
    7187      - name: Install Dependencies
    72         run: npx install-changed --install-command="npm ci"
     88        run: npm ci
    7389
    7490      - name: Run QUnit tests
  • branches/5.6/.github/workflows/php-compatibility.yml

    r50301 r50602  
    22
    33on:
     4  # PHP compatibility testing was introduced in WordPress 5.5.
    45  push:
    56    branches:
    67      - master
    7       # The PHP compatibility testing was introduced in WordPress 5.5.
     8      - trunk
    89      - '5.[5-9]'
    910      - '[6-9].[0-9]'
     
    1213      - '[6-9].[0-9]*'
    1314  pull_request:
     15    branches:
     16      - master
     17      - trunk
     18      - '5.[5-9]'
     19      - '[6-9].[0-9]'
     20    paths:
     21      # This workflow only scans PHP files.
     22      - '**.php'
     23      # These files configure Composer. Changes could affect the outcome.
     24      - 'composer.*'
     25      # This file configures PHP Compatibility scanning. Changes could affect the outcome.
     26      - 'phpcompat.xml.dist'
     27      # Changes to workflow files should always verify all workflows are successful.
     28      - '.github/workflows/*.yml'
     29  workflow_dispatch:
    1430
    1531jobs:
     
    3551    steps:
    3652      - name: Checkout repository
    37         uses: actions/checkout@v2
     53        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    3854
    3955      - name: Set up PHP
    40         uses: shivammathur/setup-php@v2
     56        uses: shivammathur/setup-php@afefcaf556d98dc7896cca380e181decb609ca44 # v2.10.0
    4157        with:
    4258          php-version: '7.4'
     
    5066
    5167      - name: Install Composer dependencies
    52         uses: ramsey/composer-install@v1
     68        uses: ramsey/composer-install@92a7904348d4ad30236f3611e33b7f0c6f9edd70 # v1.1.0
    5369        with:
    5470          composer-options: "--no-progress --no-ansi --no-interaction"
  • branches/5.6/.github/workflows/phpunit-tests.yml

    r50301 r50602  
    55    branches:
    66      - master
     7      - trunk
    78      - '3.[7-9]'
    89      - '[4-9].[0-9]'
     
    1112      - '[4-9].[0-9]*'
    1213  pull_request:
     14    branches:
     15      - master
     16      - trunk
     17      - '3.[7-9]'
     18      - '[4-9].[0-9]'
     19  workflow_dispatch:
    1320  # Once weekly On Sundays at 00:00 UTC.
    1421  schedule:
     
    1623
    1724env:
    18   LOCAL_DIR: build
    1925  PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
    2026  COMPOSER_INSTALL: ${{ false }}
     
    2228  PHPUNIT_SCRIPT: php
    2329  LOCAL_PHP_MEMCACHED: ${{ false }}
     30  SLOW_TESTS: 'external-http,media,restapi'
    2431
    2532jobs:
    26   # Sets up WordPress for testing or development use.
     33  # Sets up the workflow for testing.
    2734  #
    2835  # Performs the following steps:
    2936  # - Cancels all previous workflow runs for pull requests that have not completed.
    30   # - Checks out the repository.
    31   # - Logs debug information about the runner container.
    32   # - Installs NodeJS 14.
    33   # - Sets up caching for NPM.
    34   # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
    35   # - Builds WordPress to run from the `build` directory.
    36   # - Creates a ZIP file of compiled WordPress.
    37   # - Uploads ZIP file as an artifact.
    38   setup-wordpress:
    39     name: Setup WordPress
     37  setup-workflow:
     38    name: Setup Workflow
    4039    runs-on: ubuntu-latest
    4140    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
     
    4443      - name: Cancel previous runs of this workflow (pull requests only)
    4544        if: ${{ github.event_name == 'pull_request' }}
    46         uses: styfle/cancel-workflow-action@0.5.0
    47         with:
    48           access_token: ${{ github.token }}
    49 
    50       - name: Checkout repository
    51         uses: actions/checkout@v2
    52 
    53       - name: Log debug information
    54         run: |
    55           echo "$GITHUB_REF"
    56           echo "$GITHUB_EVENT_NAME"
    57           npm --version
    58           node --version
    59           curl --version
    60           git --version
    61           svn --version
    62           php --version
    63           php -i
    64           locale -a
    65 
    66       - name: Install NodeJS
    67         uses: actions/setup-node@v1
    68         with:
    69           node-version: 14
    70 
    71       - name: Cache NodeJS modules
    72         uses: actions/cache@v2
    73         env:
    74           cache-name: cache-node-modules
    75         with:
    76           # npm cache files are stored in `~/.npm` on Linux/macOS
    77           path: ~/.npm
    78           key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    79           restore-keys: |
    80             ${{ runner.os }}-npm-
    81 
    82       - name: Install Dependencies
    83         run: npx install-changed --install-command="npm ci"
    84 
    85       - name: Build WordPress
    86         run: npm run build
    87 
    88       - name: Create ZIP artifact
    89         uses: thedoctor0/zip-release@0.4.1
    90         with:
    91           filename: built-wp-${{ github.sha }}.zip
    92           exclusions: '*.git* /*node_modules/* packagehash.txt'
    93 
    94       - name: Upload build artifact
    95         uses: actions/upload-artifact@v2
    96         with:
    97           name: built-wp-${{ github.sha }}
    98           path: built-wp-${{ github.sha }}.zip
    99           if-no-files-found: error
     45        uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0
    10046
    10147  # Runs the PHPUnit tests for WordPress.
     
    10450  # - Set environment variables.
    10551  # - Sets up the environment variables needed for testing with memcached (if desired).
    106   # - Downloads the built WordPress artifact from the previous job.
    107   # - Unzips the artifact.
    10852  # - Installs NodeJS 14.
    10953  # - Sets up caching for NPM.
    110   # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
     54  # - Installs NPM dependencies
    11155  # - Configures caching for Composer.
    112   # _ Installs Composer dependencies (if desired).
     56  # - Installs Composer dependencies (if desired).
    11357  # - Logs Docker debug information (about both the Docker installation within the runner).
    11458  # - Starts the WordPress Docker container.
     
    12569  # - todo: Configure Slack notifications for failing tests.
    12670  test-php:
    127     name: ${{ matrix.php }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
    128     needs: setup-wordpress
     71    name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.split_slow && ' slow tests' || '' }} ${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
    12972    runs-on: ${{ matrix.os }}
    13073    strategy:
     74      fail-fast: false
    13175      matrix:
    132         php: [ '8.0', '7.4', '7.3', '7.2', '7.1', '7.0', '5.6.20' ]
     76        php: [ '5.6.20', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
    13377        os: [ ubuntu-latest ]
    13478        memcached: [ false ]
     79        split_slow: [ false ]
     80        multisite: [ false, true ]
    13581        include:
    136           # Include job for PHP 7.4 with memcached.
     82          # Additional "slow" jobs for PHP 5.6.
     83          - php: '5.6.20'
     84            os: ubuntu-latest
     85            memcached: false
     86            multisite: false
     87            split_slow: true
     88          - php: '5.6.20'
     89            os: ubuntu-latest
     90            memcached: false
     91            multisite: true
     92            split_slow: true
     93          # Include jobs for PHP 7.4 with memcached.
    13794          - php: '7.4'
    13895            os: ubuntu-latest
    13996            memcached: true
     97            multisite: false
     98          - php: '7.4'
     99            os: ubuntu-latest
     100            memcached: true
     101            multisite: true
    140102          # Report the results of the PHP 7.4 without memcached job.
    141103          - php: '7.4'
    142104            os: ubuntu-latest
    143105            memcached: false
     106            multisite: false
    144107            report: true
    145108    env:
    146109      LOCAL_PHP: ${{ matrix.php }}-fpm
    147110      LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }}
     111      PHPUNIT_CONFIG: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
    148112
    149113    steps:
     
    153117          echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
    154118
    155       - name: Download the built WordPress artifact
    156         uses: actions/download-artifact@v2
    157         with:
    158           name: built-wp-${{ github.sha }}
    159 
    160       - name: Unzip built artifact
    161         run: unzip built-wp-${{ github.sha }}.zip
     119      - name: Checkout repository
     120        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    162121
    163122      - name: Install NodeJS
    164         uses: actions/setup-node@v1
     123        uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
    165124        with:
    166125          node-version: 14
    167126
    168127      - name: Use cached Node modules
    169         uses: actions/cache@v2
     128        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    170129        env:
    171130          cache-name: cache-node-modules
     
    174133          path: ~/.npm
    175134          key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    176           restore-keys: |
    177             ${{ runner.os }}-npm-
    178135
    179136      - name: Install Dependencies
    180         run: npx install-changed --install-command="npm ci"
     137        run: npm ci
    181138
    182139      - name: Get composer cache directory
     
    187144      - name: Cache Composer dependencies
    188145        if: ${{ env.COMPOSER_INSTALL == true || env.LOCAL_PHP == '8.0-fpm' }}
    189         uses: actions/cache@v2
     146        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    190147        env:
    191148          cache-name: cache-composer-dependencies
     
    193150          path: ${{ steps.composer-cache.outputs.dir }}
    194151          key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
    195           restore-keys: |
    196             ${{ runner.os }}-php-${{ matrix.php }}-composer-
    197152
    198153      - name: Install Composer dependencies
     
    224179        if: ${{ matrix.memcached }}
    225180        run: |
    226           cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php
     181          cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
    227182          docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached
    228183
     
    249204        run: npm run env:install
    250205
     206      - name: Run slow PHPUnit tests
     207        if: ${{ matrix.split_slow }}
     208        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
     209
     210      - name: Run PHPUnit tests for single site excluding slow tests
     211        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }}
     212        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required
     213
     214      - name: Run PHPUnit tests for Multisite excluding slow tests
     215        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }}
     216        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers
     217
    251218      - name: Run PHPUnit tests
    252         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist
     219        if: ${{ matrix.php >= '7.0' }}
     220        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }}
    253221
    254222      - name: Run AJAX tests
    255         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group ajax
    256 
    257       - name: Run tests as a multisite install
    258         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml
     223        if: ${{ ! matrix.split_slow && ! matrix.multisite }}
     224        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
    259225
    260226      - name: Run ms-files tests as a multisite install
     227        if: ${{ matrix.multisite && ! matrix.split_slow }}
    261228        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files
    262229
    263230      - name: Run external HTTP tests
     231        if: ${{ ! matrix.multisite && ! matrix.split_slow }}
    264232        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group external-http
    265233
    266       - name: Run REST API tests
    267         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group restapi-jsclient
    268 
    269       # Xdebug supports PHP 8 only from version 3.0, which is not released yet.
    270       # Once Xdebug 3.0 is released and included in the Docker image, the IF condition should be removed.
    271234      # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
    272235      - name: Run (xDebug) tests
    273         if: ${{ env.LOCAL_PHP != '8.0-fpm' }}
    274         run: LOCAL_PHP_XDEBUG=true npm run test:php -- -v --group xdebug --exclude-group __fakegroup__
     236        if: ${{ ! matrix.split_slow }}
     237        run: LOCAL_PHP_XDEBUG=true npm run test:${{ env.PHPUNIT_SCRIPT }} -- -v --group xdebug --exclude-group __fakegroup__
    275238
    276239      - name: Checkout the WordPress Test Reporter
    277240        if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
    278         uses: actions/checkout@v2
     241        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    279242        with:
    280243          repository: 'WordPress/phpunit-test-runner'
    281244          path: 'test-runner'
    282 
    283       - name: Set up the Git repository
    284         if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
    285         run: |
    286           git init
    287           git remote add origin https://github.com/WordPress/wordpress-develop.git
    288           git fetch
    289           git reset origin/master
    290245
    291246      - name: Submit test results to the WordPress.org host test results
  • branches/5.6/.github/workflows/welcome-new-contributors.yml

    r50296 r50602  
    1212
    1313    steps:
    14       - uses: bubkoo/welcome-action@v1
     14      - uses: bubkoo/welcome-action@8dbbac2540d155744c90e4e37da6b05ffc9c5e2c # v1.0.3
    1515        with:
    1616          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  • branches/5.6/Gruntfile.js

    r50459 r50602  
    88    var path = require('path'),
    99        fs = require( 'fs' ),
     10        glob = require( 'glob' ),
     11        assert = require( 'assert' ).strict,
    1012        spawn = require( 'child_process' ).spawnSync,
    1113        SOURCE_DIR = 'src/',
     
    14301432    ] );
    14311433
     1434    /**
     1435     * Build verification tasks.
     1436     */
     1437    grunt.registerTask( 'verify:build', [
     1438        'verify:wp-embed',
     1439        'verify:old-files',
     1440        'verify:source-maps',
     1441    ] );
     1442
     1443    /**
     1444     * Build assertions for wp-embed.min.js.
     1445     *
     1446     * @ticket 34698
     1447     */
     1448    grunt.registerTask( 'verify:wp-embed', function() {
     1449        const file = `${ BUILD_DIR }/wp-includes/js/wp-embed.min.js`;
     1450
     1451        assert(
     1452            fs.existsSync( file ),
     1453            'The build/wp-includes/js/wp-embed.min.js file does not exist.'
     1454        );
     1455
     1456        const contents = fs.readFileSync( file, {
     1457            encoding: 'utf8',
     1458        } );
     1459
     1460        assert(
     1461            contents.length > 0,
     1462            'The build/wp-includes/js/wp-embed.min.js file must not be empty.'
     1463        );
     1464        assert(
     1465            false === contents.includes( '&' ),
     1466            'The build/wp-includes/js/wp-embed.min.js file must not contain ampersands.'
     1467        );
     1468    } );
     1469
     1470    /**
     1471     * Build assertions to ensure no project files are inside `$_old_files` in the build directory.
     1472     *
     1473     * @ticket 36083
     1474     */
     1475    grunt.registerTask( 'verify:old-files', function() {
     1476        const file = `${ BUILD_DIR }wp-admin/includes/update-core.php`;
     1477
     1478        assert(
     1479            fs.existsSync( file ),
     1480            'The build/wp-admin/includes/update-core.php file does not exist.'
     1481        );
     1482
     1483        const contents = fs.readFileSync( file, {
     1484            encoding: 'utf8',
     1485        } );
     1486
     1487        assert(
     1488            contents.length > 0,
     1489            'The build/wp-admin/includes/update-core.php file must not be empty.'
     1490        );
     1491
     1492        const match = contents.match( /\$_old_files = array\(([^\)]+)\);/ );
     1493
     1494        assert(
     1495            match.length > 0,
     1496            'The build/wp-admin/includes/update-core.php file does not include an `$_old_files` array.'
     1497        );
     1498
     1499        const files = match[1].split( '\n\t' ).filter( function( file ) {
     1500            // Filter out empty lines
     1501            if ( '' === file ) {
     1502                return false;
     1503            }
     1504
     1505            // Filter out commented out lines
     1506            if ( 0 === file.indexOf( '/' ) ) {
     1507                return false;
     1508            }
     1509
     1510            return true;
     1511        } ).map( function( file ) {
     1512            // Strip leading and trailing single quotes and commas
     1513            return file.replace( /^\'|\',$/g, '' );
     1514        } );
     1515
     1516        files.forEach(function( file ){
     1517            const search = `${ BUILD_DIR }${ file }`;
     1518            assert(
     1519                false === fs.existsSync( search ),
     1520                `${ search } should not be present in the $_old_files array.`
     1521            );
     1522        });
     1523    } );
     1524
     1525    /**
     1526     * Build assertions for the lack of source maps in JavaScript files.
     1527     *
     1528     * @ticket 24994
     1529     * @ticket 46218
     1530     */
     1531    grunt.registerTask( 'verify:source-maps', function() {
     1532        const path = `${ BUILD_DIR }**/*.js`;
     1533        const files = glob.sync( path );
     1534
     1535        assert(
     1536            files.length > 0,
     1537            'No JavaScript files found in the build directory.'
     1538        );
     1539
     1540        files.forEach( function( file ) {
     1541            const contents = fs.readFileSync( file, {
     1542                encoding: 'utf8',
     1543            } );
     1544            // `data:` URLs are allowed:
     1545            const match = contents.match( /sourceMappingURL=((?!data:).)/ );
     1546
     1547            assert(
     1548                match === null,
     1549                `The ${ file } file must not contain a sourceMappingURL.`
     1550            );
     1551        } );
     1552    } );
     1553
    14321554    grunt.registerTask( 'build', function() {
    14331555        if ( grunt.option( 'dev' ) ) {
     
    14431565                'includes:emoji',
    14441566                'includes:embed',
    1445                 'replace:emojiBannerText'
     1567                'replace:emojiBannerText',
     1568                'verify:build'
    14461569            ] );
    14471570        }
  • branches/5.6/README.md

    r49598 r50602  
    4444
    4545```
    46 npm run watch
     46npm run dev
    4747```
    4848
  • branches/5.6/package-lock.json

    r50405 r50602  
    71877187        },
    71887188        "check-node-version": {
    7189             "version": "4.0.3",
    7190             "resolved": "https://registry.npmjs.org/check-node-version/-/check-node-version-4.0.3.tgz",
    7191             "integrity": "sha512-kbnOaF7SE1uasWx3hqxzsU2yz7I+rkxSMuTW0eKoF39eUtSR/a0F4Sm35LwJNx4itOIARf9eLhWHOOh7rlZ5/g==",
     7189            "version": "4.1.0",
     7190            "resolved": "https://registry.npmjs.org/check-node-version/-/check-node-version-4.1.0.tgz",
     7191            "integrity": "sha512-TSXGsyfW5/xY2QseuJn8/hleO2AU7HxVCdkc900jp1vcfzF840GkjvRT7CHl8sRtWn23n3X3k0cwH9RXeRwhfw==",
    71927192            "dev": true,
    71937193            "requires": {
     
    73997399        },
    74007400        "clean-css": {
    7401             "version": "4.2.1",
    7402             "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.1.tgz",
    7403             "integrity": "sha512-4ZxI6dy4lrY6FHzfiy1aEOXgu4LIsW2MhwG0VBKdcoGoH/XLFgaHSdLTGr4O8Be6A8r3MOphEiI8Gc1n0ecf3g==",
     7401            "version": "5.1.2",
     7402            "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.1.2.tgz",
     7403            "integrity": "sha512-QcaGg9OuMo+0Ds933yLOY+gHPWbxhxqF0HDexmToPf8pczvmvZGYzd+QqWp9/mkucAOKViI+dSFOqoZIvXbeBw==",
    74047404            "dev": true,
    74057405            "requires": {
     
    1278812788        },
    1278912789        "grunt-contrib-cssmin": {
    12790             "version": "3.0.0",
    12791             "resolved": "https://registry.npmjs.org/grunt-contrib-cssmin/-/grunt-contrib-cssmin-3.0.0.tgz",
    12792             "integrity": "sha512-eXpooYmVGKMs/xV7DzTLgJFPVOfMuawPD3x0JwhlH0mumq2NtH3xsxaHxp1Y3NKxp0j0tRhFS6kSBRsz6TuTGg==",
    12793             "dev": true,
    12794             "requires": {
    12795                 "chalk": "^2.4.1",
    12796                 "clean-css": "~4.2.1",
    12797                 "maxmin": "^2.1.0"
    12798             },
    12799             "dependencies": {
    12800                 "ansi-styles": {
    12801                     "version": "3.2.1",
    12802                     "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
    12803                     "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
    12804                     "dev": true,
    12805                     "requires": {
    12806                         "color-convert": "^1.9.0"
    12807                     }
    12808                 },
    12809                 "chalk": {
    12810                     "version": "2.4.2",
    12811                     "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
    12812                     "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
    12813                     "dev": true,
    12814                     "requires": {
    12815                         "ansi-styles": "^3.2.1",
    12816                         "escape-string-regexp": "^1.0.5",
    12817                         "supports-color": "^5.3.0"
    12818                     }
    12819                 },
    12820                 "supports-color": {
    12821                     "version": "5.5.0",
    12822                     "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
    12823                     "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
    12824                     "dev": true,
    12825                     "requires": {
    12826                         "has-flag": "^3.0.0"
    12827                     }
     12790            "version": "4.0.0",
     12791            "resolved": "https://registry.npmjs.org/grunt-contrib-cssmin/-/grunt-contrib-cssmin-4.0.0.tgz",
     12792            "integrity": "sha512-jXU+Zlk8Q8XztOGNGpjYlD/BDQ0n95IHKrQKtFR7Gd8hZrzgqiG1Ra7cGYc8h2DD9vkSFGNlweb9Q00rBxOK2w==",
     12793            "dev": true,
     12794            "requires": {
     12795                "chalk": "^4.1.0",
     12796                "clean-css": "^5.0.1",
     12797                "maxmin": "^3.0.0"
     12798            },
     12799            "dependencies": {
     12800                "figures": {
     12801                    "version": "3.2.0",
     12802                    "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
     12803                    "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==",
     12804                    "dev": true,
     12805                    "requires": {
     12806                        "escape-string-regexp": "^1.0.5"
     12807                    }
     12808                },
     12809                "maxmin": {
     12810                    "version": "3.0.0",
     12811                    "resolved": "https://registry.npmjs.org/maxmin/-/maxmin-3.0.0.tgz",
     12812                    "integrity": "sha512-wcahMInmGtg/7c6a75fr21Ch/Ks1Tb+Jtoan5Ft4bAI0ZvJqyOw8kkM7e7p8hDSzY805vmxwHT50KcjGwKyJ0g==",
     12813                    "dev": true,
     12814                    "requires": {
     12815                        "chalk": "^4.1.0",
     12816                        "figures": "^3.2.0",
     12817                        "gzip-size": "^5.1.1",
     12818                        "pretty-bytes": "^5.3.0"
     12819                    }
     12820                },
     12821                "pretty-bytes": {
     12822                    "version": "5.6.0",
     12823                    "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz",
     12824                    "integrity": "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==",
     12825                    "dev": true
    1282812826                }
    1282912827            }
     
    1831818316        },
    1831918317        "nise": {
    18320             "version": "4.0.4",
    18321             "resolved": "https://registry.npmjs.org/nise/-/nise-4.0.4.tgz",
    18322             "integrity": "sha512-bTTRUNlemx6deJa+ZyoCUTRvH3liK5+N6VQZ4NIw90AgDXY6iPnsqplNFf6STcj+ePk0H/xqxnP75Lr0J0Fq3A==",
     18318            "version": "4.1.0",
     18319            "resolved": "https://registry.npmjs.org/nise/-/nise-4.1.0.tgz",
     18320            "integrity": "sha512-eQMEmGN/8arp0xsvGoQ+B1qvSkR73B1nWSCh7nOt5neMCtwcQVYQGdzQMhcNscktTsWB54xnlSQFzOAPJD8nXA==",
    1832318321            "dev": true,
    1832418322            "requires": {
     
    2072420722                },
    2072520723                "mime-db": {
    20726                     "version": "1.45.0",
    20727                     "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.45.0.tgz",
    20728                     "integrity": "sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w==",
     20724                    "version": "1.46.0",
     20725                    "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.46.0.tgz",
     20726                    "integrity": "sha512-svXaP8UQRZ5K7or+ZmfNhg2xX3yKDMUzqadsSqi4NCH/KomcH75MAMYAGVlvXn4+b/xOPhS3I2uHKRUzvjY7BQ==",
    2072920727                    "dev": true
    2073020728                },
    2073120729                "mime-types": {
    20732                     "version": "2.1.28",
    20733                     "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.28.tgz",
    20734                     "integrity": "sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ==",
    20735                     "dev": true,
    20736                     "requires": {
    20737                         "mime-db": "1.45.0"
     20730                    "version": "2.1.29",
     20731                    "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.29.tgz",
     20732                    "integrity": "sha512-Y/jMt/S5sR9OaqteJtslsFZKWOIIqMACsJSiHghlCAyhf7jfVYjKBmLiX8OgpWeW+fjJ2b+Az69aPFPkUOY6xQ==",
     20733                    "dev": true,
     20734                    "requires": {
     20735                        "mime-db": "1.46.0"
    2073820736                    }
    2073920737                },
     
    2080320801        },
    2080420802        "qunit": {
    20805             "version": "2.14.0",
    20806             "resolved": "https://registry.npmjs.org/qunit/-/qunit-2.14.0.tgz",
    20807             "integrity": "sha512-CYfenbgdpmhl2Ql2rDrrj0felY4h8k6lYhtWwGBCLL4qQC33YOj0psV8MWo85L1i0SIOmEDRXkFopWnGCLmf7g==",
    20808             "dev": true,
    20809             "requires": {
    20810                 "commander": "6.2.0",
     20803            "version": "2.14.1",
     20804            "resolved": "https://registry.npmjs.org/qunit/-/qunit-2.14.1.tgz",
     20805            "integrity": "sha512-jtFw8bf8+GjzY8UpnwbjqTOdK/rvrjcafUFTNpRc6/9N4q5dBwcwSMlcC76kAn5BRiSFj5Ssn2dfHtEYvtsXSw==",
     20806            "dev": true,
     20807            "requires": {
     20808                "commander": "7.1.0",
    2081120809                "js-reporters": "1.2.3",
    2081220810                "node-watch": "0.7.1",
     
    2081520813            "dependencies": {
    2081620814                "commander": {
    20817                     "version": "6.2.0",
    20818                     "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.0.tgz",
    20819                     "integrity": "sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q==",
     20815                    "version": "7.1.0",
     20816                    "resolved": "https://registry.npmjs.org/commander/-/commander-7.1.0.tgz",
     20817                    "integrity": "sha512-pRxBna3MJe6HKnBGsDyMv8ETbptw3axEdYHoqNh7gu5oDcew8fs0xnivZGm06Ogk8zGAJ9VX+OPEr2GXEQK4dg==",
    2082020818                    "dev": true
    2082120819                }
     
    2217022168        },
    2217122169        "sass": {
    22172             "version": "1.32.6",
    22173             "resolved": "https://registry.npmjs.org/sass/-/sass-1.32.6.tgz",
    22174             "integrity": "sha512-1bcDHDcSqeFtMr0JXI3xc/CXX6c4p0wHHivJdru8W7waM7a1WjKMm4m/Z5sY7CbVw4Whi2Chpcw6DFfSWwGLzQ==",
     22170            "version": "1.32.8",
     22171            "resolved": "https://registry.npmjs.org/sass/-/sass-1.32.8.tgz",
     22172            "integrity": "sha512-Sl6mIeGpzjIUZqvKnKETfMf0iDAswD9TNlv13A7aAF3XZlRPMq4VvJWBC2N2DXbp94MQVdNSFG6LfF/iOXrPHQ==",
    2217522173            "dev": true,
    2217622174            "requires": {
     
    2276922767        },
    2277022768        "sinon": {
    22771             "version": "9.2.4",
    22772             "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.2.4.tgz",
    22773             "integrity": "sha512-zljcULZQsJxVra28qIAL6ow1Z9tpattkCTEJR4RBP3TGc00FcttsP5pK284Nas5WjMZU5Yzy3kAIp3B3KRf5Yg==",
     22769            "version": "10.0.0",
     22770            "resolved": "https://registry.npmjs.org/sinon/-/sinon-10.0.0.tgz",
     22771            "integrity": "sha512-XAn5DxtGVJBlBWYrcYKEhWCz7FLwZGdyvANRyK06419hyEpdT0dMc5A8Vcxg5SCGHc40CsqoKsc1bt1CbJPfNw==",
    2277422772            "dev": true,
    2277522773            "requires": {
     
    2277822776                "@sinonjs/samsam": "^5.3.1",
    2277922777                "diff": "^4.0.2",
    22780                 "nise": "^4.0.4",
     22778                "nise": "^4.1.0",
    2278122779                "supports-color": "^7.1.0"
    2278222780            },
     
    2545525453        },
    2545625454        "uglify-js": {
    25457             "version": "3.12.6",
    25458             "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.6.tgz",
    25459             "integrity": "sha512-aqWHe3DfQmZUDGWBbabZ2eQnJlQd1fKlMUu7gV+MiTuDzdgDw31bI3wA2jLLsV/hNcDP26IfyEgSVoft5+0SVw==",
     25455            "version": "3.13.2",
     25456            "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.2.tgz",
     25457            "integrity": "sha512-SbMu4D2Vo95LMC/MetNaso1194M1htEA+JrqE9Hk+G2DhI+itfS9TRu9ZKeCahLDNa/J3n4MqUJ/fOHMzQpRWw==",
    2546025458            "dev": true
    2546125459        },
  • branches/5.6/package.json

    r50459 r50602  
    3333        "autoprefixer": "^9.8.6",
    3434        "chalk": "4.1.0",
    35         "check-node-version": "4.0.3",
     35        "check-node-version": "4.1.0",
    3636        "copy-webpack-plugin": "^5.1.2",
    3737        "cssnano": "4.1.10",
     
    4343        "grunt-contrib-concat": "1.0.1",
    4444        "grunt-contrib-copy": "~1.0.0",
    45         "grunt-contrib-cssmin": "~3.0.0",
     45        "grunt-contrib-cssmin": "~4.0.0",
    4646        "grunt-contrib-imagemin": "~4.0.0",
    4747        "grunt-contrib-jshint": "3.0.0",
     
    6363        "install-changed": "1.1.0",
    6464        "matchdep": "~2.0.0",
    65         "sass": "^1.32.6",
     65        "sass": "^1.32.8",
    6666        "prettier": "npm:wp-prettier@2.0.5",
    6767        "puppeteer": "npm:puppeteer-core@3.0.0",
    68         "qunit": "~2.14.0",
    69         "sinon": "~9.2.4",
     68        "qunit": "~2.14.1",
     69        "sinon": "~10.0.0",
    7070        "sinon-test": "~3.0.0",
    7171        "source-map-loader": "^1.1.3",
    72         "uglify-js": "^3.12.6",
     72        "uglify-js": "^3.13.2",
    7373        "uglifyjs-webpack-plugin": "2.2.0",
    7474        "uuid": "8.3.2",
  • branches/5.6/phpunit.xml.dist

    r48847 r50602  
    4343    <filter>
    4444        <whitelist addUncoveredFilesFromWhitelist="true">
    45             <directory suffix=".php">build</directory>
     45            <directory suffix=".php">src</directory>
    4646            <exclude>
    4747                <!-- Third party library exclusions. -->
    48                 <directory suffix=".php">build/wp-includes/ID3</directory>
    49                 <directory suffix=".php">build/wp-includes/IXR</directory>
    50                 <directory suffix=".php">build/wp-includes/random_compat</directory>
    51                 <directory suffix=".php">build/wp-includes/PHPMailer</directory>
    52                 <directory suffix=".php">build/wp-includes/Requests</directory>
    53                 <directory suffix=".php">build/wp-includes/SimplePie</directory>
    54                 <directory suffix=".php">build/wp-includes/sodium_compat</directory>
    55                 <directory suffix=".php">build/wp-includes/Text</directory>
     48                <directory suffix=".php">src/wp-includes/ID3</directory>
     49                <directory suffix=".php">src/wp-includes/IXR</directory>
     50                <directory suffix=".php">src/wp-includes/random_compat</directory>
     51                <directory suffix=".php">src/wp-includes/PHPMailer</directory>
     52                <directory suffix=".php">src/wp-includes/Requests</directory>
     53                <directory suffix=".php">src/wp-includes/SimplePie</directory>
     54                <directory suffix=".php">src/wp-includes/sodium_compat</directory>
     55                <directory suffix=".php">src/wp-includes/Text</directory>
    5656
    5757                <!-- Plugins and themes. -->
    58                 <directory suffix=".php">build/wp-content/</directory>
     58                <directory suffix=".php">src/wp-content/</directory>
    5959
    60                 <file>build/wp-admin/includes/class-ftp*</file>
    61                 <file>build/wp-admin/includes/class-pclzip.php</file>
    62                 <file>build/wp-admin/includes/deprecated.php</file>
    63                 <file>build/wp-admin/includes/ms-deprecated.php</file>
     60                <file>src/wp-admin/includes/class-ftp*</file>
     61                <file>src/wp-admin/includes/class-pclzip.php</file>
     62                <file>src/wp-admin/includes/deprecated.php</file>
     63                <file>src/wp-admin/includes/ms-deprecated.php</file>
    6464
    65                 <file>build/wp-includes/atomlib.php</file>
    66                 <file>build/wp-includes/class-IXR.php</file>
    67                 <file>build/wp-includes/class-json.php</file>
    68                 <file>build/wp-includes/class-phpass.php</file>
    69                 <file>build/wp-includes/class-pop3.php</file>
    70                 <file>build/wp-includes/class-requests.php</file>
    71                 <file>build/wp-includes/class-simplepie.php</file>
    72                 <file>build/wp-includes/class-snoopy.php</file>
    73                 <file>build/wp-includes/deprecated.php</file>
    74                 <file>build/wp-includes/ms-deprecated.php</file>
    75                 <file>build/wp-includes/pluggable-deprecated.php</file>
    76                 <file>build/wp-includes/rss.php</file>
     65                <file>src/wp-includes/atomlib.php</file>
     66                <file>src/wp-includes/class-IXR.php</file>
     67                <file>src/wp-includes/class-json.php</file>
     68                <file>src/wp-includes/class-phpass.php</file>
     69                <file>src/wp-includes/class-pop3.php</file>
     70                <file>src/wp-includes/class-requests.php</file>
     71                <file>src/wp-includes/class-simplepie.php</file>
     72                <file>src/wp-includes/class-snoopy.php</file>
     73                <file>src/wp-includes/deprecated.php</file>
     74                <file>src/wp-includes/ms-deprecated.php</file>
     75                <file>src/wp-includes/pluggable-deprecated.php</file>
     76                <file>src/wp-includes/rss.php</file>
    7777            </exclude>
    7878        </whitelist>
  • branches/5.6/tests/phpunit/includes/abstract-testcase.php

    r49280 r50602  
    12941294        );
    12951295    }
     1296
     1297    /**
     1298     * Touches the given file and its directory if it doesn't already exist.
     1299     *
     1300     * This can be used to ensure a file that is implictly relied on in a test exists
     1301     * without it having to be built.
     1302     *
     1303     * @param string $file The file name.
     1304     */
     1305    public static function touch( $file ) {
     1306        if ( file_exists( $file ) ) {
     1307            return;
     1308        }
     1309
     1310        $dir = dirname( $file );
     1311
     1312        if ( ! file_exists( $dir ) ) {
     1313            mkdir( $dir, 0777, true );
     1314        }
     1315
     1316        touch( $file );
     1317    }
    12961318}
  • branches/5.6/tests/phpunit/tests/admin/includesPlugin.php

    r49566 r50602  
    55 */
    66class Tests_Admin_includesPlugin extends WP_UnitTestCase {
     7    public static function wpSetUpBeforeClass( $factory ) {
     8        self::_back_up_mu_plugins();
     9    }
     10
     11    public static function wpTearDownAfterClass() {
     12        self::_restore_mu_plugins();
     13    }
     14
    715    function test_get_plugin_data() {
    816        $data = get_plugin_data( DIR_TESTDATA . '/plugins/hello.php' );
     
    370378            'list_files_test_plugin/subdir/subfile.php',
    371379        );
    372         $this->assertSame( $expected, $plugin_files );
    373380
    374381        unlink( $sub_dir . '/subfile.php' );
     
    376383        rmdir( $sub_dir );
    377384        rmdir( $plugin_dir );
     385
     386        $this->assertSame( $expected, $plugin_files );
    378387    }
    379388
     
    382391     */
    383392    public function test_get_mu_plugins_when_mu_plugins_exists_but_is_empty() {
    384         if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    385             $exists = true;
    386             $this->_back_up_mu_plugins();
    387         } else {
    388             $exists = false;
    389             mkdir( WPMU_PLUGIN_DIR );
    390         }
    391 
     393        mkdir( WPMU_PLUGIN_DIR );
     394
     395        $mu_plugins = get_mu_plugins();
     396
     397        rmdir( WPMU_PLUGIN_DIR );
     398
     399        $this->assertSame( array(), $mu_plugins );
     400    }
     401
     402    /**
     403     * @covers ::get_mu_plugins
     404     */
     405    public function test_get_mu_plugins_when_mu_plugins_directory_does_not_exist() {
     406        $this->assertFileNotExists( WPMU_PLUGIN_DIR );
    392407        $this->assertSame( array(), get_mu_plugins() );
    393 
    394         // Clean up.
    395         if ( $exists ) {
    396             $this->_restore_mu_plugins();
    397         } else {
    398             rmdir( WPMU_PLUGIN_DIR );
    399         }
    400408    }
    401409
     
    403411     * @covers ::get_mu_plugins
    404412     */
    405     public function test_get_mu_plugins_when_mu_plugins_directory_does_not_exist() {
    406         $exists = false;
    407         if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    408             $exists = true;
    409             $this->_back_up_mu_plugins();
    410             rmdir( WPMU_PLUGIN_DIR );
    411         }
    412 
    413         $this->assertSame( array(), get_mu_plugins() );
    414 
    415         // Clean up.
    416         if ( $exists ) {
    417             mkdir( WPMU_PLUGIN_DIR );
    418             $this->_restore_mu_plugins();
    419         }
     413    public function test_get_mu_plugins_should_ignore_index_php_containing_silence_is_golden() {
     414        mkdir( WPMU_PLUGIN_DIR );
     415
     416        $this->_create_plugin( '<?php\n//Silence is golden.', 'index.php', WPMU_PLUGIN_DIR );
     417
     418        $mu_plugins = get_mu_plugins();
     419
     420        unlink( WPMU_PLUGIN_DIR . '/index.php' );
     421        rmdir( WPMU_PLUGIN_DIR );
     422
     423        $this->assertSame( array(), $mu_plugins );
    420424    }
    421425
     
    423427     * @covers ::get_mu_plugins
    424428     */
    425     public function test_get_mu_plugins_should_ignore_index_php_containing_silence_is_golden() {
    426         if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    427             $exists = true;
    428             $this->_back_up_mu_plugins();
    429         } else {
    430             $exists = false;
    431             mkdir( WPMU_PLUGIN_DIR );
    432         }
    433 
    434         $this->_create_plugin( '<?php\n//Silence is golden.', 'index.php', WPMU_PLUGIN_DIR );
    435         $this->assertSame( array(), get_mu_plugins() );
     429    public function test_get_mu_plugins_should_not_ignore_index_php_containing_something_other_than_silence_is_golden() {
     430        mkdir( WPMU_PLUGIN_DIR );
     431
     432        $this->_create_plugin( '<?php\n//Silence is not golden.', 'index.php', WPMU_PLUGIN_DIR );
     433        $found = get_mu_plugins();
    436434
    437435        // Clean up.
    438436        unlink( WPMU_PLUGIN_DIR . '/index.php' );
    439         if ( $exists ) {
    440             $this->_restore_mu_plugins();
    441         } else {
    442             rmdir( WPMU_PLUGIN_DIR );
    443         }
     437        rmdir( WPMU_PLUGIN_DIR );
     438
     439        $this->assertSame( array( 'index.php' ), array_keys( $found ) );
    444440    }
    445441
     
    447443     * @covers ::get_mu_plugins
    448444     */
    449     public function test_get_mu_plugins_should_not_ignore_index_php_containing_something_other_than_silence_is_golden() {
    450         if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    451             $exists = true;
    452             $this->_back_up_mu_plugins();
    453         } else {
    454             $exists = false;
    455             mkdir( WPMU_PLUGIN_DIR );
    456         }
    457 
    458         $this->_create_plugin( '<?php\n//Silence is not golden.', 'index.php', WPMU_PLUGIN_DIR );
    459         $found = get_mu_plugins();
    460         $this->assertSame( array( 'index.php' ), array_keys( $found ) );
    461 
    462         // Clean up.
    463         unlink( WPMU_PLUGIN_DIR . '/index.php' );
    464         if ( $exists ) {
    465             $this->_restore_mu_plugins();
    466         } else {
    467             rmdir( WPMU_PLUGIN_DIR );
    468         }
    469     }
    470 
    471     /**
    472      * @covers ::get_mu_plugins
    473      */
    474445    public function test_get_mu_plugins_should_ignore_files_without_php_extensions() {
    475         if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    476             $exists = true;
    477             $this->_back_up_mu_plugins();
    478         } else {
    479             $exists = false;
    480             mkdir( WPMU_PLUGIN_DIR );
    481         }
     446        mkdir( WPMU_PLUGIN_DIR );
    482447
    483448        $this->_create_plugin( '<?php\n//Test', 'foo.php', WPMU_PLUGIN_DIR );
    484449        $this->_create_plugin( '<?php\n//Test 2', 'bar.txt', WPMU_PLUGIN_DIR );
    485450        $found = get_mu_plugins();
    486         $this->assertSame( array( 'foo.php' ), array_keys( $found ) );
    487451
    488452        // Clean up.
    489453        unlink( WPMU_PLUGIN_DIR . '/foo.php' );
    490454        unlink( WPMU_PLUGIN_DIR . '/bar.txt' );
    491         if ( $exists ) {
    492             $this->_restore_mu_plugins();
    493         } else {
    494             rmdir( WPMU_PLUGIN_DIR );
    495         }
     455
     456        $this->assertSame( array( 'foo.php' ), array_keys( $found ) );
    496457    }
    497458
     
    652613
    653614    /**
    654      * Move existing mu-plugins to wp-content/mu-plugin/backup.
     615     * Move existing mu-plugins to wp-content/mu-plugin-backup.
    655616     *
    656617     * @since 4.2.0
     
    658619     * @access private
    659620     */
    660     private function _back_up_mu_plugins() {
     621    private static function _back_up_mu_plugins() {
    661622        if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    662623            $mu_bu_dir = WP_CONTENT_DIR . '/mu-plugin-backup';
    663             if ( ! is_dir( $mu_bu_dir ) ) {
    664                 mkdir( $mu_bu_dir );
    665             }
    666 
    667             $files_to_move = array();
    668             $mu_plugins    = opendir( WPMU_PLUGIN_DIR );
    669             if ( $mu_plugins ) {
    670                 while ( false !== $plugin = readdir( $mu_plugins ) ) {
    671                     if ( 0 !== strpos( $plugin, '.' ) ) {
    672                         $files_to_move[] = $plugin;
    673                     }
    674                 }
    675             }
    676 
    677             closedir( $mu_plugins );
    678 
    679             foreach ( $files_to_move as $file_to_move ) {
    680                 $f = rename( WPMU_PLUGIN_DIR . '/' . $file_to_move, $mu_bu_dir . '/' . $file_to_move );
    681             }
     624            rename( WPMU_PLUGIN_DIR, $mu_bu_dir );
    682625        }
    683626    }
     
    690633     * @access private
    691634     */
    692     private function _restore_mu_plugins() {
    693         $mu_bu_dir     = WP_CONTENT_DIR . '/mu-plugin-backup';
    694         $files_to_move = array();
    695         $mu_plugins    = @opendir( $mu_bu_dir );
    696         if ( $mu_plugins ) {
    697             while ( false !== $plugin = readdir( $mu_plugins ) ) {
    698                 if ( 0 !== strpos( $plugin, '.' ) ) {
    699                     $files_to_move[] = $plugin;
    700                 }
    701             }
    702         }
    703 
    704         closedir( $mu_plugins );
    705 
    706         foreach ( $files_to_move as $file_to_move ) {
    707             rename( $mu_bu_dir . '/' . $file_to_move, WPMU_PLUGIN_DIR . '/' . $file_to_move );
     635    private static function _restore_mu_plugins() {
     636        $mu_bu_dir = WP_CONTENT_DIR . '/mu-plugin-backup';
     637
     638        if ( is_dir( WPMU_PLUGIN_DIR ) ) {
     639            rmdir( WPMU_PLUGIN_DIR );
    708640        }
    709641
    710642        if ( is_dir( $mu_bu_dir ) ) {
    711             rmdir( $mu_bu_dir );
     643            rename( $mu_bu_dir, WPMU_PLUGIN_DIR );
    712644        }
    713645    }
  • branches/5.6/tests/phpunit/tests/dependencies/jquery.php

    r49101 r50602  
    3535            $this->assertSame( $jquery_scripts[ $dep ], $o->src );
    3636        }
    37     }
    38 
    39     function test_presence_of_jquery_no_conflict() {
    40         $contents   = trim( file_get_contents( ABSPATH . WPINC . '/js/jquery/jquery.js' ) );
    41         $noconflict = 'jQuery.noConflict();';
    42         $end        = substr( $contents, - strlen( $noconflict ) );
    43         $this->assertSame( $noconflict, $end );
    4437    }
    4538
  • branches/5.6/tests/phpunit/tests/dependencies/scripts.php

    r49601 r50602  
    14031403        );
    14041404    }
    1405 
    1406     function test_no_source_mapping() {
    1407         $all_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( dirname( ABSPATH ) . '/build/' ) );
    1408         $js_files  = new RegexIterator( $all_files, '/\.js$/' );
    1409         foreach ( $js_files as $js_file ) {
    1410             $contents = trim( file_get_contents( $js_file ) );
    1411 
    1412             // We allow data: URLs.
    1413             $found = preg_match( '/sourceMappingURL=((?!data:).)/', $contents );
    1414             $this->assertSame( $found, 0, "sourceMappingURL found in $js_file" );
    1415         }
    1416     }
    14171405}
  • branches/5.6/tests/phpunit/tests/formatting/Emoji.php

    r49239 r50602  
    1414     */
    1515    public function test_unfiltered_emoji_cdns() {
     16        // `_print_emoji_detection_script()` assumes `wp-includes/js/wp-emoji-loader.js` is present:
     17        self::touch( ABSPATH . WPINC . '/js/wp-emoji-loader.js' );
    1618        $output = get_echo( '_print_emoji_detection_script' );
    1719
     
    3234        add_filter( 'emoji_svg_url', array( $this, '_filtered_emoji_svn_cdn' ) );
    3335
     36        // `_print_emoji_detection_script()` assumes `wp-includes/js/wp-emoji-loader.js` is present:
     37        self::touch( ABSPATH . WPINC . '/js/wp-emoji-loader.js' );
    3438        $output = get_echo( '_print_emoji_detection_script' );
    3539
     
    5357        add_filter( 'emoji_url', array( $this, '_filtered_emoji_png_cdn' ) );
    5458
     59        // `_print_emoji_detection_script()` assumes `wp-includes/js/wp-emoji-loader.js` is present:
     60        self::touch( ABSPATH . WPINC . '/js/wp-emoji-loader.js' );
    5561        $output = get_echo( '_print_emoji_detection_script' );
    5662
  • branches/5.6/tests/phpunit/tests/oembed/controller.php

    r49603 r50602  
    3535            )
    3636        );
     37
     38        // `get_post_embed_html()` assumes `wp-includes/js/wp-embed.js` is present:
     39        self::touch( ABSPATH . WPINC . '/js/wp-embed.js' );
    3740    }
    3841
  • branches/5.6/tests/phpunit/tests/oembed/getResponseData.php

    r48939 r50602  
    55 */
    66class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
     7    public function setUp() {
     8        parent::setUp();
     9
     10        // `get_post_embed_html()` assumes `wp-includes/js/wp-embed.js` is present:
     11        self::touch( ABSPATH . WPINC . '/js/wp-embed.js' );
     12    }
     13
    714    function test_get_oembed_response_data_non_existent_post() {
    815        $this->assertFalse( get_oembed_response_data( 0, 100 ) );
  • branches/5.6/tests/phpunit/tests/oembed/template.php

    r48937 r50602  
    2424        $this->assertQueryTrue( 'is_single', 'is_singular', 'is_embed' );
    2525
     26        // `print_embed_scripts()` assumes `wp-includes/js/wp-embed-template.js` is present:
     27        self::touch( ABSPATH . WPINC . '/js/wp-embed-template.js' );
     28
    2629        ob_start();
    2730        require ABSPATH . WPINC . '/theme-compat/embed.php';
     
    5558
    5659        $this->assertQueryTrue( 'is_single', 'is_singular', 'is_embed' );
     60
     61        // `print_embed_scripts()` assumes `wp-includes/js/wp-embed-template.js` is present:
     62        self::touch( ABSPATH . WPINC . '/js/wp-embed-template.js' );
    5763
    5864        ob_start();
     
    291297
    292298    /**
     299     * Confirms that no ampersands exist in src/wp-includes/js/wp-embed.js.
     300     *
     301     * See also the `verify:wp-embed` Grunt task for verifying the built file.
     302     *
    293303     * @ticket 34698
    294304     */
     
    296306        $this->assertNotContains( '&', file_get_contents( ABSPATH . WPINC . '/js/wp-embed.js' ) );
    297307    }
    298 
    299     /**
    300      * @ticket 34698
    301      *
    302      * @depends test_js_no_ampersands
    303      *
    304      * The previous test confirms that no ampersands exist in src/wp-includes/js/wp-embed.js.
    305      * However, we must also confirm that UglifyJS does not add ampersands during its
    306      * optimizations (which we tweak to avoid, but indirectly -- understandably, there's
    307      * no "don't add ampersands to my JavaScript file" option).
    308      *
    309      * So this test checks for ampersands in build/wp-includes/js/wp-embed.min.js.
    310      * In many cases, this file will not exist; in those cases, we simply skip the test.
    311      *
    312      * So when would it be run? We have Travis CI run `npm run test` which then runs, in order,
    313      * `qunit:compiled` (which runs the build) and then `phpunit`. Thus, this test will at least be
    314      * run during continuous integration.
    315      *
    316      * However, we need to verify that `qunit:compiled` runs before `phpunit`. So this test also
    317      * does a cheap check for a registered Grunt task called `test` that contains both
    318      * `qunit:compiled` and `phpunit`, in that order.
    319      *
    320      * One final failsafe: The Gruntfile.js assertion takes place before checking for the existence
    321      * of wp-embed.min.js. If the Grunt tasks are significantly refactored later, it could indicate
    322      * that wp-embed.min.js doesn't exist anymore. We wouldn't want the test to silently become one
    323      * that is always skipped, and thus useless.
    324      */
    325     function test_js_no_ampersands_in_compiled() {
    326         $gruntfile = file_get_contents( dirname( ABSPATH ) . '/Gruntfile.js' );
    327 
    328         // Confirm this file *should* exist, otherwise this test will always be skipped.
    329         $test = '/grunt.registerTask\(\s*\'test\',.*\'qunit:compiled\'.*\'phpunit\'/';
    330         $this->assertTrue( (bool) preg_match( $test, $gruntfile ) );
    331 
    332         $file = dirname( ABSPATH ) . '/build/' . WPINC . '/js/wp-embed.min.js';
    333         if ( ! file_exists( $file ) ) {
    334             return;
    335         }
    336         $this->assertNotContains( '&', file_get_contents( $file ) );
    337     }
    338 
    339308}
  • branches/5.6/tests/phpunit/tests/oembed/wpOembed.php

    r48937 r50602  
    1919
    2020        $this->pre_oembed_result_filtered = false;
     21
     22        // `get_post_embed_html()` assumes `wp-includes/js/wp-embed.js` is present:
     23        self::touch( ABSPATH . WPINC . '/js/wp-embed.js' );
    2124    }
    2225
  • branches/5.6/tests/phpunit/tests/shortcode.php

    r49117 r50602  
    747747    function test_php_and_js_shortcode_attribute_regexes_match() {
    748748
    749         $file    = file_get_contents( ABSPATH . WPINC . '/js/shortcode.js' );
     749        $file    = file_get_contents( ABSPATH . 'js/_enqueues/wp/shortcode.js' );
    750750        $matched = preg_match( '|\s+pattern = (\/.+\/)g;|', $file, $matches );
    751751        $php     = get_shortcode_atts_regex();
  • branches/5.6/tests/qunit/index.html

    r49215 r50602  
    152152        <script src="wp-includes/js/shortcode.js"></script>
    153153        <script src="wp-includes/js/api-request.js"></script>
     154        <script src="wp-includes/js/jquery.js"></script>
    154155        <script src="wp-includes/js/wp-api.js"></script>
    155156        <script src="wp-admin/js/customize-controls.js"></script>
  • branches/5.6/wp-tests-config-sample.php

    r47201 r50602  
    22
    33/* Path to the WordPress codebase you'd like to test. Add a forward slash in the end. */
    4 if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
    5     define( 'ABSPATH', dirname( __FILE__ ) . '/build/' );
    6 } else {
    7     define( 'ABSPATH', dirname( __FILE__ ) . '/src/' );
    8 }
     4define( 'ABSPATH', dirname( __FILE__ ) . '/src/' );
    95
    106/*
Note: See TracChangeset for help on using the changeset viewer.