public function AreaTest::testRenderArea

Tests the rendering of an area.

File

drupal/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTest.php, line 94
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);
}