-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-timber-comment-thread.php
More file actions
50 lines (39 loc) · 1.71 KB
/
Copy pathtest-timber-comment-thread.php
File metadata and controls
50 lines (39 loc) · 1.71 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
<?php
/**
* @group comments-api
* @group called-post-constructor
*/
class TestTimberCommentThread extends Timber_UnitTestCase {
function testCommentThreadWithArgs() {
$post_id = $this->factory->post->create(array('post_title' => 'Gobbles'));
$comment_id_array = $this->factory->comment->create_many( 5, array('comment_post_ID' => $post_id) );
$args = array();
$ct = new Timber\CommentThread($post_id, $args);
$this->assertEquals( 5, count($ct) );
}
function testCommentThreadCountMethod() {
$post_id = $this->factory->post->create(array('post_title' => 'Gobbles'));
$comment_id_array = $this->factory->comment->create_many( 5, array('comment_post_ID' => $post_id) );
$args = array();
$ct = new Timber\CommentThread($post_id, $args);
$this->assertEquals( 5, $ct->count() );
}
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(array('comment_post_ID' => $post_id, 'comment_content' => $quote,'comment_approved' => 0, 'comment_author_email' => '[email protected]'));
$comment = get_comment($comment_id);
$post = Timber::get_post($post_id);
$this->assertEquals(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->assertEquals(0, count( $post->comments() ));
} else {
$timber_comment = $post->comments()[0];
$this->assertEquals($quote, $timber_comment->comment_content);
}
}
}