diff --git a/phpunit/blocks/render-post-template-test.php b/phpunit/blocks/render-post-template-test.php new file mode 100644 index 0000000000000..13b5623cdd5dd --- /dev/null +++ b/phpunit/blocks/render-post-template-test.php @@ -0,0 +1,73 @@ +post->create_and_get( + array( + 'post_type' => 'post', + 'post_status' => 'publish', + 'post_name' => 'metaldog', + 'post_title' => 'Metal Dog', + 'post_content' => 'Metal Dog content', + 'post_excerpt' => 'Metal Dog', + ) + ); + + self::$other_post = self::factory()->post->create_and_get( + array( + 'post_type' => 'post', + 'post_status' => 'publish', + 'post_name' => 'ceilingcat', + 'post_title' => 'Ceiling Cat', + 'post_content' => 'Ceiling Cat content', + 'post_excerpt' => 'Ceiling Cat', + ) + ); + } + + public function test_rendering_post_template() { + $parsed_blocks = parse_blocks( + '' + ); + $block = new WP_Block( $parsed_blocks[0] ); + $markup = $block->render(); + + $post_id = self::$post->ID; + $other_post_id = self::$other_post->ID; + + $expected = << +
  • +

    Ceiling Cat

    +
    +

    Ceiling Cat

    +
    +
  • +
  • +

    Metal Dog

    +
    +

    Metal Dog

    +
    +
  • + +END; + $this->assertSame( + str_replace( array( "\n", "\t" ), '', $expected ), + str_replace( array( "\n", "\t" ), '', $markup ) + ); + } +}