date_views_popup.test 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * @file
  4. * Tests date popup in Views
  5. */
  6. class DateViewsPopupTestCase extends DateFieldBasic {
  7. /**
  8. * Test info.
  9. */
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Date Views - Popup Test',
  13. 'description' => 'Tests date popup in Views',
  14. 'group' => 'Date',
  15. );
  16. }
  17. /**
  18. * Test setup actions.
  19. */
  20. public function setUp() {
  21. parent::setUp();
  22. // Load the 'date_popup', 'date_views', 'views', 'views_ui', 'ctools' modules.
  23. $modules = array('date_popup', 'date_views', 'views', 'views_ui', 'ctools');
  24. $success = module_enable($modules, TRUE);
  25. $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules))));
  26. // Reset/rebuild all data structures after enabling the modules.
  27. $this->resetAll();
  28. // Create a date field.
  29. $field_name = "field_test_date_popup";
  30. $label = 'Test';
  31. $options = array(
  32. 'label' => 'Test',
  33. 'widget_type' => 'date_popup',
  34. 'field_name' => $field_name,
  35. 'field_type' => 'datetime',
  36. 'input_format' => 'm/d/Y - H:i',
  37. );
  38. $this->createDateField($options);
  39. // Set required permissions.
  40. $permissions = array('administer views', 'administer site configuration');
  41. // Create admin user and login.
  42. $admin_user = $this->drupalCreateUser($permissions);
  43. $this->drupalLogin($admin_user);
  44. // Create the view.
  45. $view = new view();
  46. $view->name = 'test_date_popup';
  47. $view->description = '';
  48. $view->tag = 'default';
  49. $view->base_table = 'node';
  50. $view->human_name = 'Test date_popup';
  51. $view->core = 7;
  52. $view->api_version = '3.0';
  53. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  54. /* Display: Master */
  55. $handler = $view->new_display('default', 'Master', 'default');
  56. $handler->display->display_options['title'] = 'test_date_popup_page';
  57. $handler->display->display_options['use_more_always'] = FALSE;
  58. $handler->display->display_options['access']['type'] = 'perm';
  59. $handler->display->display_options['cache']['type'] = 'none';
  60. $handler->display->display_options['query']['type'] = 'views_query';
  61. $handler->display->display_options['exposed_form']['type'] = 'basic';
  62. $handler->display->display_options['pager']['type'] = 'none';
  63. $handler->display->display_options['pager']['options']['offset'] = '0';
  64. $handler->display->display_options['style_plugin'] = 'default';
  65. $handler->display->display_options['row_plugin'] = 'node';
  66. /* Field: Content: Title */
  67. $handler->display->display_options['fields']['title']['id'] = 'title';
  68. $handler->display->display_options['fields']['title']['table'] = 'node';
  69. $handler->display->display_options['fields']['title']['field'] = 'title';
  70. $handler->display->display_options['fields']['title']['label'] = '';
  71. $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
  72. $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
  73. /* Filter criterion: Content: test_date_popup (field_test_date_popup) */
  74. $handler->display->display_options['filters']['field_test_date_popup_value']['id'] = 'field_test_date_popup_value';
  75. $handler->display->display_options['filters']['field_test_date_popup_value']['table'] = 'field_data_field_test_date_popup';
  76. $handler->display->display_options['filters']['field_test_date_popup_value']['field'] = 'field_test_date_popup_value';
  77. $handler->display->display_options['filters']['field_test_date_popup_value']['exposed'] = TRUE;
  78. $handler->display->display_options['filters']['field_test_date_popup_value']['expose']['operator_id'] = 'field_test_date_popup_value_op';
  79. $handler->display->display_options['filters']['field_test_date_popup_value']['expose']['label'] = 'test_date_popup (field_test_date_popup)';
  80. $handler->display->display_options['filters']['field_test_date_popup_value']['expose']['operator'] = 'field_test_date_popup_value_op';
  81. $handler->display->display_options['filters']['field_test_date_popup_value']['expose']['identifier'] = 'field_test_date_popup_value';
  82. $handler->display->display_options['filters']['field_test_date_popup_value']['form_type'] = 'date_popup';
  83. /* Display: Page */
  84. $handler = $view->new_display('page', 'Page', 'page');
  85. $handler->display->display_options['path'] = 'test-date-popup';
  86. $view->save();
  87. }
  88. /**
  89. * Test date popup.
  90. */
  91. public function testDatePopup() {
  92. // Go to view page.
  93. $this->drupalGet('test-date-popup');
  94. }
  95. }