summaryrefslogtreecommitdiff
path: root/sites/all/modules/views/tests/handlers/views_handlers.test
blob: f2faee3f769c5538d2c4195f9cc923c3e0d035ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php

/**
 * @file
 * Contains ViewsHandlerTest.
 */

/**
 * Tests generic handler functionality.
 *
 * @see view
 */
class ViewsHandlerTest extends ViewsSqlTest {

  public static function getInfo() {
    return array(
      'name' => 'Handlers',
      'description' => 'Tests generic handler functionality.',
      'group' => 'Views Handlers',
    );
  }

  /**
   * {@inheritdoc}
   */
  protected function viewsData() {
    $views_data = parent::viewsData();
    $views_data['views']['test_access'] = array(
      'title' => 'test access',
      'help' => '',
      'area' => array(
        'handler' => 'views_test_area_access',
      ),
    );

    return $views_data;
  }

  /**
   * Tests access for handlers using an area handler.
   */
  public function testHandlerAccess() {
    $view = $this->getBasicView();

    // add a test area
    $view->display['default']->handler->override_option('header', array(
      'test_access' => array(
        'id' => 'test_access',
        'table' => 'views',
        'field' => 'test_access',
        'custom_access' => FALSE,
      ),
    ));

    $view->init_display();
    $view->init_handlers();
    $handlers = $view->display_handler->get_handlers('header');
    $this->assertEqual(0, count($handlers));

    $view->destroy();

    $view = $this->getBasicView();

    // add a test area
    $view->display['default']->handler->override_option('header', array(
      'test_access' => array(
        'id' => 'test_access',
        'table' => 'views',
        'field' => 'test_access',
        'custom_access' => TRUE,
      ),
    ));

    $view->init_display();
    $view->init_handlers();
    $handlers = $view->display_handler->get_handlers('header');
    $this->assertEqual(1, count($handlers));
    $this->assertTrue(isset($handlers['test_access']));
  }

}