forked from timber/timber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-timber-comment-thread.php
63 lines (56 loc) · 1.98 KB
/
test-timber-comment-thread.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* @group comments-api
* @group called-post-constructor
*/
class TestTimberCommentThread extends Timber_UnitTestCase
{
public function testCommentThreadWithArgs()
{
$post_id = $this->factory->post->create([
'post_title' => 'Gobbles',
]);
$comment_id_array = $this->factory->comment->create_many(5, [
'comment_post_ID' => $post_id,
]);
$args = [];
$ct = new Timber\CommentThread($post_id, $args);
$this->assertSame(5, count($ct));
}
public function testCommentThreadCountMethod()
{
$post_id = $this->factory->post->create([
'post_title' => 'Gobbles',
]);
$comment_id_array = $this->factory->comment->create_many(5, [
'comment_post_ID' => $post_id,
]);
$args = [];
$ct = new Timber\CommentThread($post_id, $args);
$this->assertSame(5, $ct->count());
}
public function testShowUnmoderatedCommentIfByAnon()
{
global $wp_version;
$post_id = $this->factory->post->create();
$quote = "And in that moment, I was a marine biologist";
$comment_id = $this->factory->comment->create([
'comment_post_ID' => $post_id,
'comment_content' => $quote,
'comment_approved' => 0,
'comment_author_email' => 'jarednova@upstatement.com',
]);
$comment = get_comment($comment_id);
$post = Timber::get_post($post_id);
$this->assertSame(0, count($post->comments()));
$_GET['unapproved'] = $comment->comment_ID;
$_GET['moderation-hash'] = wp_hash($comment->comment_date_gmt);
$post = Timber::get_post($post_id);
if (!function_exists('wp_get_unapproved_comment_author_email')) {
$this->assertSame(0, count($post->comments()));
} else {
$timber_comment = $post->comments()[0];
$this->assertEquals($quote, $timber_comment->comment_content);
}
}
}