Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add block binding support #74

Merged
merged 20 commits into from
Aug 30, 2024
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test for missing block binding
chriszarate committed Aug 25, 2024

Verified

This commit was signed with the committer’s verified signature.
chriszarate Chris Zarate
commit a0106c971c076167d9e52fe526a2d46ffa9395c4
26 changes: 26 additions & 0 deletions tests/parser/test-block-bindings.php
Original file line number Diff line number Diff line change
@@ -198,4 +198,30 @@ public function test_nested_paragraph_block_binding_with_custom_context() {
$this->assertArrayHasKey( 'blocks', $blocks, sprintf( 'Unexpected parser output: %s', wp_json_encode( $blocks ) ) );
$this->assertArraySubset( $expected_blocks, $blocks['blocks'], false, wp_json_encode( $blocks['blocks'] ) );
}

/* Missing block binding */

public function test_missing_block_binding() {

$html = '
<!-- wp:core/paragraph {"metadata":{"bindings":{"content":{"source":"test/missing-block-binding","args":{"foo":"bar"}}}}} -->
<p>Fallback content</p>
<!-- /wp:core/paragraph -->
';

$expected_blocks = [
[
'name' => 'core/paragraph',
'attributes' => [
'content' => 'Fallback content',
],
],
];

$content_parser = new ContentParser( $this->get_block_registry() );
$blocks = $content_parser->parse( $html );

$this->assertArrayHasKey( 'blocks', $blocks, sprintf( 'Unexpected parser output: %s', wp_json_encode( $blocks ) ) );
$this->assertArraySubset( $expected_blocks, $blocks['blocks'], false, wp_json_encode( $blocks['blocks'] ) );
}
}