Changeset 61323 for trunk/tests/phpunit/tests/dependencies/scripts.php
- Timestamp:
- 11/30/2025 12:54:26 AM (9 months ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/dependencies/scripts.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/dependencies/scripts.php
r61223 r61323 4094 4094 $this->assertStringNotContainsStringIgnoringCase( 'sourceURL=', $translations_script_data ); 4095 4095 } 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_incorrect_usage = 'WP_Scripts::add'; 4105 $this->setExpectedIncorrectUsage( $expected_incorrect_usage ); 4106 4107 wp_register_script( 'registered-dep', '/registered-dep.js' ); 4108 wp_enqueue_script( 'main', '/main.js', array( 'registered-dep', 'missing-dep' ) ); 4109 4110 $markup = get_echo( 'wp_print_scripts' ); 4111 $this->assertStringNotContainsString( 'main.js', $markup, 'Expected script to be absent.' ); 4112 4113 $this->assertArrayHasKey( 4114 $expected_incorrect_usage, 4115 $this->caught_doing_it_wrong, 4116 "Expected $expected_incorrect_usage 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_incorrect_usage ], 4122 'Expected _doing_it_wrong() notice to indicate missing dependencies for enqueued script.' 4123 ); 4124 } 4096 4125 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)