You are here

public function DatePopupWithViewsTestCase::setUp in Date 7.2

Same name in this branch
  1. 7.2 date_popup/tests/DateViewsPopupTestCase.test \DatePopupWithViewsTestCase::setUp()
  2. 7.2 date_popup/tests/DatePopupWithViewsTestCase.test \DatePopupWithViewsTestCase::setUp()
Same name and namespace in other branches
  1. 7.3 date_popup/tests/DateViewsPopupTestCase.test \DatePopupWithViewsTestCase::setUp()
  2. 7.3 date_popup/tests/DatePopupWithViewsTestCase.test \DatePopupWithViewsTestCase::setUp()

Test setup actions.

Overrides DateFieldTestBase::setUp

File

date_popup/tests/DatePopupWithViewsTestCase.test, line 27
Tests date popup in Views.

Class

DatePopupWithViewsTestCase
Tests date popup in Views.

Code

public function setUp(array $modules = array()) {
  $modules[] = 'views';
  $modules[] = 'views_ui';
  $modules[] = 'date_views';
  $modules[] = 'date_popup';
  parent::setUp($modules);

  // Reset/rebuild all data structures after enabling the modules.
  $this
    ->resetAll();

  // Create a date field.
  $field_name = "field_test_date_popup";
  $label = 'Test';
  $options = array(
    'label' => 'Test',
    'widget_type' => 'date_popup',
    'field_name' => $field_name,
    'field_type' => 'datetime',
    'input_format' => 'm/d/Y - H:i',
  );
  $this
    ->createDateField($options);

  // Set required permissions.
  $permissions = array(
    'administer views',
    'administer site configuration',
  );

  // Create admin user and login.
  $admin_user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($admin_user);

  // Create the view.
  $view = new view();
  $view->name = 'test_date_popup';
  $view->description = '';
  $view->tag = 'default';
  $view->base_table = 'node';
  $view->human_name = 'Test date_popup';
  $view->core = 7;
  $view->api_version = '3.0';
  $view->disabled = FALSE;

  /* Display: Master */
  $handler = $view
    ->new_display('default', 'Master', 'default');
  $handler->display->display_options['title'] = 'test_date_popup_page';
  $handler->display->display_options['use_more_always'] = FALSE;
  $handler->display->display_options['access']['type'] = 'perm';
  $handler->display->display_options['cache']['type'] = 'none';
  $handler->display->display_options['query']['type'] = 'views_query';
  $handler->display->display_options['exposed_form']['type'] = 'basic';
  $handler->display->display_options['pager']['type'] = 'none';
  $handler->display->display_options['pager']['options']['offset'] = '0';
  $handler->display->display_options['style_plugin'] = 'default';
  $handler->display->display_options['row_plugin'] = 'node';

  /* Field: Content: Title */
  $handler->display->display_options['fields']['title']['id'] = 'title';
  $handler->display->display_options['fields']['title']['table'] = 'node';
  $handler->display->display_options['fields']['title']['field'] = 'title';
  $handler->display->display_options['fields']['title']['label'] = '';
  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;

  /* Filter criterion: Content: test_date_popup (field_test_date_popup) */
  $handler->display->display_options['filters']['field_test_date_popup_value']['id'] = 'field_test_date_popup_value';
  $handler->display->display_options['filters']['field_test_date_popup_value']['table'] = 'field_data_field_test_date_popup';
  $handler->display->display_options['filters']['field_test_date_popup_value']['field'] = 'field_test_date_popup_value';
  $handler->display->display_options['filters']['field_test_date_popup_value']['exposed'] = TRUE;
  $handler->display->display_options['filters']['field_test_date_popup_value']['expose']['operator_id'] = 'field_test_date_popup_value_op';
  $handler->display->display_options['filters']['field_test_date_popup_value']['expose']['label'] = 'test_date_popup (field_test_date_popup)';
  $handler->display->display_options['filters']['field_test_date_popup_value']['expose']['operator'] = 'field_test_date_popup_value_op';
  $handler->display->display_options['filters']['field_test_date_popup_value']['expose']['identifier'] = 'field_test_date_popup_value';
  $handler->display->display_options['filters']['field_test_date_popup_value']['form_type'] = 'date_popup';

  /* Display: Page */
  $handler = $view
    ->new_display('page', 'Page', 'page');
  $handler->display->display_options['path'] = 'test-date-popup';
  $view
    ->save();
}