Changeset 50464 for branches/5.7
- Timestamp:
- 03/01/2021 08:21:23 PM (4 years ago)
- Location:
- branches/5.7
- Files:
-
- 2 deleted
- 17 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/5.7
- Property svn:mergeinfo changed
/trunk merged: 50441-50444
- Property svn:mergeinfo changed
-
branches/5.7/.github/workflows/phpunit-tests.yml
r50413 r50464 16 16 17 17 env: 18 LOCAL_DIR: build19 18 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} 20 19 COMPOSER_INSTALL: ${{ false }} … … 22 21 PHPUNIT_SCRIPT: php 23 22 LOCAL_PHP_MEMCACHED: ${{ false }} 23 SLOW_TESTS: 'external-http,media,restapi' 24 24 25 25 jobs: 26 # Sets up WordPress for testing or development use.26 # Sets up the workflow for testing. 27 27 # 28 28 # Performs the following steps: 29 29 # - 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 30 setup-workflow: 31 name: Setup Workflow 40 32 runs-on: ubuntu-latest 41 33 if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} … … 47 39 with: 48 40 access_token: ${{ github.token }} 49 50 - name: Checkout repository51 uses: actions/checkout@v252 53 - name: Log debug information54 run: |55 echo "$GITHUB_REF"56 echo "$GITHUB_EVENT_NAME"57 npm --version58 node --version59 curl --version60 git --version61 svn --version62 php --version63 php -i64 locale -a65 66 - name: Install NodeJS67 uses: actions/setup-node@v268 with:69 node-version: 1470 71 - name: Cache NodeJS modules72 uses: actions/cache@v273 env:74 cache-name: cache-node-modules75 with:76 # npm cache files are stored in `~/.npm` on Linux/macOS77 path: ~/.npm78 key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}79 restore-keys: |80 ${{ runner.os }}-npm-81 82 - name: Install Dependencies83 run: npx install-changed --install-command="npm ci"84 85 - name: Build WordPress86 run: npm run build87 88 - name: Create ZIP artifact89 uses: thedoctor0/zip-release@0.4.190 with:91 filename: built-wp-${{ github.sha }}.zip92 exclusions: '*.git* /*node_modules/* packagehash.txt'93 94 - name: Upload build artifact95 uses: actions/upload-artifact@v296 with:97 name: built-wp-${{ github.sha }}98 path: built-wp-${{ github.sha }}.zip99 if-no-files-found: error100 41 101 42 # Runs the PHPUnit tests for WordPress. … … 104 45 # - Set environment variables. 105 46 # - 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.108 47 # - Installs NodeJS 14. 109 48 # - Sets up caching for NPM. 110 # _ Installs NPM dependencies using install-changed to hash the `package.json` file.49 # - Installs NPM dependencies 111 50 # - Configures caching for Composer. 112 # _Installs Composer dependencies (if desired).51 # - Installs Composer dependencies (if desired). 113 52 # - Logs Docker debug information (about both the Docker installation within the runner). 114 53 # - Starts the WordPress Docker container. … … 125 64 # - todo: Configure Slack notifications for failing tests. 126 65 test-php: 127 name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }} 128 needs: setup-wordpress 66 name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.split_slow && ' slow tests' || '' }} ${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }} 129 67 runs-on: ${{ matrix.os }} 130 68 strategy: … … 133 71 os: [ ubuntu-latest ] 134 72 memcached: [ false ] 73 split_slow: [ false ] 135 74 multisite: [ false, true ] 136 75 include: 76 # Additional "slow" jobs for PHP 5.6. 77 - php: '5.6.20' 78 os: ubuntu-latest 79 memcached: false 80 multisite: false 81 split_slow: true 82 - php: '5.6.20' 83 os: ubuntu-latest 84 memcached: false 85 multisite: true 86 split_slow: true 137 87 # Include jobs for PHP 7.4 with memcached. 138 88 - php: '7.4' … … 161 111 echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV 162 112 163 - name: Download the built WordPress artifact 164 uses: actions/download-artifact@v2 165 with: 166 name: built-wp-${{ github.sha }} 167 168 - name: Unzip built artifact 169 run: unzip built-wp-${{ github.sha }}.zip 113 - name: Checkout repository 114 uses: actions/checkout@v2 170 115 171 116 - name: Install NodeJS … … 232 177 if: ${{ matrix.memcached }} 233 178 run: | 234 cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php179 cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php 235 180 docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached 236 181 … … 257 202 run: npm run env:install 258 203 204 - name: Run slow PHPUnit tests 205 if: ${{ matrix.split_slow }} 206 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }} 207 208 - name: Run PHPUnit tests for single site excluding slow tests 209 if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }} 210 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required 211 212 - name: Run PHPUnit tests for Multisite excluding slow tests 213 if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }} 214 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers 215 259 216 - name: Run PHPUnit tests 217 if: ${{ matrix.php >= '7.0' }} 260 218 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} 261 219 262 220 - name: Run AJAX tests 221 if: ${{ ! matrix.split_slow }} 263 222 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax 264 223 265 224 - name: Run ms-files tests as a multisite install 266 if: ${{ matrix.multisite }}225 if: ${{ matrix.multisite && ! matrix.split_slow }} 267 226 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files 268 227 269 228 - name: Run external HTTP tests 270 if: ${{ ! matrix.multisite }}229 if: ${{ ! matrix.multisite && ! matrix.split_slow }} 271 230 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group external-http 272 231 273 232 # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist. 274 233 - name: Run (xDebug) tests 234 if: ${{ ! matrix.split_slow }} 275 235 run: LOCAL_PHP_XDEBUG=true npm run test:${{ env.PHPUNIT_SCRIPT }} -- -v --group xdebug --exclude-group __fakegroup__ 276 236 … … 281 241 repository: 'WordPress/phpunit-test-runner' 282 242 path: 'test-runner' 283 284 - name: Set up the Git repository285 if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}286 run: |287 git init288 git remote add origin https://github.com/WordPress/wordpress-develop.git289 git fetch290 git reset origin/master291 243 292 244 - name: Submit test results to the WordPress.org host test results -
branches/5.7/.github/workflows/test-coverage.yml
r50387 r50464 7 7 8 8 env: 9 LOCAL_DIR: build10 9 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} 11 10 COMPOSER_INSTALL: ${{ false }} … … 27 26 # - Sets up caching for NPM. 28 27 # _ Installs NPM dependencies using install-changed to hash the `package.json` file. 29 # - Builds WordPress to run from the `build` directory.30 28 # - Logs Docker debug information (about the Docker installation within the runner). 31 29 # - Starts the WordPress Docker container. … … 88 86 run: npx install-changed --install-command="npm ci" 89 87 90 - name: Build WordPress91 run: npm run build92 93 88 - name: Docker debug information 94 89 run: | -
branches/5.7/Gruntfile.js
r50457 r50464 8 8 var path = require('path'), 9 9 fs = require( 'fs' ), 10 glob = require( 'glob' ), 11 assert = require( 'assert' ).strict, 10 12 spawn = require( 'child_process' ).spawnSync, 11 13 SOURCE_DIR = 'src/', … … 1434 1436 ] ); 1435 1437 1438 /** 1439 * Build verification tasks. 1440 */ 1441 grunt.registerTask( 'verify:build', [ 1442 'verify:wp-embed', 1443 'verify:old-files', 1444 'verify:source-maps', 1445 ] ); 1446 1447 /** 1448 * Build assertions for wp-embed.min.js. 1449 * 1450 * @ticket 34698 1451 */ 1452 grunt.registerTask( 'verify:wp-embed', function() { 1453 const file = `${ BUILD_DIR }/wp-includes/js/wp-embed.min.js`; 1454 1455 assert( 1456 fs.existsSync( file ), 1457 'The build/wp-includes/js/wp-embed.min.js file does not exist.' 1458 ); 1459 1460 const contents = fs.readFileSync( file, { 1461 encoding: 'utf8', 1462 } ); 1463 1464 assert( 1465 contents.length > 0, 1466 'The build/wp-includes/js/wp-embed.min.js file must not be empty.' 1467 ); 1468 assert( 1469 false === contents.includes( '&' ), 1470 'The build/wp-includes/js/wp-embed.min.js file must not contain ampersands.' 1471 ); 1472 } ); 1473 1474 /** 1475 * Build assertions to ensure no project files are inside `$_old_files` in the build directory. 1476 * 1477 * @ticket 36083 1478 */ 1479 grunt.registerTask( 'verify:old-files', function() { 1480 const file = `${ BUILD_DIR }wp-admin/includes/update-core.php`; 1481 1482 assert( 1483 fs.existsSync( file ), 1484 'The build/wp-admin/includes/update-core.php file does not exist.' 1485 ); 1486 1487 const contents = fs.readFileSync( file, { 1488 encoding: 'utf8', 1489 } ); 1490 1491 assert( 1492 contents.length > 0, 1493 'The build/wp-admin/includes/update-core.php file must not be empty.' 1494 ); 1495 1496 const match = contents.match( /\$_old_files = array\(([^\)]+)\);/ ); 1497 1498 assert( 1499 match.length > 0, 1500 'The build/wp-admin/includes/update-core.php file does not include an `$_old_files` array.' 1501 ); 1502 1503 const files = match[1].split( '\n\t' ).filter( function( file ) { 1504 // Filter out empty lines 1505 if ( '' === file ) { 1506 return false; 1507 } 1508 1509 // Filter out commented out lines 1510 if ( 0 === file.indexOf( '/' ) ) { 1511 return false; 1512 } 1513 1514 return true; 1515 } ).map( function( file ) { 1516 // Strip leading and trailing single quotes and commas 1517 return file.replace( /^\'|\',$/g, '' ); 1518 } ); 1519 1520 files.forEach(function( file ){ 1521 const search = `${ BUILD_DIR }${ file }`; 1522 assert( 1523 false === fs.existsSync( search ), 1524 `${ search } should not be present in the $_old_files array.` 1525 ); 1526 }); 1527 } ); 1528 1529 /** 1530 * Build assertions for the lack of source maps in JavaScript files. 1531 * 1532 * @ticket 24994 1533 * @ticket 46218 1534 */ 1535 grunt.registerTask( 'verify:source-maps', function() { 1536 const path = `${ BUILD_DIR }**/*.js`; 1537 const files = glob.sync( path ); 1538 1539 assert( 1540 files.length > 0, 1541 'No JavaScript files found in the build directory.' 1542 ); 1543 1544 files.forEach( function( file ) { 1545 const contents = fs.readFileSync( file, { 1546 encoding: 'utf8', 1547 } ); 1548 // `data:` URLs are allowed: 1549 const match = contents.match( /sourceMappingURL=((?!data:).)/ ); 1550 1551 assert( 1552 match === null, 1553 `The ${ file } file must not contain a sourceMappingURL.` 1554 ); 1555 } ); 1556 } ); 1557 1436 1558 grunt.registerTask( 'build', function() { 1437 1559 if ( grunt.option( 'dev' ) ) { … … 1447 1569 'includes:emoji', 1448 1570 'includes:embed', 1449 'replace:emojiBannerText' 1571 'replace:emojiBannerText', 1572 'verify:build' 1450 1573 ] ); 1451 1574 } -
branches/5.7/README.md
r49957 r50464 46 46 47 47 ``` 48 npm run watch48 npm run dev 49 49 ``` 50 50 -
branches/5.7/tests/phpunit/includes/abstract-testcase.php
r49916 r50464 1294 1294 ); 1295 1295 } 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 } 1296 1318 } -
branches/5.7/tests/phpunit/tests/admin/includesPlugin.php
r49566 r50464 5 5 */ 6 6 class 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 7 15 function test_get_plugin_data() { 8 16 $data = get_plugin_data( DIR_TESTDATA . '/plugins/hello.php' ); … … 370 378 'list_files_test_plugin/subdir/subfile.php', 371 379 ); 372 $this->assertSame( $expected, $plugin_files );373 380 374 381 unlink( $sub_dir . '/subfile.php' ); … … 376 383 rmdir( $sub_dir ); 377 384 rmdir( $plugin_dir ); 385 386 $this->assertSame( $expected, $plugin_files ); 378 387 } 379 388 … … 382 391 */ 383 392 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 ); 392 407 $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 }400 408 } 401 409 … … 403 411 * @covers ::get_mu_plugins 404 412 */ 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 ); 420 424 } 421 425 … … 423 427 * @covers ::get_mu_plugins 424 428 */ 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(); 436 434 437 435 // Clean up. 438 436 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 ) ); 444 440 } 445 441 … … 447 443 * @covers ::get_mu_plugins 448 444 */ 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_plugins473 */474 445 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 ); 482 447 483 448 $this->_create_plugin( '<?php\n//Test', 'foo.php', WPMU_PLUGIN_DIR ); 484 449 $this->_create_plugin( '<?php\n//Test 2', 'bar.txt', WPMU_PLUGIN_DIR ); 485 450 $found = get_mu_plugins(); 486 $this->assertSame( array( 'foo.php' ), array_keys( $found ) );487 451 488 452 // Clean up. 489 453 unlink( WPMU_PLUGIN_DIR . '/foo.php' ); 490 454 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 ) ); 496 457 } 497 458 … … 652 613 653 614 /** 654 * Move existing mu-plugins to wp-content/mu-plugin /backup.615 * Move existing mu-plugins to wp-content/mu-plugin-backup. 655 616 * 656 617 * @since 4.2.0 … … 658 619 * @access private 659 620 */ 660 private function _back_up_mu_plugins() {621 private static function _back_up_mu_plugins() { 661 622 if ( is_dir( WPMU_PLUGIN_DIR ) ) { 662 623 $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 ); 682 625 } 683 626 } … … 690 633 * @access private 691 634 */ 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 ); 708 640 } 709 641 710 642 if ( is_dir( $mu_bu_dir ) ) { 711 r mdir( $mu_bu_dir);643 rename( $mu_bu_dir, WPMU_PLUGIN_DIR ); 712 644 } 713 645 } -
branches/5.7/tests/phpunit/tests/dependencies/jquery.php
r50287 r50464 38 38 $this->assertSame( $jquery_scripts[ $dep ], $o->src ); 39 39 } 40 }41 42 function test_presence_of_jquery_no_conflict() {43 $contents = trim( file_get_contents( ABSPATH . WPINC . '/js/jquery/jquery.js' ) );44 $noconflict = 'jQuery.noConflict();';45 $end = substr( $contents, - strlen( $noconflict ) );46 $this->assertSame( $noconflict, $end );47 40 } 48 41 -
branches/5.7/tests/phpunit/tests/dependencies/scripts.php
r50408 r50464 729 729 $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/vendor/wp-polyfill{$suffix}.js' id='wp-polyfill-js'></script>\n"; 730 730 $expected .= "<script type='text/javascript' id='wp-polyfill-js-after'>\n"; 731 $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.DOMRect ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-dom-rect{$suffix}.js\"></scr' + 'ipt>' );( window.URL && window.URL.prototype && window.URLSearchParams ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-url{$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>' );( 'objectFit' in document.documentElement.style ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-object-fit .min.js\"></scr' + 'ipt>' );\n";731 $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.DOMRect ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-dom-rect{$suffix}.js\"></scr' + 'ipt>' );( window.URL && window.URL.prototype && window.URLSearchParams ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-url{$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>' );( 'objectFit' in document.documentElement.style ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-object-fit{$suffix}.js\"></scr' + 'ipt>' );\n"; 732 732 $expected .= "</script>\n"; 733 733 $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/dom-ready{$suffix}.js' id='wp-dom-ready-js'></script>\n"; … … 1418 1418 } 1419 1419 1420 function test_no_source_mapping() {1421 $all_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( dirname( ABSPATH ) . '/build/' ) );1422 $js_files = new RegexIterator( $all_files, '/\.js$/' );1423 foreach ( $js_files as $js_file ) {1424 $contents = trim( file_get_contents( $js_file ) );1425 1426 // We allow data: URLs.1427 $found = preg_match( '/sourceMappingURL=((?!data:).)/', $contents );1428 $this->assertSame( $found, 0, "sourceMappingURL found in $js_file" );1429 }1430 }1431 1432 1420 /** 1433 1421 * @ticket 52534 -
branches/5.7/tests/phpunit/tests/formatting/Emoji.php
r49239 r50464 14 14 */ 15 15 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' ); 16 18 $output = get_echo( '_print_emoji_detection_script' ); 17 19 … … 32 34 add_filter( 'emoji_svg_url', array( $this, '_filtered_emoji_svn_cdn' ) ); 33 35 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' ); 34 38 $output = get_echo( '_print_emoji_detection_script' ); 35 39 … … 53 57 add_filter( 'emoji_url', array( $this, '_filtered_emoji_png_cdn' ) ); 54 58 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' ); 55 61 $output = get_echo( '_print_emoji_detection_script' ); 56 62 -
branches/5.7/tests/phpunit/tests/oembed/controller.php
r49603 r50464 35 35 ) 36 36 ); 37 38 // `get_post_embed_html()` assumes `wp-includes/js/wp-embed.js` is present: 39 self::touch( ABSPATH . WPINC . '/js/wp-embed.js' ); 37 40 } 38 41 -
branches/5.7/tests/phpunit/tests/oembed/getResponseData.php
r50401 r50464 6 6 */ 7 7 class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 8 public function setUp() { 9 parent::setUp(); 10 11 // `get_post_embed_html()` assumes `wp-includes/js/wp-embed.js` is present: 12 self::touch( ABSPATH . WPINC . '/js/wp-embed.js' ); 13 } 14 8 15 function test_get_oembed_response_data_non_existent_post() { 9 16 $this->assertFalse( get_oembed_response_data( 0, 100 ) ); -
branches/5.7/tests/phpunit/tests/oembed/template.php
r48937 r50464 23 23 24 24 $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' ); 25 28 26 29 ob_start(); … … 291 294 292 295 /** 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 * 293 300 * @ticket 34698 294 301 */ … … 296 303 $this->assertNotContains( '&', file_get_contents( ABSPATH . WPINC . '/js/wp-embed.js' ) ); 297 304 } 298 299 /**300 * @ticket 34698301 *302 * @depends test_js_no_ampersands303 *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 its306 * optimizations (which we tweak to avoid, but indirectly -- understandably, there's307 * 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 be314 * run during continuous integration.315 *316 * However, we need to verify that `qunit:compiled` runs before `phpunit`. So this test also317 * does a cheap check for a registered Grunt task called `test` that contains both318 * `qunit:compiled` and `phpunit`, in that order.319 *320 * One final failsafe: The Gruntfile.js assertion takes place before checking for the existence321 * of wp-embed.min.js. If the Grunt tasks are significantly refactored later, it could indicate322 * that wp-embed.min.js doesn't exist anymore. We wouldn't want the test to silently become one323 * 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 339 305 } -
branches/5.7/tests/phpunit/tests/oembed/wpOembed.php
r48937 r50464 19 19 20 20 $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' ); 21 24 } 22 25 -
branches/5.7/tests/phpunit/tests/shortcode.php
r49117 r50464 747 747 function test_php_and_js_shortcode_attribute_regexes_match() { 748 748 749 $file = file_get_contents( ABSPATH . WPINC . '/js/shortcode.js' );749 $file = file_get_contents( ABSPATH . 'js/_enqueues/wp/shortcode.js' ); 750 750 $matched = preg_match( '|\s+pattern = (\/.+\/)g;|', $file, $matches ); 751 751 $php = get_shortcode_atts_regex(); -
branches/5.7/tests/qunit/index.html
r50137 r50464 153 153 <script src="wp-includes/js/shortcode.js"></script> 154 154 <script src="wp-includes/js/api-request.js"></script> 155 <script src="wp-includes/js/jquery.js"></script> 155 156 <script src="wp-includes/js/wp-api.js"></script> 156 157 <script src="wp-admin/js/customize-controls.js"></script> -
branches/5.7/wp-tests-config-sample.php
r47201 r50464 2 2 3 3 /* 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 } 4 define( 'ABSPATH', dirname( __FILE__ ) . '/src/' ); 9 5 10 6 /*
Note: See TracChangeset
for help on using the changeset viewer.