Repository navigation
Expand file tree
/
Copy pathnote-reactions-feed-test.php
More file actions
75 lines (66 loc) · 1.86 KB
/
Copy pathnote-reactions-feed-test.php
File metadata and controls
75 lines (66 loc) · 1.86 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* Tests that internal comment types stay out of comment feeds.
*
* @package gutenberg
*/
class Tests_Note_Reactions_Feed extends WP_UnitTestCase {
/**
* Published post the comments are attached to.
*/
private static int $post_id;
/**
* A regular approved comment.
*/
private static int $comment_id;
/**
* A reaction on a note.
*/
private static int $reaction_id;
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
self::$post_id = $factory->post->create( array( 'post_status' => 'publish' ) );
self::$comment_id = $factory->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
)
);
$note_id = $factory->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_type' => 'note',
'comment_approved' => '1',
)
);
self::$reaction_id = $factory->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_parent' => $note_id,
'comment_type' => 'reaction',
'comment_content' => '2764',
'comment_approved' => '1',
)
);
}
/**
* Returns the comment IDs in the current feed query.
*
* @return int[]
*/
private function get_feed_comment_ids() {
global $wp_query;
return array_map( 'intval', wp_list_pluck( $wp_query->comments, 'comment_ID' ) );
}
public function test_site_comment_feed_excludes_reactions() {
$this->go_to( '/?feed=comments-rss2' );
$ids = $this->get_feed_comment_ids();
$this->assertContains( self::$comment_id, $ids );
$this->assertNotContains( self::$reaction_id, $ids );
}
public function test_post_comment_feed_excludes_reactions() {
$this->go_to( '/?feed=rss2&p=' . self::$post_id );
$ids = $this->get_feed_comment_ids();
$this->assertContains( self::$comment_id, $ids );
$this->assertNotContains( self::$reaction_id, $ids );
}
}