Ejemplo n.º 1
0
 public function comments()
 {
     if (!$this->comments) {
         $this->comments = $this->post->comments();
     }
     return $this->comments;
 }
Ejemplo n.º 2
0
 function testComments()
 {
     $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));
     $post = new TimberPost($post_id);
     $this->assertEquals(5, count($post->comments()));
     $this->assertEquals(5, $post->get_comment_count());
 }
Ejemplo n.º 3
0
 function testShowUnmoderatedCommentIfByCurrentUser()
 {
     $post_id = $this->factory->post->create();
     add_filter('wp_get_current_commenter', function ($author_data) {
         $author_data['comment_author_email'] = '*****@*****.**';
         return $author_data;
     });
     $commenter = wp_get_current_commenter();
     $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' => '*****@*****.**'));
     $post = new TimberPost($post_id);
     $this->assertEquals(1, count($post->comments()));
 }