-
-
Save ironprogrammer/314c2d6af804043ec33841f72cbfca36 to your computer and use it in GitHub Desktop.
Test mu-plugin for Trac 53566
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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