Skip to content

Commit

Permalink
docs : Added doc blocks for test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ta5r authored and justlevine committed Sep 17, 2024
1 parent 1e51565 commit 09f83cc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/unit/ContentBlocksResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ static function ( $parsed_block ) {
$this->assertEquals( $allowed, $actual_block_names );
}

/**
* Test the wpgraphql_content_blocks_pre_resolve_blocks filter.
*/
public function test_pre_resolved_blocks_filter_returns_non_null() {
add_filter(
'wpgraphql_content_blocks_pre_resolve_blocks',
Expand All @@ -159,8 +162,12 @@ static function ( $blocks, $node, $args, $allowed_block_names ) {
// The filter should return a block.
$this->assertCount( 1, $resolved_blocks );
$this->assertEquals( 'core/paragraph', $resolved_blocks[0]['blockName'] );
$this->assertEquals( 'Test content', $resolved_blocks[0]['attrs']['content'] );
}

/**
* Tests content retrieval from a post node.
*/
public function test_content_retrieved_from_post_node() {
$post_id = self::factory()->post->create(
[
Expand All @@ -175,6 +182,9 @@ public function test_content_retrieved_from_post_node() {
$this->assertEquals( 'core/paragraph', $resolved_blocks[0]['blockName'] );
}

/**
* Tests that an empty array is returned when the post content is empty.
*/
public function test_returns_empty_array_for_empty_content() {
$post_id = self::factory()->post->create( [ 'post_content' => '' ] );
$post = new Post( get_post( $post_id ) );
Expand All @@ -186,6 +196,9 @@ public function test_returns_empty_array_for_empty_content() {
$this->assertEmpty( $resolved_blocks );
}

/**
* Tests that the wpgraphql_content_blocks_allowed_blocks filter is applied.
*/
public function test_filters_allowed_blocks() {
$post_id = self::factory()->post->create(
[
Expand All @@ -201,6 +214,9 @@ public function test_filters_allowed_blocks() {
$this->assertEquals( 'core/paragraph', $resolved_blocks[0]['blockName'] );
}

/**
* Tests that the wpgraphql_content_blocks_resolve_blocks filter is applied.
*/
public function test_filters_after_resolving_blocks() {
add_filter(
'wpgraphql_content_blocks_resolve_blocks',
Expand Down

0 comments on commit 09f83cc

Please sign in to comment.