Skip to content

Instantly share code, notes, and snippets.

@ironprogrammer
Last active January 25, 2023 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ironprogrammer/314c2d6af804043ec33841f72cbfca36 to your computer and use it in GitHub Desktop.
Save ironprogrammer/314c2d6af804043ec33841f72cbfca36 to your computer and use it in GitHub Desktop.
Test mu-plugin for Trac 53566
<?php
/**
* Testing for https://core.trac.wordpress.org/ticket/53566
*
* Tests output from _doing_it_wrong() notice in register_block_script_handle().
*
* To install, copy the contents of this script into a new file, e.g. test_trac_53566.php,
* in the `wp-content/mu-plugins/` directory. You may need to create the directory.
* To uninstall, move or delete this file from the `wp-content/mu-plugins/` directory.
*
* Acceptance Criteria:
* Notice should contain the expected path to the missing `.asset.php` file derived from $metadata['script'].
* For example, `path/script-file.js` -> `path/script-file.asset.php`.
*
* Existing notice:
* The asset file for the "script" defined in "unit-tests/test-block" block definition is missing.
*
* Expected notice:
* The asset file "blocks/notice/missing-asset.asset.php" for the "script" defined in "unit-tests/test-block" block definition is missing.
*/
add_action( 'plugins_loaded', 'test_trac_53566' );
// Register a script handle that is missing an asset file.
function test_trac_53566() {
$metadata = array(
'file' => __FILE__,
'name' => 'unit-tests/test-block',
'script' => 'file:./blocks/notice/missing-asset.js',
);
register_block_script_handle( $metadata, 'script' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment