You are here

public function DisplayExtenderTest::testDisplayExtenders in Views (for Drupal 7) 8.3

Test display extenders.

File

lib/Drupal/views/Tests/Plugin/DisplayExtenderTest.php, line 37
Definition of Drupal\views\Tests\Plugin\DisplayExtenderTest.

Class

DisplayExtenderTest
Tests the display extender plugins.

Namespace

Drupal\views\Tests\Plugin

Code

public function testDisplayExtenders() {
  config('views.settings')
    ->set('display_extenders', array(
    'display_extender_test',
  ))
    ->save();
  $this
    ->assertEqual(count(views_get_enabled_display_extenders()), 1, 'Make sure that there is only one enabled display extender.');
  $view = $this
    ->getBasicView();
  $view
    ->initDisplay();
  $this
    ->assertEqual(count($view->display_handler->extender), 1, 'Make sure that only one extender is initialized.');
  $display_extender = $view->display_handler->extender['display_extender_test'];
  $this
    ->assertTrue($display_extender instanceof \Drupal\views_test_data\Plugin\views\display_extender\DisplayExtenderTest, 'Make sure the right class got initialized.');
  $view
    ->preExecute();
  $this
    ->assertTrue($display_extender->testState['pre_execute'], 'Make sure the display extender was able to react on preExecute.');
  $view
    ->execute();
  $this
    ->assertTrue($display_extender->testState['query'], 'Make sure the display extender was able to react on query.');
}