renderMoreLink example

$empty = empty($view->result);

    // Force a render array so CSS/JS can be attached.     if (!is_array($element['#rows'])) {
      $element['#rows'] = ['#markup' => $element['#rows']];
    }

    $element['#header'] = $view->display_handler->renderArea('header', $empty);
    $element['#footer'] = $view->display_handler->renderArea('footer', $empty);
    $element['#empty'] = $empty ? $view->display_handler->renderArea('empty', $empty) : [];
    $element['#exposed'] = !empty($view->exposed_widgets) ? $view->exposed_widgets : [];
    $element['#more'] = $view->display_handler->renderMoreLink();
    $element['#feed_icons'] = !empty($view->feedIcons) ? $view->feedIcons : [];

    if ($view->display_handler->renderPager()) {
      $exposed_input = $view->getExposedInput();
      $element['#pager'] = $view->renderPager($exposed_input);
    }

    if (!empty($view->attachment_before)) {
      $element['#attachment_before'] = $view->attachment_before;
    }
    if (!empty($view->attachment_after)) {
      
$output = $view->preview();
    $output = $renderer->renderRoot($output);

    $this->setRawContent($output);
    $result = $this->xpath('//div[@class=:class]/a', [':class' => 'more-link']);
    $this->assertEquals(Url::fromRoute('view.test_display_more.page_1')->toString()$result[0]->attributes()->href, 'The right more link is shown.');
    $this->assertEquals($expected_more_texttrim($result[0][0]), 'The right link text is shown.');

    // Test the renderMoreLink method directly. This could be directly unit     // tested.     $more_link = $view->display_handler->renderMoreLink();
    $more_link = $renderer->renderRoot($more_link);
    $this->setRawContent($more_link);
    $result = $this->xpath('//div[@class=:class]/a', [':class' => 'more-link']);
    $this->assertEquals(Url::fromRoute('view.test_display_more.page_1')->toString()$result[0]->attributes()->href, 'The right more link is shown.');
    $this->assertEquals($expected_more_texttrim($result[0][0]), 'The right link text is shown.');

    // Test the useMoreText method directly. This could be directly unit     // tested.     $more_text = $view->display_handler->useMoreText();
    $this->assertEquals($expected_more_text$more_text, 'The right more text is chosen.');

    
Home | Imprint | This part of the site doesn't use cookies.