diff --git a/tests/phpunit/tests/blocks/register.php b/tests/phpunit/tests/blocks/register.php index 1a5f2c9ed9c60..29cc97fa2e39e 100644 --- a/tests/phpunit/tests/blocks/register.php +++ b/tests/phpunit/tests/blocks/register.php @@ -260,6 +260,48 @@ public function test_missing_asset_file_register_block_script_handle() { $this->assertFalse( $result ); } + /** + * @expectedIncorrectUsage register_block_script_handle + * @ticket 60233 + */ + public function test_missing_asset_file_register_block_script_module_id() { + $metadata = array( + 'file' => __FILE__, + 'name' => 'unit-tests/test-block', + 'viewScriptModule' => 'file:./blocks/notice/missing-asset.js', + ); + $result = register_block_script_module_id( $metadata, 'viewScriptModule' ); + + $this->assertFalse( $result ); + } + + /** + * @ticket 60233 + */ + public function test_handle_passed_register_block_script_module_id() { + $metadata = array( + 'viewScriptModule' => 'test-id', + ); + $result = register_block_script_module_id( $metadata, 'viewScriptModule' ); + + $this->assertSame( 'test-script-handle', $result ); + } + + /** + * @ticket 60233 + */ + public function test_handles_passed_register_block_script_module_ids() { + $metadata = array( + 'script' => array( 'test-id', 'test-id-1' ), + ); + + $result = register_block_script_handle( $metadata, 'viewScriptModule' ); + $this->assertSame( 'test-id', $result ); + + $result = register_block_script_handle( $metadata, 'viewScriptModule', 1 ); + $this->assertSame( 'test-id-2', $result, 1 ); + } + /** * @ticket 50263 */