Skip to content

Commit 0d28424

Browse files
committed
Add double quotes around handle/ID in warning
1 parent 36b480b commit 0d28424

File tree

7 files changed

+13
-10
lines changed

7 files changed

+13
-10
lines changed

src/wp-includes/class-wp-dependencies.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ public function get_etag( $load ) {
557557
protected function get_dependency_warning_message( $handle, $missing_dependency_handles ) {
558558
return sprintf(
559559
/* translators: 1: Handle, 2: Comma-separated list of missing dependency handles. */
560-
__( 'The handle %1$s was enqueued with dependencies that are not registered: %2$s.' ),
560+
__( 'The handle "%1$s" was enqueued with dependencies that are not registered: %2$s.' ),
561561
$handle,
562562
implode( ', ', $missing_dependency_handles )
563563
);

src/wp-includes/class-wp-script-modules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ private function sort_item_dependencies( string $id, array $import_types, array
728728
__METHOD__,
729729
sprintf(
730730
/* translators: 1: Script module ID, 2: Comma-separated list of missing dependency IDs. */
731-
__( 'The script module %1$s was enqueued with dependencies that are not registered: %2$s.' ),
731+
__( 'The script module "%1$s" was enqueued with dependencies that are not registered: %2$s.' ),
732732
$id,
733733
implode( ', ', $missing_dependencies )
734734
),

src/wp-includes/class-wp-scripts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ public function reset() {
11771177
protected function get_dependency_warning_message( $handle, $missing_dependency_handles ) {
11781178
return sprintf(
11791179
/* translators: 1: Script handle, 2: Comma-separated list of missing dependency handles. */
1180-
__( 'The script with the handle %1$s was enqueued with dependencies that are not registered: %2$s.' ),
1180+
__( 'The script with the handle "%1$s" was enqueued with dependencies that are not registered: %2$s.' ),
11811181
$handle,
11821182
implode( ', ', $missing_dependency_handles )
11831183
);

src/wp-includes/class-wp-styles.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ public function reset() {
506506
protected function get_dependency_warning_message( $handle, $missing_dependency_handles ) {
507507
return sprintf(
508508
/* translators: 1: Style handle, 2: Comma-separated list of missing dependency handles. */
509-
__( 'The style with the handle %1$s was enqueued with dependencies that are not registered: %2$s.' ),
509+
__( 'The style with the handle "%1$s" was enqueued with dependencies that are not registered: %2$s.' ),
510510
$handle,
511511
implode( ', ', $missing_dependency_handles )
512512
);

tests/phpunit/tests/dependencies/scripts.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4108,7 +4108,8 @@ public function test_wp_scripts_doing_it_wrong_for_missing_dependencies() {
41084108
wp_register_script( 'main', '/main.js', array( 'registered-dep', 'missing-dep' ) );
41094109
wp_enqueue_script( 'main' );
41104110

4111-
get_echo( 'wp_print_scripts' );
4111+
$markup = get_echo( 'wp_print_scripts' );
4112+
$this->assertStringNotContainsString( 'main.js', $markup, 'Expected script to be absent.' );
41124113

41134114
$this->assertArrayHasKey(
41144115
$expected_key,
@@ -4117,7 +4118,7 @@ public function test_wp_scripts_doing_it_wrong_for_missing_dependencies() {
41174118
);
41184119

41194120
$this->assertStringContainsString(
4120-
'The script with the handle main was enqueued with dependencies that are not registered: missing-dep',
4121+
'The script with the handle "main" was enqueued with dependencies that are not registered: missing-dep',
41214122
$this->caught_doing_it_wrong[ $expected_key ],
41224123
'Expected _doing_it_wrong() notice to indicate missing dependencies for enqueued script.'
41234124
);

tests/phpunit/tests/dependencies/styles.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,8 @@ public function test_wp_style_doing_it_wrong_for_missing_dependencies() {
833833

834834
wp_enqueue_style( 'main-style' );
835835

836-
get_echo( 'wp_print_styles' );
836+
$markup = get_echo( 'wp_print_styles' );
837+
$this->assertStringNotContainsString( 'main-style.css', $markup, 'Expected style to be absent.' );
837838

838839
$this->assertArrayHasKey(
839840
$expected_key,
@@ -842,7 +843,7 @@ public function test_wp_style_doing_it_wrong_for_missing_dependencies() {
842843
);
843844

844845
$this->assertStringContainsString(
845-
'The style with the handle main-style was enqueued with dependencies that are not registered: missing-style-dep',
846+
'The style with the handle "main-style" was enqueued with dependencies that are not registered: missing-style-dep',
846847
$this->caught_doing_it_wrong[ $expected_key ],
847848
'Expected _doing_it_wrong() notice to indicate missing dependencies for enqueued styles.'
848849
);

tests/phpunit/tests/script-modules/wpScriptModules.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,7 +2326,8 @@ public function test_missing_script_module_dependency_triggers_incorrect_usage()
23262326
$this->script_modules->register( 'main-module', '/main-module.js', array( 'missing-mod-dep' ) );
23272327
$this->script_modules->enqueue( 'main-module' );
23282328

2329-
get_echo( array( $this->script_modules, 'print_enqueued_script_modules' ) );
2329+
$markup = get_echo( array( $this->script_modules, 'print_enqueued_script_modules' ) );
2330+
$this->assertStringNotContainsString( 'main-module.js', $markup, 'Expected script module to be absent.' );
23302331

23312332
$this->assertArrayHasKey(
23322333
'WP_Script_Modules::sort_item_dependencies',
@@ -2336,7 +2337,7 @@ public function test_missing_script_module_dependency_triggers_incorrect_usage()
23362337

23372338
// Assert the message mentions the missing dependency handle.
23382339
$this->assertStringContainsString(
2339-
'The script module main-module was enqueued with dependencies that are not registered: missing-mod-dep',
2340+
'The script module "main-module" was enqueued with dependencies that are not registered: missing-mod-dep',
23402341
$this->caught_doing_it_wrong['WP_Script_Modules::sort_item_dependencies']
23412342
);
23422343
}

0 commit comments

Comments
 (0)