You are here

public function BEF_TestBase::setUp in Better Exposed Filters 7.3

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 DrupalWebTestCase::setUp

See also

DrupalWebTestCase::prepareDatabasePrefix()

DrupalWebTestCase::changeDatabasePrefix()

DrupalWebTestCase::prepareEnvironment()

File

tests/better_exposed_filters_TestBase.php, line 32
Base class for testing the Better Exposed Filters module. @author mikeker

Class

BEF_TestBase
Helper functions for Better Exposed Filters tests.

Code

public function setUp() {

  // For benchmarking.
  $this->start = time();

  // Enable any modules required for the test.
  parent::setUp('better_exposed_filters', 'date', 'date_views', 'list', 'number', 'taxonomy', 'text', 'views', 'views_ui');

  // One of these days I'll figure out why Features is breaking all my tests.
  module_enable(array(
    'bef_test_content',
  ));

  // User with edit views perms.
  $this->admin_user = $this
    ->drupalCreateUser();
  $role = user_role_load_by_name('administrator');
  $this
    ->assertTrue(!empty($role->rid), 'Found the "administrator" role.');
  user_save($this->admin_user, array(
    'roles' => array(
      $role->rid => $role->rid,
    ),
  ));
  $this
    ->drupalLogin($this->admin_user);

  // Build a basic view for use in tests.
  $this
    ->createView();

  // $this->createDisplay('Page', array('path' => array('path' => 'bef_test_page')));
  // Add field to default display
  // $this->addField('node.title');
  // Turn of Better Exposed Filters.
  $this
    ->setBefExposedForm();
}