Skip to content

Commit 23debdb

Browse files
committed
Touch stub CSS files in wp-includes which are created from build process
1 parent 16f8e46 commit 23debdb

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

tests/phpunit/tests/template.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,11 +1677,6 @@ function (): void {
16771677
* @dataProvider data_wp_hoist_late_printed_styles
16781678
*/
16791679
public function test_wp_hoist_late_printed_styles( ?Closure $set_up, int $inline_size_limit, array $expected_styles ): void {
1680-
// These files is created as part of the build process, but the unit tests don't run the build prior to running unit tests on GHA.
1681-
self::touch( ABSPATH . WPINC . '/css/dist/block-library/theme.css' );
1682-
self::touch( ABSPATH . WPINC . '/css/dist/block-library/style.css' );
1683-
self::touch( ABSPATH . WPINC . '/css/dist/block-library/common.css' );
1684-
16851680
switch_theme( 'default' );
16861681
global $wp_styles;
16871682
$wp_styles = null;
@@ -1711,6 +1706,23 @@ static function () {
17111706
register_core_block_style_handles();
17121707
$this->assertTrue( WP_Block_Type_Registry::get_instance()->is_registered( 'core/separator' ), 'Expected the core/separator block to be registered.' );
17131708

1709+
// Ensure all registered styles added as part of the build process are present on the disk. .These files are created as part of the build process, but the unit tests don't run the build prior to running unit tests on GHA.
1710+
foreach ( wp_styles()->registered as $handle => $dependency ) {
1711+
if ( ! is_string( $dependency->src ) ) {
1712+
continue;
1713+
}
1714+
$path = wp_parse_url( $dependency->src, PHP_URL_PATH );
1715+
$position = strpos( $path, WPINC . '/' );
1716+
if ( false === $position ) {
1717+
continue;
1718+
}
1719+
$absolute_path = ABSPATH . substr( $path, $position );
1720+
if ( ! file_exists( $absolute_path ) ) {
1721+
self::touch( $absolute_path );
1722+
file_put_contents( $absolute_path, "/* Stub for $handle */" );
1723+
}
1724+
}
1725+
17141726
// Ensure stylesheet files exist on the filesystem since a build may not have been done.
17151727
$this->ensure_style_asset_file_created(
17161728
'wp-block-library',

0 commit comments

Comments
 (0)