Changeset 50604 for branches/5.4/tests/phpunit/tests/oembed/template.php
- Timestamp:
- 03/26/2021 06:20:24 PM (4 years ago)
- Location:
- branches/5.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.4
-
branches/5.4/tests/phpunit/tests/oembed/template.php
r47198 r50604 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 }
Note: See TracChangeset
for help on using the changeset viewer.