WordPress.org

Make WordPress Core

Changeset 50605


Ignore:
Timestamp:
03/26/2021 07:22:10 PM (4 months ago)
Author:
desrosj
Message:

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

This backports several build and test tool improvements to the 5.3 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,50598] to the 5.3 branch.
See #50401, #51734, #51801, #51802, #52548, #52608, #52612, #52623, #52624, #52625, #52645, #52653, #52658, #52660, #52667.

Location:
branches/5.3
Files:
2 added
3 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • branches/5.3

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

    r50304 r50605  
    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.3'
     
    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"
     
    92113    steps:
    93114      - name: Checkout repository
    94         uses: actions/checkout@v2
     115        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    95116
    96117      - name: Log debug information
     
    102123
    103124      - name: Install NodeJS
    104         uses: actions/setup-node@v1
     125        uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
    105126        with:
    106127          node-version: 14
    107128
    108129      - name: Cache NodeJS modules
    109         uses: actions/cache@v2
     130        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    110131        env:
    111132          cache-name: cache-node-modules
     
    114135          path: ~/.npm
    115136          key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    116           restore-keys: |
    117             ${{ runner.os }}-npm-
    118137
    119138      - name: Log debug information
     
    123142
    124143      - name: Install Dependencies
    125         run: npx install-changed --install-command="npm ci"
     144        run: npm ci
    126145
    127146      - name: Run JSHint
  • branches/5.3/.github/workflows/javascript-tests.yml

    r50304 r50605  
    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.3/.github/workflows/php-compatibility.yml

    r50304 r50605  
    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.3/.github/workflows/phpunit-tests.yml

    r50304 r50605  
    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: [ '7.4', '7.3', '7.2', '7.1', '7.0', '5.6' ]
     76        php: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4' ]
    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'
     84            os: ubuntu-latest
     85            memcached: false
     86            multisite: false
     87            split_slow: true
     88          - php: '5.6'
     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
     138
     139      - name: Get composer cache directory
     140        id: composer-cache
     141        if: ${{ env.COMPOSER_INSTALL == true }}
     142        run: echo "::set-output name=dir::$(composer config cache-files-dir)"
    181143
    182144      - name: Cache Composer dependencies
    183145        if: ${{ env.COMPOSER_INSTALL == true }}
    184         uses: actions/cache@v2
     146        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    185147        env:
    186148          cache-name: cache-composer-dependencies
     
    188150          path: ${{ steps.composer-cache.outputs.dir }}
    189151          key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
    190           restore-keys: |
    191             ${{ runner.os }}-php-${{ matrix.php }}-composer-
    192152
    193153      - name: Install Composer dependencies
     
    210170        if: ${{ matrix.memcached }}
    211171        run: |
    212           cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php
     172          cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
    213173          docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached
    214174
     
    235195        run: npm run env:install
    236196
     197      - name: Run slow PHPUnit tests
     198        if: ${{ matrix.split_slow }}
     199        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
     200
     201      - name: Run PHPUnit tests for single site excluding slow tests
     202        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }}
     203        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required
     204
     205      - name: Run PHPUnit tests for Multisite excluding slow tests
     206        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }}
     207        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers
     208
    237209      - name: Run PHPUnit tests
    238         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist
     210        if: ${{ matrix.php >= '7.0' }}
     211        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }}
    239212
    240213      - name: Run AJAX tests
    241         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group ajax
    242 
    243       - name: Run tests as a multisite install
    244         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml
     214        if: ${{ ! matrix.split_slow && ! matrix.multisite }}
     215        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
    245216
    246217      - name: Run ms-files tests as a multisite install
     218        if: ${{ matrix.multisite && ! matrix.split_slow }}
    247219        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files
    248220
    249221      - name: Run external HTTP tests
     222        if: ${{ ! matrix.multisite && ! matrix.split_slow }}
    250223        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group external-http
    251 
    252       - name: Run REST API tests
    253         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group restapi-jsclient
    254224
    255225      # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
    256226      - name: Run (xDebug) tests
    257         run: LOCAL_PHP_XDEBUG=true npm run test:php -- -v --group xdebug --exclude-group __fakegroup__
     227        if: ${{ ! matrix.split_slow }}
     228        run: LOCAL_PHP_XDEBUG=true npm run test:${{ env.PHPUNIT_SCRIPT }} -- -v --group xdebug --exclude-group __fakegroup__
    258229
    259230      - name: Checkout the WordPress Test Reporter
    260231        if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
    261         uses: actions/checkout@v2
     232        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    262233        with:
    263234          repository: 'WordPress/phpunit-test-runner'
    264235          path: 'test-runner'
    265 
    266       - name: Set up the Git repository
    267         if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
    268         run: |
    269           git init
    270           git remote add origin https://github.com/WordPress/wordpress-develop.git
    271           git fetch
    272           git reset origin/master
    273236
    274237      - name: Submit test results to the WordPress.org host test results
  • branches/5.3/.github/workflows/welcome-new-contributors.yml

    r50304 r50605  
    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.3/Gruntfile.js

    r50190 r50605  
    77    var path = require('path'),
    88        fs = require( 'fs' ),
     9        glob = require( 'glob' ),
     10        assert = require( 'assert' ).strict,
    911        spawn = require( 'child_process' ).spawnSync,
    1012        SOURCE_DIR = 'src/',
     
    13751377    ] );
    13761378
     1379    /**
     1380     * Build verification tasks.
     1381     */
     1382    grunt.registerTask( 'verify:build', [
     1383        'verify:wp-embed',
     1384        'verify:old-files',
     1385        'verify:source-maps',
     1386    ] );
     1387
     1388    /**
     1389     * Build assertions for wp-embed.min.js.
     1390     *
     1391     * @ticket 34698
     1392     */
     1393    grunt.registerTask( 'verify:wp-embed', function() {
     1394        const file = `${ BUILD_DIR }/wp-includes/js/wp-embed.min.js`;
     1395
     1396        assert(
     1397            fs.existsSync( file ),
     1398            'The build/wp-includes/js/wp-embed.min.js file does not exist.'
     1399        );
     1400
     1401        const contents = fs.readFileSync( file, {
     1402            encoding: 'utf8',
     1403        } );
     1404
     1405        assert(
     1406            contents.length > 0,
     1407            'The build/wp-includes/js/wp-embed.min.js file must not be empty.'
     1408        );
     1409        assert(
     1410            false === contents.includes( '&' ),
     1411            'The build/wp-includes/js/wp-embed.min.js file must not contain ampersands.'
     1412        );
     1413    } );
     1414
     1415    /**
     1416     * Build assertions to ensure no project files are inside `$_old_files` in the build directory.
     1417     *
     1418     * @ticket 36083
     1419     */
     1420    grunt.registerTask( 'verify:old-files', function() {
     1421        const file = `${ BUILD_DIR }wp-admin/includes/update-core.php`;
     1422
     1423        assert(
     1424            fs.existsSync( file ),
     1425            'The build/wp-admin/includes/update-core.php file does not exist.'
     1426        );
     1427
     1428        const contents = fs.readFileSync( file, {
     1429            encoding: 'utf8',
     1430        } );
     1431
     1432        assert(
     1433            contents.length > 0,
     1434            'The build/wp-admin/includes/update-core.php file must not be empty.'
     1435        );
     1436
     1437        const match = contents.match( /\$_old_files = array\(([^\)]+)\);/ );
     1438
     1439        assert(
     1440            match.length > 0,
     1441            'The build/wp-admin/includes/update-core.php file does not include an `$_old_files` array.'
     1442        );
     1443
     1444        const files = match[1].split( '\n\t' ).filter( function( file ) {
     1445            // Filter out empty lines
     1446            if ( '' === file ) {
     1447                return false;
     1448            }
     1449
     1450            // Filter out commented out lines
     1451            if ( 0 === file.indexOf( '/' ) ) {
     1452                return false;
     1453            }
     1454
     1455            return true;
     1456        } ).map( function( file ) {
     1457            // Strip leading and trailing single quotes and commas
     1458            return file.replace( /^\'|\',$/g, '' );
     1459        } );
     1460
     1461        files.forEach(function( file ){
     1462            const search = `${ BUILD_DIR }${ file }`;
     1463            assert(
     1464                false === fs.existsSync( search ),
     1465                `${ search } should not be present in the $_old_files array.`
     1466            );
     1467        });
     1468    } );
     1469
     1470    /**
     1471     * Build assertions for the lack of source maps in JavaScript files.
     1472     *
     1473     * @ticket 24994
     1474     * @ticket 46218
     1475     */
     1476    grunt.registerTask( 'verify:source-maps', function() {
     1477        const path = `${ BUILD_DIR }**/*.js`;
     1478        const files = glob.sync( path );
     1479
     1480        assert(
     1481            files.length > 0,
     1482            'No JavaScript files found in the build directory.'
     1483        );
     1484
     1485        files.forEach( function( file ) {
     1486            const contents = fs.readFileSync( file, {
     1487                encoding: 'utf8',
     1488            } );
     1489            // `data:` URLs are allowed:
     1490            const match = contents.match( /sourceMappingURL=((?!data:).)/ );
     1491
     1492            assert(
     1493                match === null,
     1494                `The ${ file } file must not contain a sourceMappingURL.`
     1495            );
     1496        } );
     1497    } );
     1498
    13771499    grunt.registerTask( 'build', function() {
    13781500        if ( grunt.option( 'dev' ) ) {
     
    13881510                'includes:emoji',
    13891511                'includes:embed',
     1512                'verify:build'
    13901513            ] );
    13911514        }
  • branches/5.3/package-lock.json

    r50190 r50605  
    15741574        },
    15751575        "@sideway/address": {
    1576             "version": "4.1.0",
    1577             "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.0.tgz",
    1578             "integrity": "sha512-wAH/JYRXeIFQRsxerIuLjgUu2Xszam+O5xKeatJ4oudShOOirfmsQ1D6LL54XOU2tizpCYku+s1wmU0SYdpoSA==",
     1576            "version": "4.1.1",
     1577            "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.1.tgz",
     1578            "integrity": "sha512-+I5aaQr3m0OAmMr7RQ3fR9zx55sejEYR2BFJaxL+zT3VM2611X0SHvPWIbAUBZVTn/YzYKbV8gJ2oT/QELknfQ==",
    15791579            "dev": true,
    15801580            "requires": {
     
    56275627        },
    56285628        "clean-css": {
    5629             "version": "4.2.1",
    5630             "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.1.tgz",
    5631             "integrity": "sha512-4ZxI6dy4lrY6FHzfiy1aEOXgu4LIsW2MhwG0VBKdcoGoH/XLFgaHSdLTGr4O8Be6A8r3MOphEiI8Gc1n0ecf3g==",
     5629            "version": "5.1.2",
     5630            "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.1.2.tgz",
     5631            "integrity": "sha512-QcaGg9OuMo+0Ds933yLOY+gHPWbxhxqF0HDexmToPf8pczvmvZGYzd+QqWp9/mkucAOKViI+dSFOqoZIvXbeBw==",
    56325632            "dev": true,
    56335633            "requires": {
     
    99559955        },
    99569956        "grunt-contrib-cssmin": {
    9957             "version": "3.0.0",
    9958             "resolved": "https://registry.npmjs.org/grunt-contrib-cssmin/-/grunt-contrib-cssmin-3.0.0.tgz",
    9959             "integrity": "sha512-eXpooYmVGKMs/xV7DzTLgJFPVOfMuawPD3x0JwhlH0mumq2NtH3xsxaHxp1Y3NKxp0j0tRhFS6kSBRsz6TuTGg==",
    9960             "dev": true,
    9961             "requires": {
    9962                 "chalk": "^2.4.1",
    9963                 "clean-css": "~4.2.1",
    9964                 "maxmin": "^2.1.0"
     9957            "version": "4.0.0",
     9958            "resolved": "https://registry.npmjs.org/grunt-contrib-cssmin/-/grunt-contrib-cssmin-4.0.0.tgz",
     9959            "integrity": "sha512-jXU+Zlk8Q8XztOGNGpjYlD/BDQ0n95IHKrQKtFR7Gd8hZrzgqiG1Ra7cGYc8h2DD9vkSFGNlweb9Q00rBxOK2w==",
     9960            "dev": true,
     9961            "requires": {
     9962                "chalk": "^4.1.0",
     9963                "clean-css": "^5.0.1",
     9964                "maxmin": "^3.0.0"
    99659965            },
    99669966            "dependencies": {
    99679967                "ansi-styles": {
    9968                     "version": "3.2.1",
    9969                     "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
    9970                     "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
    9971                     "dev": true,
    9972                     "requires": {
    9973                         "color-convert": "^1.9.0"
     9968                    "version": "4.3.0",
     9969                    "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
     9970                    "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
     9971                    "dev": true,
     9972                    "requires": {
     9973                        "color-convert": "^2.0.1"
    99749974                    }
    99759975                },
    99769976                "chalk": {
    9977                     "version": "2.4.2",
    9978                     "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
    9979                     "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
    9980                     "dev": true,
    9981                     "requires": {
    9982                         "ansi-styles": "^3.2.1",
    9983                         "escape-string-regexp": "^1.0.5",
    9984                         "supports-color": "^5.3.0"
    9985                     }
     9977                    "version": "4.1.0",
     9978                    "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
     9979                    "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
     9980                    "dev": true,
     9981                    "requires": {
     9982                        "ansi-styles": "^4.1.0",
     9983                        "supports-color": "^7.1.0"
     9984                    }
     9985                },
     9986                "color-convert": {
     9987                    "version": "2.0.1",
     9988                    "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
     9989                    "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
     9990                    "dev": true,
     9991                    "requires": {
     9992                        "color-name": "~1.1.4"
     9993                    }
     9994                },
     9995                "color-name": {
     9996                    "version": "1.1.4",
     9997                    "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
     9998                    "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
     9999                    "dev": true
     10000                },
     10001                "figures": {
     10002                    "version": "3.2.0",
     10003                    "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
     10004                    "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==",
     10005                    "dev": true,
     10006                    "requires": {
     10007                        "escape-string-regexp": "^1.0.5"
     10008                    }
     10009                },
     10010                "has-flag": {
     10011                    "version": "4.0.0",
     10012                    "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
     10013                    "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
     10014                    "dev": true
     10015                },
     10016                "maxmin": {
     10017                    "version": "3.0.0",
     10018                    "resolved": "https://registry.npmjs.org/maxmin/-/maxmin-3.0.0.tgz",
     10019                    "integrity": "sha512-wcahMInmGtg/7c6a75fr21Ch/Ks1Tb+Jtoan5Ft4bAI0ZvJqyOw8kkM7e7p8hDSzY805vmxwHT50KcjGwKyJ0g==",
     10020                    "dev": true,
     10021                    "requires": {
     10022                        "chalk": "^4.1.0",
     10023                        "figures": "^3.2.0",
     10024                        "gzip-size": "^5.1.1",
     10025                        "pretty-bytes": "^5.3.0"
     10026                    }
     10027                },
     10028                "pretty-bytes": {
     10029                    "version": "5.6.0",
     10030                    "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz",
     10031                    "integrity": "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==",
     10032                    "dev": true
    998610033                },
    998710034                "supports-color": {
    9988                     "version": "5.5.0",
    9989                     "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
    9990                     "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
    9991                     "dev": true,
    9992                     "requires": {
    9993                         "has-flag": "^3.0.0"
     10035                    "version": "7.2.0",
     10036                    "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
     10037                    "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
     10038                    "dev": true,
     10039                    "requires": {
     10040                        "has-flag": "^4.0.0"
    999410041                    }
    999510042                }
     
    1360313650        },
    1360413651        "joi": {
    13605             "version": "17.3.0",
    13606             "resolved": "https://registry.npmjs.org/joi/-/joi-17.3.0.tgz",
    13607             "integrity": "sha512-Qh5gdU6niuYbUIUV5ejbsMiiFmBdw8Kcp8Buj2JntszCkCfxJ9Cz76OtHxOZMPXrt5810iDIXs+n1nNVoquHgg==",
     13652            "version": "17.4.0",
     13653            "resolved": "https://registry.npmjs.org/joi/-/joi-17.4.0.tgz",
     13654            "integrity": "sha512-F4WiW2xaV6wc1jxete70Rw4V/VuMd6IN+a5ilZsxG4uYtUXWu2kq9W5P2dz30e7Gmw8RCbY/u/uk+dMPma9tAg==",
    1360813655            "dev": true,
    1360913656            "requires": {
     
    1823918286        },
    1824018287        "sass": {
    18241             "version": "1.32.6",
    18242             "resolved": "https://registry.npmjs.org/sass/-/sass-1.32.6.tgz",
    18243             "integrity": "sha512-1bcDHDcSqeFtMr0JXI3xc/CXX6c4p0wHHivJdru8W7waM7a1WjKMm4m/Z5sY7CbVw4Whi2Chpcw6DFfSWwGLzQ==",
     18288            "version": "1.32.8",
     18289            "resolved": "https://registry.npmjs.org/sass/-/sass-1.32.8.tgz",
     18290            "integrity": "sha512-Sl6mIeGpzjIUZqvKnKETfMf0iDAswD9TNlv13A7aAF3XZlRPMq4VvJWBC2N2DXbp94MQVdNSFG6LfF/iOXrPHQ==",
    1824418291            "dev": true,
    1824518292            "requires": {
     
    2046820515        },
    2046920516        "uglify-js": {
    20470             "version": "3.12.6",
    20471             "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.6.tgz",
    20472             "integrity": "sha512-aqWHe3DfQmZUDGWBbabZ2eQnJlQd1fKlMUu7gV+MiTuDzdgDw31bI3wA2jLLsV/hNcDP26IfyEgSVoft5+0SVw==",
     20517            "version": "3.13.2",
     20518            "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.2.tgz",
     20519            "integrity": "sha512-SbMu4D2Vo95LMC/MetNaso1194M1htEA+JrqE9Hk+G2DhI+itfS9TRu9ZKeCahLDNa/J3n4MqUJ/fOHMzQpRWw==",
    2047320520            "dev": true
    2047420521        },
     
    2098821035        },
    2098921036        "wait-on": {
    20990             "version": "5.2.1",
    20991             "resolved": "https://registry.npmjs.org/wait-on/-/wait-on-5.2.1.tgz",
    20992             "integrity": "sha512-H2F986kNWMU9hKlI9l/ppO6tN8ZSJd35yBljMLa1/vjzWP++Qh6aXyt77/u7ySJFZQqBtQxnvm/xgG48AObXcw==",
     21037            "version": "5.3.0",
     21038            "resolved": "https://registry.npmjs.org/wait-on/-/wait-on-5.3.0.tgz",
     21039            "integrity": "sha512-DwrHrnTK+/0QFaB9a8Ol5Lna3k7WvUR4jzSKmz0YaPBpuN2sACyiPVKVfj6ejnjcajAcvn3wlbTyMIn9AZouOg==",
    2099321040            "dev": true,
    2099421041            "requires": {
    2099521042                "axios": "^0.21.1",
    2099621043                "joi": "^17.3.0",
    20997                 "lodash": "^4.17.20",
     21044                "lodash": "^4.17.21",
    2099821045                "minimist": "^1.2.5",
    2099921046                "rxjs": "^6.6.3"
     
    2100121048            "dependencies": {
    2100221049                "lodash": {
    21003                     "version": "4.17.20",
    21004                     "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
    21005                     "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==",
     21050                    "version": "4.17.21",
     21051                    "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
     21052                    "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
    2100621053                    "dev": true
    2100721054                },
     
    2101321060                },
    2101421061                "rxjs": {
    21015                     "version": "6.6.3",
    21016                     "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.3.tgz",
    21017                     "integrity": "sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==",
     21062                    "version": "6.6.6",
     21063                    "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.6.tgz",
     21064                    "integrity": "sha512-/oTwee4N4iWzAMAL9xdGKjkEHmIwupR3oXbQjCKywF1BeFohswF3vZdogbmEF6pZkOsXTzWkrZszrWpQTByYVg==",
    2101821065                    "dev": true,
    2101921066                    "requires": {
  • branches/5.3/package.json

    r50190 r50605  
    4141        "grunt-contrib-concat": "1.0.1",
    4242        "grunt-contrib-copy": "~1.0.0",
    43         "grunt-contrib-cssmin": "~3.0.0",
     43        "grunt-contrib-cssmin": "~4.0.0",
    4444        "grunt-contrib-imagemin": "~4.0.0",
    4545        "grunt-contrib-jshint": "3.0.0",
     
    6161        "jquery-migrate": "1.4.1",
    6262        "matchdep": "~2.0.0",
    63         "sass": "^1.32.6",
     63        "sass": "^1.32.8",
    6464        "source-map-loader": "^1.1.3",
    65         "uglify-js": "^3.12.6",
     65        "uglify-js": "^3.13.2",
    6666        "uglifyjs-webpack-plugin": "2.2.0",
    67         "wait-on": "5.2.1",
     67        "wait-on": "5.3.0",
    6868        "webpack": "4.43.0",
    6969        "webpack-dev-server": "3.11.2",
  • branches/5.3/tests/phpunit/includes/abstract-testcase.php

    r50092 r50605  
    12251225        );
    12261226    }
     1227
     1228    /**
     1229     * Touches the given file and its directory if it doesn't already exist.
     1230     *
     1231     * This can be used to ensure a file that is implictly relied on in a test exists
     1232     * without it having to be built.
     1233     *
     1234     * @param string $file The file name.
     1235     */
     1236    public static function touch( $file ) {
     1237        if ( file_exists( $file ) ) {
     1238            return;
     1239        }
     1240
     1241        $dir = dirname( $file );
     1242
     1243        if ( ! file_exists( $dir ) ) {
     1244            mkdir( $dir, 0777, true );
     1245        }
     1246
     1247        touch( $file );
     1248    }
    12271249}
  • branches/5.3/tests/phpunit/tests/admin/includesPlugin.php

    r46869 r50605  
    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' );
     
    374382            'list_files_test_plugin/subdir/subfile.php',
    375383        );
    376         $this->assertEquals( $expected, $plugin_files );
    377384
    378385        unlink( $sub_dir . '/subfile.php' );
     
    380387        rmdir( $sub_dir );
    381388        rmdir( $plugin_dir );
     389
     390        $this->assertSame( $expected, $plugin_files );
    382391    }
    383392
     
    386395     */
    387396    public function test_get_mu_plugins_when_mu_plugins_exists_but_is_empty() {
    388         if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    389             $exists = true;
    390             $this->_back_up_mu_plugins();
    391         } else {
    392             $exists = false;
    393             mkdir( WPMU_PLUGIN_DIR );
    394         }
    395 
    396         $this->assertEquals( array(), get_mu_plugins() );
    397 
    398         // Clean up.
    399         if ( $exists ) {
    400             $this->_restore_mu_plugins();
    401         } else {
    402             rmdir( WPMU_PLUGIN_DIR );
    403         }
     397        mkdir( WPMU_PLUGIN_DIR );
     398
     399        $mu_plugins = get_mu_plugins();
     400
     401        rmdir( WPMU_PLUGIN_DIR );
     402
     403        $this->assertSame( array(), $mu_plugins );
    404404    }
    405405
     
    408408     */
    409409    public function test_get_mu_plugins_when_mu_plugins_directory_does_not_exist() {
    410         $exists = false;
    411         if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    412             $exists = true;
    413             $this->_back_up_mu_plugins();
    414             rmdir( WPMU_PLUGIN_DIR );
    415         }
    416 
    417         $this->assertEquals( array(), get_mu_plugins() );
    418 
    419         // Clean up.
    420         if ( $exists ) {
    421             mkdir( WPMU_PLUGIN_DIR );
    422             $this->_restore_mu_plugins();
    423         }
     410        $this->assertFileNotExists( WPMU_PLUGIN_DIR );
     411        $this->assertSame( array(), get_mu_plugins() );
    424412    }
    425413
     
    428416     */
    429417    public function test_get_mu_plugins_should_ignore_index_php_containing_silence_is_golden() {
    430         if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    431             $exists = true;
    432             $this->_back_up_mu_plugins();
    433         } else {
    434             $exists = false;
    435             mkdir( WPMU_PLUGIN_DIR );
    436         }
     418        mkdir( WPMU_PLUGIN_DIR );
    437419
    438420        $this->_create_plugin( '<?php\n//Silence is golden.', 'index.php', WPMU_PLUGIN_DIR );
    439         $this->assertEquals( array(), get_mu_plugins() );
     421
     422        $mu_plugins = get_mu_plugins();
     423
     424        unlink( WPMU_PLUGIN_DIR . '/index.php' );
     425        rmdir( WPMU_PLUGIN_DIR );
     426
     427        $this->assertSame( array(), $mu_plugins );
     428    }
     429
     430    /**
     431     * @covers ::get_mu_plugins
     432     */
     433    public function test_get_mu_plugins_should_not_ignore_index_php_containing_something_other_than_silence_is_golden() {
     434        mkdir( WPMU_PLUGIN_DIR );
     435
     436        $this->_create_plugin( '<?php\n//Silence is not golden.', 'index.php', WPMU_PLUGIN_DIR );
     437        $found = get_mu_plugins();
    440438
    441439        // Clean up.
    442440        unlink( WPMU_PLUGIN_DIR . '/index.php' );
    443         if ( $exists ) {
    444             $this->_restore_mu_plugins();
    445         } else {
    446             rmdir( WPMU_PLUGIN_DIR );
    447         }
     441        rmdir( WPMU_PLUGIN_DIR );
     442
     443        $this->assertSame( array( 'index.php' ), array_keys( $found ) );
    448444    }
    449445
     
    451447     * @covers ::get_mu_plugins
    452448     */
    453     public function test_get_mu_plugins_should_not_ignore_index_php_containing_something_other_than_silence_is_golden() {
    454         if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    455             $exists = true;
    456             $this->_back_up_mu_plugins();
    457         } else {
    458             $exists = false;
    459             mkdir( WPMU_PLUGIN_DIR );
    460         }
    461 
    462         $this->_create_plugin( '<?php\n//Silence is not golden.', 'index.php', WPMU_PLUGIN_DIR );
    463         $found = get_mu_plugins();
    464         $this->assertEquals( array( 'index.php' ), array_keys( $found ) );
    465 
    466         // Clean up.
    467         unlink( WPMU_PLUGIN_DIR . '/index.php' );
    468         if ( $exists ) {
    469             $this->_restore_mu_plugins();
    470         } else {
    471             rmdir( WPMU_PLUGIN_DIR );
    472         }
    473     }
    474 
    475     /**
    476      * @covers ::get_mu_plugins
    477      */
    478449    public function test_get_mu_plugins_should_ignore_files_without_php_extensions() {
    479         if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    480             $exists = true;
    481             $this->_back_up_mu_plugins();
    482         } else {
    483             $exists = false;
    484             mkdir( WPMU_PLUGIN_DIR );
    485         }
     450        mkdir( WPMU_PLUGIN_DIR );
    486451
    487452        $this->_create_plugin( '<?php\n//Test', 'foo.php', WPMU_PLUGIN_DIR );
    488453        $this->_create_plugin( '<?php\n//Test 2', 'bar.txt', WPMU_PLUGIN_DIR );
    489454        $found = get_mu_plugins();
    490         $this->assertEquals( array( 'foo.php' ), array_keys( $found ) );
    491455
    492456        // Clean up.
    493457        unlink( WPMU_PLUGIN_DIR . '/foo.php' );
    494458        unlink( WPMU_PLUGIN_DIR . '/bar.txt' );
    495         if ( $exists ) {
    496             $this->_restore_mu_plugins();
    497         } else {
    498             rmdir( WPMU_PLUGIN_DIR );
    499         }
     459
     460        $this->assertSame( array( 'foo.php' ), array_keys( $found ) );
    500461    }
    501462
     
    656617
    657618    /**
    658      * Move existing mu-plugins to wp-content/mu-plugin/backup.
     619     * Move existing mu-plugins to wp-content/mu-plugin-backup.
    659620     *
    660621     * @since 4.2.0
     
    662623     * @access private
    663624     */
    664     private function _back_up_mu_plugins() {
     625    private static function _back_up_mu_plugins() {
    665626        if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    666627            $mu_bu_dir = WP_CONTENT_DIR . '/mu-plugin-backup';
    667             if ( ! is_dir( $mu_bu_dir ) ) {
    668                 mkdir( $mu_bu_dir );
    669             }
    670 
    671             $files_to_move = array();
    672             $mu_plugins    = opendir( WPMU_PLUGIN_DIR );
    673             if ( $mu_plugins ) {
    674                 while ( false !== $plugin = readdir( $mu_plugins ) ) {
    675                     if ( 0 !== strpos( $plugin, '.' ) ) {
    676                         $files_to_move[] = $plugin;
    677                     }
    678                 }
    679             }
    680 
    681             closedir( $mu_plugins );
    682 
    683             foreach ( $files_to_move as $file_to_move ) {
    684                 $f = rename( WPMU_PLUGIN_DIR . '/' . $file_to_move, $mu_bu_dir . '/' . $file_to_move );
    685             }
     628            rename( WPMU_PLUGIN_DIR, $mu_bu_dir );
    686629        }
    687630    }
     
    694637     * @access private
    695638     */
    696     private function _restore_mu_plugins() {
    697         $mu_bu_dir     = WP_CONTENT_DIR . '/mu-plugin-backup';
    698         $files_to_move = array();
    699         $mu_plugins    = @opendir( $mu_bu_dir );
    700         if ( $mu_plugins ) {
    701             while ( false !== $plugin = readdir( $mu_plugins ) ) {
    702                 if ( 0 !== strpos( $plugin, '.' ) ) {
    703                     $files_to_move[] = $plugin;
    704                 }
    705             }
    706         }
    707 
    708         closedir( $mu_plugins );
    709 
    710         foreach ( $files_to_move as $file_to_move ) {
    711             rename( $mu_bu_dir . '/' . $file_to_move, WPMU_PLUGIN_DIR . '/' . $file_to_move );
     639    private static function _restore_mu_plugins() {
     640        $mu_bu_dir = WP_CONTENT_DIR . '/mu-plugin-backup';
     641
     642        if ( is_dir( WPMU_PLUGIN_DIR ) ) {
     643            rmdir( WPMU_PLUGIN_DIR );
    712644        }
    713645
    714646        if ( is_dir( $mu_bu_dir ) ) {
    715             rmdir( $mu_bu_dir );
     647            rename( $mu_bu_dir, WPMU_PLUGIN_DIR );
    716648        }
    717649    }
  • branches/5.3/tests/phpunit/tests/dependencies/jquery.php

    r44740 r50605  
    2929            $this->assertEquals( $jquery_scripts[ $dep ], $o->src );
    3030        }
    31     }
    32 
    33     function test_presence_of_jquery_no_conflict() {
    34         $contents   = trim( file_get_contents( ABSPATH . WPINC . '/js/jquery/jquery.js' ) );
    35         $noconflict = 'jQuery.noConflict();';
    36         $end        = substr( $contents, - strlen( $noconflict ) );
    37         $this->assertEquals( $noconflict, $end );
    3831    }
    3932
  • branches/5.3/tests/phpunit/tests/dependencies/scripts.php

    r46181 r50605  
    713713
    714714        $ver       = get_bloginfo( 'version' );
     715        $suffix    = wp_scripts_get_suffix();
    715716        $expected  = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=jquery-core,jquery-migrate&amp;ver={$ver}'></script>\n";
    716717        $expected .= "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
    717718        $expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
    718         $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/vendor/wp-polyfill.min.js'></script>\n";
     719        $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/vendor/wp-polyfill{$suffix}.js'></script>\n";
    719720        $expected .= "<script type='text/javascript'>\n";
    720         $expected .= "( 'fetch' in window ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-fetch.min.js\"></scr' + 'ipt>' );( document.contains ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-node-contains.min.js\"></scr' + 'ipt>' );( window.FormData && window.FormData.prototype.keys ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-formdata.min.js\"></scr' + 'ipt>' );( Element.prototype.matches && Element.prototype.closest ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-element-closest.min.js\"></scr' + 'ipt>' );\n";
     721        $expected .= "( 'fetch' in window ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-fetch{$suffix}.js\"></scr' + 'ipt>' );( document.contains ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-node-contains{$suffix}.js\"></scr' + 'ipt>' );( window.FormData && window.FormData.prototype.keys ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-formdata{$suffix}.js\"></scr' + 'ipt>' );( Element.prototype.matches && Element.prototype.closest ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-element-closest{$suffix}.js\"></scr' + 'ipt>' );\n";
    721722        $expected .= "</script>\n";
    722         $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/dom-ready.min.js'></script>\n";
    723         $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/a11y.min.js'></script>\n";
     723        $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/dom-ready{$suffix}.js'></script>\n";
     724        $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/a11y{$suffix}.js'></script>\n";
    724725        $expected .= "<script type='text/javascript' src='http://example2.com'></script>\n";
    725726        $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
     
    13801381        );
    13811382    }
    1382 
    1383     function test_no_source_mapping() {
    1384         $all_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( dirname( ABSPATH ) . '/build/' ) );
    1385         $js_files  = new RegexIterator( $all_files, '/\.js$/' );
    1386         foreach ( $js_files as $js_file ) {
    1387             $contents = trim( file_get_contents( $js_file ) );
    1388 
    1389             // We allow data: URLs.
    1390             $found = preg_match( '/sourceMappingURL=((?!data:).)/', $contents );
    1391             $this->assertSame( $found, 0, "sourceMappingURL found in $js_file" );
    1392         }
    1393     }
    13941383}
  • branches/5.3/tests/phpunit/tests/formatting/Emoji.php

    r45134 r50605  
    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.3/tests/phpunit/tests/oembed/controller.php

    r45607 r50605  
    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.3/tests/phpunit/tests/oembed/getResponseData.php

    r43571 r50605  
    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.3/tests/phpunit/tests/oembed/template.php

    r45445 r50605  
    2323
    2424        $this->assertQueryTrue( 'is_single', 'is_singular', 'is_embed' );
     25
     26        // `print_embed_scripts()` assumes `wp-includes/js/wp-embed-template.js` is present:
     27        self::touch( ABSPATH . WPINC . '/js/wp-embed-template.js' );
    2528
    2629        ob_start();
     
    291294
    292295    /**
     296     * Confirms that no ampersands exist in src/wp-includes/js/wp-embed.js.
     297     *
     298     * See also the `verify:wp-embed` Grunt task for verifying the built file.
     299     *
    293300     * @ticket 34698
    294301     */
     
    296303        $this->assertNotContains( '&', file_get_contents( ABSPATH . WPINC . '/js/wp-embed.js' ) );
    297304    }
    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 
    339305}
  • branches/5.3/tests/phpunit/tests/oembed/wpOembed.php

    r45663 r50605  
    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.3/tests/phpunit/tests/rest-api/rest-users-controller.php

    r45811 r50605  
    18621862
    18631863        $params = array(
    1864             'id'       => '156',
     1864            'id'       => '0',
    18651865            'username' => 'lisasimpson',
    18661866            'password' => 'DavidHasselhoff',
  • branches/5.3/tests/phpunit/tests/shortcode.php

    r46554 r50605  
    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.3/wp-tests-config-sample.php

    r44512 r50605  
    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.