DisplayExtenderTest.php 1.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php

  /**
   * @file
   * Definition of Drupal\views\Tests\Plugin\DisplayExtenderTest.
   */

namespace Drupal\views\Tests\Plugin;

use Drupal\views\Tests\Plugin\PluginTestBase;

/**
 * Tests the display extender plugins.
 *
 * @see Drupal\views_test_data\Plugin\views\display_extender\DisplayExtenderTest
 */
class DisplayExtenderTest extends PluginTestBase {

19
20
21
22
23
24
25
  /**
   * Views used by this test.
   *
   * @var array
   */
  public static $testViews = array('test_view');

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  public static function getInfo() {
    return array(
      'name' => 'Display extender',
      'description' => 'Tests the display extender plugins.',
      'group' => 'Views Plugins',
    );
  }

  protected function setUp() {
    parent::setUp();

    $this->enableViewsTestModule();
  }

  /**
   * Test display extenders.
   */
  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.');

47
    $view = views_get_view('test_view');
48
49
50
51
52
53
54
55
    $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();
56
    $this->assertTrue($display_extender->testState['preExecute'], 'Make sure the display extender was able to react on preExecute.');
57
58
59
    $view->execute();
    $this->assertTrue($display_extender->testState['query'], 'Make sure the display extender was able to react on query.');
  }
60

61
}