Skip to content

Commit

Permalink
Ignore bundled packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Feb 6, 2025
1 parent d8b4834 commit 75f8e85
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion phpunit/script-dependencies-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* @group script-dependencies
*/
class Test_Script_Dependencies extends WP_UnitTestCase {
public $bundled_scripts = array( 'wp-upload-media' );

/**
* Tests for accidental `wp-polyfill` script dependents.
*/
Expand All @@ -15,6 +17,11 @@ public function test_polyfill_dependents() {
// Iterate over all registered scripts, finding dependents of the `wp-polyfill` script.
// Based on private `WP_Scripts::get_dependents` method.
foreach ( $registered_scripts as $registered_handle => $args ) {
// Ignore bundled packages, they don't load separate polyfills.
if ( in_array( $registered_handle, $this->bundled_scripts, true ) ) {
continue;
}

if ( in_array( 'wp-polyfill', $args->deps, true ) ) {
$dependents[] = $registered_handle;
}
Expand All @@ -34,7 +41,6 @@ public function test_polyfill_dependents() {
'wp-router',
'wp-url',
'wp-widgets',
'wp-upload-media',
);

$this->assertEqualSets( $expected, $dependents );
Expand Down

0 comments on commit 75f8e85

Please sign in to comment.