/** * @test * it should render the comments count display if there are idlikethis comments associated with * the post */ public function it_should_render_the_comments_count_display_if_there_are_idlikethis_comments_associated_with_the_post() { $post = $this->factory()->post->create_and_get(); $comments = $this->factory()->comment->create_many(10); $this->commments_repository->get_votes_for_post($post)->willReturn(['first idea' => array_splice($comments, 0, 5), 'second idea' => $comments]); $this->texts_provider->get_comments_title_text()->shouldBeCalled(); $this->render_engine->render(Argument::any(), Argument::any())->shouldBeCalled(); $sut = $this->make_instance(); $sut->render($post, []); }
/** * @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, []); }
/** * 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); }
/** * 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_data['header_text'] = $this->texts->get_comments_title_text(); array_walk($comments, array($this, 'count_comments')); arsort($comments); $this->template_data['rows'] = $comments; } echo $this->render_engine->render($this->template_slug, $this->template_data); }