diff --git a/tests/parser/test-content-parser.php b/tests/parser/test-content-parser.php index a5b90d0..d11b65e 100644 --- a/tests/parser/test-content-parser.php +++ b/tests/parser/test-content-parser.php @@ -103,4 +103,63 @@ public function test_parse_multiple_blocks() { $this->assertArrayHasKey( 'blocks', $blocks, sprintf( 'Unexpected parser output: %s', wp_json_encode( $blocks ) ) ); $this->assertArraySubset( $expected_blocks, $blocks['blocks'], true ); } + + /* Default values and missing values */ + + public function test_parse_block_missing_attributes_and_defaults() { + $this->register_block_with_attributes( 'test/block-with-empty-attributes', [ + 'attributeOneWithDefaultValueAndSource' => [ + 'type' => 'string', + 'source' => 'attribute', + 'selector' => 'div', + 'attribute' => 'data-attr-one', + 'default' => 'Default Attribute 1 Value', + ], + 'attributeTwoWithDefaultValueAndNoSource' => [ + 'type' => 'string', + 'source' => 'attribute', + 'selector' => 'div', + 'attribute' => 'data-attr-two', + 'default' => 'Default Attribute 2 Value', + ], + 'attributeThreeWithNoDefaultValueAndSource' => [ + 'type' => 'string', + 'source' => 'attribute', + 'selector' => 'div', + 'attribute' => 'data-attr-three', + ], + 'attributeFourWithNoDefaultValueAndNoSource' => [ + 'type' => 'string', + 'source' => 'attribute', + 'selector' => 'div', + 'attribute' => 'data-attr-four', + ], + ] ); + + $html = ' + +