File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
tests/phpunit/tests/dependencies Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -4093,4 +4093,33 @@ public function test_print_translations_no_display_no_sourceurl() {
40934093 $ translations_script_data = $ wp_scripts ->print_translations ( 'test-example ' , false );
40944094 $ this ->assertStringNotContainsStringIgnoringCase ( 'sourceURL= ' , $ translations_script_data );
40954095 }
4096+
4097+ /**
4098+ * Tests that WP_Scripts emits a _doing_it_wrong() notice for missing dependencies.
4099+ *
4100+ * @ticket 64229
4101+ * @covers WP_Dependencies::all_deps
4102+ */
4103+ public function test_wp_scripts_doing_it_wrong_for_missing_dependencies () {
4104+ $ expected_key = 'WP_Dependencies::all_deps ' ;
4105+ $ this ->setExpectedIncorrectUsage ( $ expected_key );
4106+
4107+ wp_register_script ( 'registered-dep ' , '/registered-dep.js ' );
4108+ wp_register_script ( 'main ' , '/main.js ' , array ( 'registered-dep ' , 'missing-dep ' ) );
4109+ wp_enqueue_script ( 'main ' );
4110+
4111+ get_echo ( 'wp_print_scripts ' );
4112+
4113+ $ this ->assertArrayHasKey (
4114+ $ expected_key ,
4115+ $ this ->caught_doing_it_wrong ,
4116+ 'Expected WP_Dependencies::all_deps to trigger a _doing_it_wrong() notice for missing dependency. '
4117+ );
4118+
4119+ $ this ->assertStringContainsString (
4120+ 'The script with the handle main was enqueued with dependencies that are not registered: missing-dep ' ,
4121+ $ this ->caught_doing_it_wrong [ $ expected_key ],
4122+ 'Expected _doing_it_wrong() notice to indicate missing dependencies for enqueued script. '
4123+ );
4124+ }
40964125}
You can’t perform that action at this time.
0 commit comments