-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
render-comments-test.php
46 lines (41 loc) · 1.22 KB
/
render-comments-test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* Comments block rendering tests.
*
* @package WordPress
* @subpackage Blocks
*/
/**
* Tests for the Comments block.
*
* @group blocks
*/
class Tests_Blocks_RenderComments extends WP_UnitTestCase {
/**
* @var WP_Post
*/
protected static $post_with_comments_disabled;
public static function wpSetUpBeforeClass() {
$args = array(
'comment_status' => 'closed',
);
self::$post_with_comments_disabled = self::factory()->post->create_and_get( $args );
}
public static function wpTearDownAfterClass() {
wp_delete_post( self::$post_with_comments_disabled->ID, true );
}
/**
* @covers ::render_block_core_comments
*/
public function test_render_block_core_comments_empty_output_if_comments_disabled() {
$attributes = array();
$parsed_blocks = parse_blocks(
'<!-- wp:comments --><div class="wp-block-comments"><!-- wp:comments-title /--></div><!-- /wp:comments -->'
);
$parsed_block = $parsed_blocks[0];
$context = array( 'postId' => self::$post_with_comments_disabled->ID );
$block = new WP_Block( $parsed_block, $context );
$rendered = gutenberg_render_block_core_comments( $attributes, '', $block );
$this->assertEmpty( $rendered );
}
};