You are here

public function AreaTest::testRenderArea in Views (for Drupal 7) 8.3

Tests the rendering of an area.

File

lib/Drupal/views/Tests/Handler/AreaTest.php, line 87
Definition of Drupal\views\Tests\Handler\AreaTest.

Class

AreaTest
Tests the abstract area handler.

Namespace

Drupal\views\Tests\Handler

Code

public function testRenderArea() {
  $view = views_get_view('test_example_area');
  $view
    ->initHandlers();

  // Insert a random string to the test area plugin and see whether it is
  // rendered for both header, footer and empty text.
  $header_string = $this
    ->randomString();
  $footer_string = $this
    ->randomString();
  $empty_string = $this
    ->randomString();
  $view->header['test_example']->options['string'] = $header_string;
  $view->header['test_example']->options['empty'] = TRUE;
  $view->footer['test_example']->options['string'] = $footer_string;
  $view->footer['test_example']->options['empty'] = TRUE;
  $view->empty['test_example']->options['string'] = $empty_string;

  // Check whether the strings exists in the output.
  $output = $view
    ->preview();
  $this
    ->assertTrue(strpos($output, $header_string) !== FALSE);
  $this
    ->assertTrue(strpos($output, $footer_string) !== FALSE);
  $this
    ->assertTrue(strpos($output, $empty_string) !== FALSE);
}