/**
  * @test
  * it should show the consolidate all comments control if there are idlikethis comments associated to the post
  */
 public function it_should_show_the_consolidate_all_comments_control_if_there_are_idlikethis_comments_associated_to_the_post()
 {
     $post = $this->factory()->post->create_and_get();
     $comments_ids = $this->factory()->comment->create_many(3, ['comment_post_ID' => $post->ID, 'comment_type' => 'idlikethis']);
     $this->comments_repository->get_votes_for_post($post)->willReturn(['some idea' => $comments_ids]);
     $this->context->get_post_id()->willReturn($post->ID);
     $this->texts_provider->get_comments_title_text()->shouldBeCalled();
     $this->texts_provider->get_reset_all_text()->willReturn('foo');
     $this->texts_provider->get_consolidate_all_text()->shouldBeCalled();
     $sut = $this->make_instance();
     $sut->render($post, []);
 }
Esempio n. 2
0
 /**
  * Echoes the meta box markup to the page.
  *
  * @param string|WP_Post|array $object
  * @param array|mixed $box The meta box registration description.
  * @return void
  */
 public function render($object, $box)
 {
     $comments = $this->comments_repository->get_votes_for_post($object);
     if (empty($comments)) {
         $this->template_data['has_comments'] = false;
         $this->template_data['header_text'] = $this->texts->get_empty_comments_text();
     } else {
         $this->template_data['has_comments'] = true;
         $this->template_date['header_text'] = $this->texts->get_comments_title_text();
         $this->template_data['reset_all_text'] = $this->texts->get_reset_all_text();
         $this->template_data['consolidate_all_text'] = $this->texts->get_consolidate_all_text();
         $this->template_data['post_id'] = $this->context->get_post_id();
     }
     echo $this->render_engine->render($this->template_slug, $this->template_data);
 }