views_handlers.test 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * @file
  4. * Definition of ViewsHandlerTest.
  5. */
  6. /**
  7. * Tests generic handler functionality.
  8. *
  9. * @see view
  10. */
  11. class ViewsHandlerTest extends ViewsSqlTest {
  12. public static function getInfo() {
  13. return array(
  14. 'name' => 'Handlers',
  15. 'description' => 'Tests generic handler functionality.',
  16. 'group' => 'Views Handlers',
  17. );
  18. }
  19. /**
  20. * {@inheritdoc}
  21. */
  22. protected function viewsData() {
  23. $views_data = parent::viewsData();
  24. $views_data['views']['test_access'] = array(
  25. 'title' => 'test access',
  26. 'help' => '',
  27. 'area' => array(
  28. 'handler' => 'views_test_area_access',
  29. ),
  30. );
  31. return $views_data;
  32. }
  33. /**
  34. * Tests access for handlers using an area handler.
  35. */
  36. public function testHandlerAccess() {
  37. $view = $this->getBasicView();
  38. // add a test area.
  39. $view->display['default']->handler->override_option('header', array(
  40. 'test_access' => array(
  41. 'id' => 'test_access',
  42. 'table' => 'views',
  43. 'field' => 'test_access',
  44. 'custom_access' => FALSE,
  45. ),
  46. ));
  47. $view->init_display();
  48. $view->init_handlers();
  49. $handlers = $view->display_handler->get_handlers('header');
  50. $this->assertEqual(0, count($handlers));
  51. $view->destroy();
  52. $view = $this->getBasicView();
  53. // add a test area.
  54. $view->display['default']->handler->override_option('header', array(
  55. 'test_access' => array(
  56. 'id' => 'test_access',
  57. 'table' => 'views',
  58. 'field' => 'test_access',
  59. 'custom_access' => TRUE,
  60. ),
  61. ));
  62. $view->init_display();
  63. $view->init_handlers();
  64. $handlers = $view->display_handler->get_handlers('header');
  65. $this->assertEqual(1, count($handlers));
  66. $this->assertTrue(isset($handlers['test_access']));
  67. }
  68. }