You are here

public function DatePopupWithViewsTestCase::setUp in Date 7.3

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

Sets up a Drupal site for running functional and integration tests.

Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Parameters

...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.

Overrides DateFieldTestBase::setUp

See also

DrupalWebTestCase::prepareDatabasePrefix()

DrupalWebTestCase::changeDatabasePrefix()

DrupalWebTestCase::prepareEnvironment()

File

date_popup/tests/DateViewsPopupTestCase.test, line 28
Tests Date Popup in the Views interface.

Class

DatePopupWithViewsTestCase
Tests Date Popup in the Views interface.

Code

public function setUp(array $modules = array()) {
  $modules[] = 'date_popup';
  $modules[] = 'date_views';
  $modules[] = 'ctools';
  $modules[] = 'views';
  $modules[] = 'views_ui';
  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;

  /* Edit this to TRUE to make a default view disabled initially */

  /* 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();
}