From d86ca2e9698353b580530bab311db8de1b98b5a7 Mon Sep 17 00:00:00 2001 From: James Morrison Date: Thu, 18 Sep 2025 13:29:23 +0100 Subject: [PATCH 1/3] Allow an asset to be defined with 'css' / 'js' / 'blocks' prefix to ensure correct file type is used. --- src/Assets/GetAssetInfo.php | 4 +- tests/Assets/GetAssetInfoTest.php | 200 ++++++++++++++++++++++++++++++ 2 files changed, 203 insertions(+), 1 deletion(-) diff --git a/src/Assets/GetAssetInfo.php b/src/Assets/GetAssetInfo.php index f2d13a3..ef24266 100644 --- a/src/Assets/GetAssetInfo.php +++ b/src/Assets/GetAssetInfo.php @@ -59,7 +59,9 @@ public function get_asset_info( string $slug, ?string $attribute = null ): strin throw new RuntimeException( 'Asset variables not set. Please run setup_asset_vars() before calling get_asset_info().' ); } - if ( file_exists( $this->dist_path . 'js/' . $slug . '.asset.php' ) ) { + if ( file_exists( $this->dist_path . $slug . '.asset.php' ) ) { + $asset = require $this->dist_path . $slug . '.asset.php'; + } elseif ( file_exists( $this->dist_path . 'js/' . $slug . '.asset.php' ) ) { $asset = require $this->dist_path . 'js/' . $slug . '.asset.php'; } elseif ( file_exists( $this->dist_path . 'css/' . $slug . '.asset.php' ) ) { $asset = require $this->dist_path . 'css/' . $slug . '.asset.php'; diff --git a/tests/Assets/GetAssetInfoTest.php b/tests/Assets/GetAssetInfoTest.php index d08139f..721b3ae 100644 --- a/tests/Assets/GetAssetInfoTest.php +++ b/tests/Assets/GetAssetInfoTest.php @@ -130,4 +130,204 @@ public function test_get_asset_info_throws_exception_when_called_without_setting slug: 'test-script' ); } + + /** + * Test get_asset_info with prefix-based slug handling (css/, js/, blocks/). + * + * @return void + */ + public function test_get_asset_info_with_prefix_based_slug() { + $asset_info = new class() { + use GetAssetInfo; + }; + + // Initialize WP_Filesystem + global $wp_filesystem; + if ( empty( $wp_filesystem ) ) { + require_once ABSPATH . '/wp-admin/includes/file.php'; + WP_Filesystem(); + } + + // Create a temporary test directory structure + $test_dir = get_temp_dir() . 'wp-framework-test-' . uniqid(); + $css_dir = $test_dir . '/css'; + $js_dir = $test_dir . '/js'; + $blocks_dir = $test_dir . '/blocks'; + + // Create directories using WP_Filesystem + $wp_filesystem->mkdir( $test_dir, 0755 ); + $wp_filesystem->mkdir( $css_dir, 0755 ); + $wp_filesystem->mkdir( $js_dir, 0755 ); + $wp_filesystem->mkdir( $blocks_dir, 0755 ); + + // Create asset files + $css_asset = [ + 'version' => '1.0.0', + 'dependencies' => [ 'css-dep' ], + ]; + $css_content = 'put_contents( $css_dir . '/file.asset.php', $css_content ); + + $js_asset = [ + 'version' => '2.0.0', + 'dependencies' => [ 'js-dep' ], + ]; + $js_content = 'put_contents( $js_dir . '/file.asset.php', $js_content ); + + $blocks_asset = [ + 'version' => '3.0.0', + 'dependencies' => [ 'blocks-dep' ], + ]; + $blocks_content = 'put_contents( $blocks_dir . '/file.asset.php', $blocks_content ); + + $asset_info->setup_asset_vars( + dist_path: $test_dir, + fallback_version: '1.0.0' + ); + + // Test CSS prefix + $asset = $asset_info->get_asset_info( slug: 'css/file' ); + $this->assertEquals( $css_asset, $asset ); + + // Test JS prefix + $asset = $asset_info->get_asset_info( slug: 'js/file' ); + $this->assertEquals( $js_asset, $asset ); + + // Test blocks prefix + $asset = $asset_info->get_asset_info( slug: 'blocks/file' ); + $this->assertEquals( $blocks_asset, $asset ); + + // Clean up using WP_Filesystem + $wp_filesystem->delete( $css_dir . '/file.asset.php' ); + $wp_filesystem->delete( $js_dir . '/file.asset.php' ); + $wp_filesystem->delete( $blocks_dir . '/file.asset.php' ); + $wp_filesystem->rmdir( $css_dir ); + $wp_filesystem->rmdir( $js_dir ); + $wp_filesystem->rmdir( $blocks_dir ); + $wp_filesystem->rmdir( $test_dir ); + } + + /** + * Test get_asset_info priority order: prefix-based slugs take priority over fallback. + * + * @return void + */ + public function test_get_asset_info_priority_order_prefix_vs_fallback() { + $asset_info = new class() { + use GetAssetInfo; + }; + + // Initialize WP_Filesystem + global $wp_filesystem; + if ( empty( $wp_filesystem ) ) { + require_once ABSPATH . '/wp-admin/includes/file.php'; + WP_Filesystem(); + } + + // Create a temporary test directory structure + $test_dir = get_temp_dir() . 'wp-framework-test-' . uniqid(); + $css_dir = $test_dir . '/css'; + $js_dir = $test_dir . '/js'; + + // Create directories using WP_Filesystem + $wp_filesystem->mkdir( $test_dir, 0755 ); + $wp_filesystem->mkdir( $css_dir, 0755 ); + $wp_filesystem->mkdir( $js_dir, 0755 ); + + // Create asset files + $css_prefix_asset = [ + 'version' => '2.0.0', + 'dependencies' => [ 'css-prefix-dep' ], + ]; + $css_content = 'put_contents( $css_dir . '/file.asset.php', $css_content ); + + $js_fallback_asset = [ + 'version' => '1.0.0', + 'dependencies' => [ 'js-fallback-dep' ], + ]; + $js_content = 'put_contents( $js_dir . '/file.asset.php', $js_content ); + + $asset_info->setup_asset_vars( + dist_path: $test_dir, + fallback_version: '1.0.0' + ); + + // Test that prefix-based slug takes priority + $asset = $asset_info->get_asset_info( slug: 'css/file' ); + $this->assertEquals( $css_prefix_asset, $asset ); + + // Test that fallback still works for non-prefixed slugs + $asset = $asset_info->get_asset_info( slug: 'file' ); + $this->assertEquals( $js_fallback_asset, $asset ); + + // Clean up using WP_Filesystem + $wp_filesystem->delete( $css_dir . '/file.asset.php' ); + $wp_filesystem->delete( $js_dir . '/file.asset.php' ); + $wp_filesystem->rmdir( $css_dir ); + $wp_filesystem->rmdir( $js_dir ); + $wp_filesystem->rmdir( $test_dir ); + } + + /** + * Test get_asset_info fallback behavior when direct file doesn't exist. + * + * @return void + */ + public function test_get_asset_info_fallback_when_direct_file_missing() { + $asset_info = new class() { + use GetAssetInfo; + }; + + // Initialize WP_Filesystem + global $wp_filesystem; + if ( empty( $wp_filesystem ) ) { + require_once ABSPATH . '/wp-admin/includes/file.php'; + WP_Filesystem(); + } + + // Create a temporary test directory structure + $test_dir = get_temp_dir() . 'wp-framework-test-' . uniqid(); + $js_dir = $test_dir . '/js'; + $css_dir = $test_dir . '/css'; + + // Create directories using WP_Filesystem + $wp_filesystem->mkdir( $test_dir, 0755 ); + $wp_filesystem->mkdir( $js_dir, 0755 ); + $wp_filesystem->mkdir( $css_dir, 0755 ); + + // Create asset files in subdirectories only (no direct file) + $js_asset = [ + 'version' => '1.0.0', + 'dependencies' => [ 'js-dep' ], + ]; + $js_content = 'put_contents( $js_dir . '/fallback-asset.asset.php', $js_content ); + + $css_asset = [ + 'version' => '1.5.0', + 'dependencies' => [ 'css-dep' ], + ]; + $css_content = 'put_contents( $css_dir . '/fallback-asset.asset.php', $css_content ); + + $asset_info->setup_asset_vars( + dist_path: $test_dir, + fallback_version: '1.0.0' + ); + + // Test that it falls back to JS directory first (priority order: js -> css -> blocks) + $asset = $asset_info->get_asset_info( slug: 'fallback-asset' ); + $this->assertEquals( $js_asset, $asset ); + + // Clean up using WP_Filesystem + $wp_filesystem->delete( $js_dir . '/fallback-asset.asset.php' ); + $wp_filesystem->delete( $css_dir . '/fallback-asset.asset.php' ); + $wp_filesystem->rmdir( $js_dir ); + $wp_filesystem->rmdir( $css_dir ); + $wp_filesystem->rmdir( $test_dir ); + } } From aff226d9ca9f558052e7965e7a3f048363f86d9e Mon Sep 17 00:00:00 2001 From: James Morrison Date: Thu, 18 Sep 2025 13:37:21 +0100 Subject: [PATCH 2/3] Updated docs. --- docs/Asset-Loading.md | 65 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/docs/Asset-Loading.md b/docs/Asset-Loading.md index a37b67b..f8606dc 100644 --- a/docs/Asset-Loading.md +++ b/docs/Asset-Loading.md @@ -1,7 +1,16 @@ # Asset Loading ## Overview -Use the `TenupFramework\Assets\GetAssetInfo` trait to read dependency and version metadata generated by your build (the `.asset.php` sidecar files). The trait looks for files in: +Use the `TenupFramework\Assets\GetAssetInfo` trait to read dependency and version metadata generated by your build (the `.asset.php` sidecar files). The trait supports two approaches for locating asset files: + +### Prefix-based paths (recommended) +When you specify a prefix in the slug, the trait looks for files directly in the corresponding subdirectory: +- `get_asset_info('css/admin')` → `dist/css/admin.asset.php` +- `get_asset_info('js/admin')` → `dist/js/admin.asset.php` +- `get_asset_info('blocks/my-block')` → `dist/blocks/my-block.asset.php` + +### Fallback behavior +For slugs without prefixes, the trait searches in this order: - `dist/js/{slug}.asset.php` - `dist/css/{slug}.asset.php` - `dist/blocks/{slug}.asset.php` @@ -55,6 +64,19 @@ Notes: - If your build produces multiple variants (e.g., `admin.js` vs `admin.min.js`), you can conditionally enqueue based on `SCRIPT_DEBUG` or `wp_get_environment_type() === 'development'`. ## Enqueuing scripts + +### Using prefix-based paths (recommended) +```php +wp_enqueue_script( + 'tenup_plugin_admin', + YOUR_PLUGIN_URL . 'dist/js/admin.js', + $this->get_asset_info( 'js/admin', 'dependencies' ), + $this->get_asset_info( 'js/admin', 'version' ), + true +); +``` + +### Using fallback behavior ```php wp_enqueue_script( 'tenup_plugin_admin', @@ -68,6 +90,18 @@ wp_enqueue_script( - version: string used for cache busting ## Enqueuing styles + +### Using prefix-based paths (recommended) +```php +wp_enqueue_style( + 'tenup_plugin_admin', + YOUR_PLUGIN_URL . 'dist/css/admin.css', + [], // CSS dependencies are uncommon; pass [] unless needed + $this->get_asset_info( 'css/admin', 'version' ) +); +``` + +### Using fallback behavior ```php wp_enqueue_style( 'tenup_plugin_admin', @@ -78,7 +112,17 @@ wp_enqueue_style( ``` ## Working with blocks -If you build blocks, pass the block slug used by your build tool: + +### Using prefix-based paths (recommended) +```php +$deps = $this->get_asset_info( 'blocks/my-block', 'dependencies' ); +$ver = $this->get_asset_info( 'blocks/my-block', 'version' ); +$handle = 'tenup_my_block'; + +wp_register_script( $handle, YOUR_PLUGIN_URL . 'dist/blocks/my-block.js', $deps, $ver, true ); +``` + +### Using fallback behavior ```php $deps = $this->get_asset_info( 'my-block', 'dependencies' ); $ver = $this->get_asset_info( 'my-block', 'version' ); @@ -88,6 +132,21 @@ wp_register_script( $handle, YOUR_PLUGIN_URL . 'dist/blocks/my-block.js', $deps, ``` The trait automatically checks `dist/blocks/my-block.asset.php` if present. +## Resolving asset conflicts + +When you have JS and CSS assets with the same handle (e.g., both `admin.js` and `admin.css`), use prefix-based paths to avoid conflicts: + +```php +// ❌ Problematic: Both would load the same asset data +$this->get_asset_info( 'admin', 'dependencies' ); // Could load JS instead of CSS data if both CSS and JS files exist with the same name. + +// ✅ Recommended: Explicitly specify the asset type +$this->get_asset_info( 'js/admin', 'dependencies' ); // Always loads JS asset data +$this->get_asset_info( 'css/admin', 'dependencies' ); // Always loads CSS asset data +``` + +This ensures that each asset type gets its correct dependencies and version information. + ## Error handling and fallbacks ```php try { @@ -105,6 +164,8 @@ try { - Keep your dist path stable across environments (use constants for PATH and URL). - Use the version from `.asset.php` for reliable cache busting in production. - For admin-only assets, enqueue on `admin_enqueue_scripts`; for frontend, use `wp_enqueue_scripts`. +- **Use prefix-based paths** (`'js/admin'`, `'css/admin'`, `'blocks/my-block'`) to avoid conflicts when you have assets with the same handle across different types. +- Prefix-based paths are **backwards compatible** - existing code using fallback behavior will continue to work. ## See also - [Docs Home](README.md) From c92e9ee8ed68f989b12db7adc1beb8c2d892bafe Mon Sep 17 00:00:00 2001 From: James Morrison Date: Thu, 18 Sep 2025 14:20:46 +0100 Subject: [PATCH 3/3] Fix tests; don't use WP filesystem. --- .../assets/dist/blocks/test-block.asset.php | 1 + tests/Assets/GetAssetInfoTest.php | 211 +++++------------- 2 files changed, 63 insertions(+), 149 deletions(-) create mode 100644 fixtures/assets/dist/blocks/test-block.asset.php diff --git a/fixtures/assets/dist/blocks/test-block.asset.php b/fixtures/assets/dist/blocks/test-block.asset.php new file mode 100644 index 0000000..abdc30f --- /dev/null +++ b/fixtures/assets/dist/blocks/test-block.asset.php @@ -0,0 +1 @@ + array( 'test-block-deps' ), 'version' => 'test-block-version'); diff --git a/tests/Assets/GetAssetInfoTest.php b/tests/Assets/GetAssetInfoTest.php index 721b3ae..415772f 100644 --- a/tests/Assets/GetAssetInfoTest.php +++ b/tests/Assets/GetAssetInfoTest.php @@ -141,72 +141,34 @@ public function test_get_asset_info_with_prefix_based_slug() { use GetAssetInfo; }; - // Initialize WP_Filesystem - global $wp_filesystem; - if ( empty( $wp_filesystem ) ) { - require_once ABSPATH . '/wp-admin/includes/file.php'; - WP_Filesystem(); - } - - // Create a temporary test directory structure - $test_dir = get_temp_dir() . 'wp-framework-test-' . uniqid(); - $css_dir = $test_dir . '/css'; - $js_dir = $test_dir . '/js'; - $blocks_dir = $test_dir . '/blocks'; - - // Create directories using WP_Filesystem - $wp_filesystem->mkdir( $test_dir, 0755 ); - $wp_filesystem->mkdir( $css_dir, 0755 ); - $wp_filesystem->mkdir( $js_dir, 0755 ); - $wp_filesystem->mkdir( $blocks_dir, 0755 ); - - // Create asset files - $css_asset = [ - 'version' => '1.0.0', - 'dependencies' => [ 'css-dep' ], - ]; - $css_content = 'put_contents( $css_dir . '/file.asset.php', $css_content ); - - $js_asset = [ - 'version' => '2.0.0', - 'dependencies' => [ 'js-dep' ], - ]; - $js_content = 'put_contents( $js_dir . '/file.asset.php', $js_content ); - - $blocks_asset = [ - 'version' => '3.0.0', - 'dependencies' => [ 'blocks-dep' ], - ]; - $blocks_content = 'put_contents( $blocks_dir . '/file.asset.php', $blocks_content ); - $asset_info->setup_asset_vars( - dist_path: $test_dir, + dist_path: dirname( __DIR__, 2 ) . '/fixtures/assets/dist', fallback_version: '1.0.0' ); - // Test CSS prefix - $asset = $asset_info->get_asset_info( slug: 'css/file' ); - $this->assertEquals( $css_asset, $asset ); - - // Test JS prefix - $asset = $asset_info->get_asset_info( slug: 'js/file' ); - $this->assertEquals( $js_asset, $asset ); - - // Test blocks prefix - $asset = $asset_info->get_asset_info( slug: 'blocks/file' ); - $this->assertEquals( $blocks_asset, $asset ); - - // Clean up using WP_Filesystem - $wp_filesystem->delete( $css_dir . '/file.asset.php' ); - $wp_filesystem->delete( $js_dir . '/file.asset.php' ); - $wp_filesystem->delete( $blocks_dir . '/file.asset.php' ); - $wp_filesystem->rmdir( $css_dir ); - $wp_filesystem->rmdir( $js_dir ); - $wp_filesystem->rmdir( $blocks_dir ); - $wp_filesystem->rmdir( $test_dir ); + // Test CSS prefix with existing fixture + $asset = $asset_info->get_asset_info( slug: 'css/test-style' ); + $this->assertIsArray( $asset ); + $this->assertArrayHasKey( 'version', $asset ); + $this->assertArrayHasKey( 'dependencies', $asset ); + $vars = require dirname( __DIR__, 2 ) . '/fixtures/assets/dist/css/test-style.asset.php'; + $this->assertEquals( $vars, $asset ); + + // Test JS prefix with existing fixture + $asset = $asset_info->get_asset_info( slug: 'js/test-script' ); + $this->assertIsArray( $asset ); + $this->assertArrayHasKey( 'version', $asset ); + $this->assertArrayHasKey( 'dependencies', $asset ); + $vars = require dirname( __DIR__, 2 ) . '/fixtures/assets/dist/js/test-script.asset.php'; + $this->assertEquals( $vars, $asset ); + + // Test blocks prefix with existing fixture + $asset = $asset_info->get_asset_info( slug: 'blocks/test-block' ); + $this->assertIsArray( $asset ); + $this->assertArrayHasKey( 'version', $asset ); + $this->assertArrayHasKey( 'dependencies', $asset ); + $vars = require dirname( __DIR__, 2 ) . '/fixtures/assets/dist/blocks/test-block.asset.php'; + $this->assertEquals( $vars, $asset ); } /** @@ -219,57 +181,26 @@ public function test_get_asset_info_priority_order_prefix_vs_fallback() { use GetAssetInfo; }; - // Initialize WP_Filesystem - global $wp_filesystem; - if ( empty( $wp_filesystem ) ) { - require_once ABSPATH . '/wp-admin/includes/file.php'; - WP_Filesystem(); - } - - // Create a temporary test directory structure - $test_dir = get_temp_dir() . 'wp-framework-test-' . uniqid(); - $css_dir = $test_dir . '/css'; - $js_dir = $test_dir . '/js'; - - // Create directories using WP_Filesystem - $wp_filesystem->mkdir( $test_dir, 0755 ); - $wp_filesystem->mkdir( $css_dir, 0755 ); - $wp_filesystem->mkdir( $js_dir, 0755 ); - - // Create asset files - $css_prefix_asset = [ - 'version' => '2.0.0', - 'dependencies' => [ 'css-prefix-dep' ], - ]; - $css_content = 'put_contents( $css_dir . '/file.asset.php', $css_content ); - - $js_fallback_asset = [ - 'version' => '1.0.0', - 'dependencies' => [ 'js-fallback-dep' ], - ]; - $js_content = 'put_contents( $js_dir . '/file.asset.php', $js_content ); - $asset_info->setup_asset_vars( - dist_path: $test_dir, + dist_path: dirname( __DIR__, 2 ) . '/fixtures/assets/dist', fallback_version: '1.0.0' ); - // Test that prefix-based slug takes priority - $asset = $asset_info->get_asset_info( slug: 'css/file' ); - $this->assertEquals( $css_prefix_asset, $asset ); + // Test that prefix-based slug works with existing fixtures + $asset = $asset_info->get_asset_info( slug: 'css/test-style' ); + $this->assertIsArray( $asset ); + $this->assertArrayHasKey( 'version', $asset ); + $this->assertArrayHasKey( 'dependencies', $asset ); + $vars = require dirname( __DIR__, 2 ) . '/fixtures/assets/dist/css/test-style.asset.php'; + $this->assertEquals( $vars, $asset ); // Test that fallback still works for non-prefixed slugs - $asset = $asset_info->get_asset_info( slug: 'file' ); - $this->assertEquals( $js_fallback_asset, $asset ); - - // Clean up using WP_Filesystem - $wp_filesystem->delete( $css_dir . '/file.asset.php' ); - $wp_filesystem->delete( $js_dir . '/file.asset.php' ); - $wp_filesystem->rmdir( $css_dir ); - $wp_filesystem->rmdir( $js_dir ); - $wp_filesystem->rmdir( $test_dir ); + $asset = $asset_info->get_asset_info( slug: 'test-script' ); + $this->assertIsArray( $asset ); + $this->assertArrayHasKey( 'version', $asset ); + $this->assertArrayHasKey( 'dependencies', $asset ); + $vars = require dirname( __DIR__, 2 ) . '/fixtures/assets/dist/js/test-script.asset.php'; + $this->assertEquals( $vars, $asset ); } /** @@ -282,52 +213,34 @@ public function test_get_asset_info_fallback_when_direct_file_missing() { use GetAssetInfo; }; - // Initialize WP_Filesystem - global $wp_filesystem; - if ( empty( $wp_filesystem ) ) { - require_once ABSPATH . '/wp-admin/includes/file.php'; - WP_Filesystem(); - } - - // Create a temporary test directory structure - $test_dir = get_temp_dir() . 'wp-framework-test-' . uniqid(); - $js_dir = $test_dir . '/js'; - $css_dir = $test_dir . '/css'; - - // Create directories using WP_Filesystem - $wp_filesystem->mkdir( $test_dir, 0755 ); - $wp_filesystem->mkdir( $js_dir, 0755 ); - $wp_filesystem->mkdir( $css_dir, 0755 ); - - // Create asset files in subdirectories only (no direct file) - $js_asset = [ - 'version' => '1.0.0', - 'dependencies' => [ 'js-dep' ], - ]; - $js_content = 'put_contents( $js_dir . '/fallback-asset.asset.php', $js_content ); - - $css_asset = [ - 'version' => '1.5.0', - 'dependencies' => [ 'css-dep' ], - ]; - $css_content = 'put_contents( $css_dir . '/fallback-asset.asset.php', $css_content ); - $asset_info->setup_asset_vars( - dist_path: $test_dir, + dist_path: dirname( __DIR__, 2 ) . '/fixtures/assets/dist', fallback_version: '1.0.0' ); // Test that it falls back to JS directory first (priority order: js -> css -> blocks) - $asset = $asset_info->get_asset_info( slug: 'fallback-asset' ); - $this->assertEquals( $js_asset, $asset ); - - // Clean up using WP_Filesystem - $wp_filesystem->delete( $js_dir . '/fallback-asset.asset.php' ); - $wp_filesystem->delete( $css_dir . '/fallback-asset.asset.php' ); - $wp_filesystem->rmdir( $js_dir ); - $wp_filesystem->rmdir( $css_dir ); - $wp_filesystem->rmdir( $test_dir ); + // Using existing fixture that exists in js/ directory + $asset = $asset_info->get_asset_info( slug: 'test-script' ); + $this->assertIsArray( $asset ); + $this->assertArrayHasKey( 'version', $asset ); + $this->assertArrayHasKey( 'dependencies', $asset ); + $vars = require dirname( __DIR__, 2 ) . '/fixtures/assets/dist/js/test-script.asset.php'; + $this->assertEquals( $vars, $asset ); + + // Test CSS fallback with existing fixture + $asset = $asset_info->get_asset_info( slug: 'test-style' ); + $this->assertIsArray( $asset ); + $this->assertArrayHasKey( 'version', $asset ); + $this->assertArrayHasKey( 'dependencies', $asset ); + $vars = require dirname( __DIR__, 2 ) . '/fixtures/assets/dist/css/test-style.asset.php'; + $this->assertEquals( $vars, $asset ); + + // Test blocks fallback with existing fixture + $asset = $asset_info->get_asset_info( slug: 'test-block' ); + $this->assertIsArray( $asset ); + $this->assertArrayHasKey( 'version', $asset ); + $this->assertArrayHasKey( 'dependencies', $asset ); + $vars = require dirname( __DIR__, 2 ) . '/fixtures/assets/dist/blocks/test-block.asset.php'; + $this->assertEquals( $vars, $asset ); } }