@@ -1707,11 +1707,10 @@ static function () {
17071707 $ this ->assertTrue ( WP_Block_Type_Registry::get_instance ()->is_registered ( 'core/separator ' ), 'Expected the core/separator block to be registered. ' );
17081708
17091709 // Ensure stylesheet files exist on the filesystem since a build may not have been done.
1710- $ this ->ensure_style_asset_file_created ( 'wp-block-library ' , ' css/dist/block-library/style.css ' );
1710+ $ this ->ensure_style_asset_file_created ( 'wp-block-library ' );
17111711 if ( wp_should_load_separate_core_block_assets () ) {
1712- $ this ->ensure_style_asset_file_created ( 'wp-block-separator ' , ' blocks/separator/style.css ' );
1712+ $ this ->ensure_style_asset_file_created ( 'wp-block-separator ' );
17131713 }
1714-
17151714 $ this ->assertFalse ( wp_is_block_theme (), 'Test is not relevant to block themes (only classic themes). ' );
17161715
17171716 // Enqueue a style early, before wp_enqueue_scripts.
@@ -1813,12 +1812,22 @@ static function () {
18131812 *
18141813 * self::touch( ABSPATH . WPINC . '/js/wp-emoji-loader.js' );
18151814 *
1816- * @param string $handle Style handle.
1817- * @param string $relative_path Relative path to the CSS file in the includes directory.
1815+ * @param string $handle Style handle.
1816+ *
1817+ * @throws Exception If the supplied style handle is not registered as expected.
18181818 */
1819- private function ensure_style_asset_file_created ( string $ handle , string $ relative_path ) {
1820- $ this ->assertTrue ( wp_style_is ( $ handle , 'registered ' ), 'Expected the wp-block-separator style to be registered. ' );
1821- $ dependency = wp_styles ()->query ( $ handle );
1819+ private function ensure_style_asset_file_created ( string $ handle ) {
1820+ $ dependency = wp_styles ()->query ( $ handle );
1821+ if ( ! $ dependency ) {
1822+ throw new Exception ( "The stylesheet for $ handle is not registered. " );
1823+ }
1824+ if ( ! $ dependency ->src ) {
1825+ throw new Exception ( "The stylesheet URL for $ handle is empty. " );
1826+ }
1827+ if ( ! str_contains ( $ dependency ->src , '/wp-includes/ ' ) ) {
1828+ throw new Exception ( "Expected the stylesheet URL for $ handle to be in the includes directory, but got {$ dependency ->src }" );
1829+ }
1830+ $ relative_path = preg_replace ( '#^.*?/wp-includes/# ' , '/ ' , $ dependency ->src );
18221831 $ dependency ->src = includes_url ( $ relative_path );
18231832 $ path = ABSPATH . WPINC . '/ ' . $ relative_path ;
18241833 if ( ! file_exists ( $ path ) ) {
0 commit comments