Skip to content

Commit

Permalink
Add basic test coverage for insert_hooked_blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Nov 28, 2023
1 parent 19ff5d5 commit 0b0f7cb
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/phpunit/tests/blocks/insertHookedBlocks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* Tests for the insert_hooked_blocks function.
*
* @package WordPress
* @subpackage Blocks
*
* @since 6.5.0
*
* @group blocks
* @group block-hooks
*/
class Tests_Blocks_InsertHookedBlocks extends WP_UnitTestCase {
/**
* @covers ::insert_hooked_blocks
*/
public function test_insert_hooked_blocks() {
$anchor_block_name = 'tests/anchor-block';
$anchor_block = array(
'blockName' => $anchor_block_name,
);

// Maybe move to class level and include other relative positions?
// And/or data provider?
$hooked_blocks = array(
$anchor_block_name => array(
'after' => array( 'tests/hooked-before' ),
)

Check failure on line 28 in tests/phpunit/tests/blocks/insertHookedBlocks.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

There should be a comma after the last array item in a multi-line array.
);

$actual = insert_hooked_blocks( $anchor_block, 'after', $hooked_blocks, array() );
$this->assertSame( '<!-- wp:tests/hooked-before /-->', $actual );
}
}

0 comments on commit 0b0f7cb

Please sign in to comment.