Skip to content

Commit d3fbff0

Browse files
committed
Improve ensuring that wp-block-library is not empty
1 parent f4694aa commit d3fbff0

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tests/phpunit/tests/template.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,7 @@ static function () {
17191719
$block_library_dependency = wp_styles()->query( 'wp-block-library' );
17201720
$this->assertTrue( (bool) $block_library_dependency, 'Expected wp-block-library stylesheet to be registered.' );
17211721
$this->assertIsString( $block_library_dependency->src, 'Expected wp-block-library to have a string src. Dependency: ' . json_encode( $block_library_dependency ) );
1722+
$this->assertNotEmpty( file_get_contents( $block_library_dependency->extra['path'] ), 'Expected wp-block-library file to not be empty.' );
17221723

17231724
if ( wp_should_load_separate_core_block_assets() ) {
17241725
$this->ensure_style_asset_file_created( 'wp-block-separator', 'blocks/separator/style.css', true );
@@ -1838,11 +1839,8 @@ private function ensure_style_asset_file_created( string $handle, string $relati
18381839
}
18391840
$dependency->src = includes_url( $relative_path );
18401841
$path = ABSPATH . WPINC . '/' . $relative_path;
1841-
if ( ! file_exists( $path ) ) {
1842-
$dir = dirname( $path );
1843-
if ( ! file_exists( $dir ) ) {
1844-
mkdir( $dir, 0777, true );
1845-
}
1842+
self::touch( $path );
1843+
if ( 0 === filesize( $path ) ) {
18461844
file_put_contents( $path, "/* CSS for $handle */" );
18471845
}
18481846
if ( $add_path_data ) {

0 commit comments

Comments
 (0)