/** * @test * it should render an empty message if there are no idlikethis comments associated to the post */ public function it_should_render_an_empty_message_if_there_are_no_idlikethis_comments_associated_to_the_post() { $post = $this->factory()->post->create_and_get(); $this->commments_repository->get_votes_for_post($post)->willReturn([]); $this->texts_provider->get_empty_comments_text()->shouldBeCalled(); $this->render_engine->render(Argument::any(), Argument::any())->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_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); }