You are here

public function SearchByPageEnvironmentTest::setUp in Search by Page 7

Same name and namespace in other branches
  1. 6 tests/search_by_page.test \SearchByPageEnvironmentTest::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 DrupalWebTestCase::setUp

See also

DrupalWebTestCase::prepareDatabasePrefix()

DrupalWebTestCase::changeDatabasePrefix()

DrupalWebTestCase::prepareEnvironment()

File

tests/search_by_page.test, line 260
Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com

Class

SearchByPageEnvironmentTest
Basic search environments test.

Code

public function setUp() {
  parent::setUp('search', 'search_by_page');
  $this
    ->setUpEnvironments();

  // Verify that environments are created
  $envs = search_by_page_list_environments();
  $this
    ->assertTrue(in_array($this->envid1, $envs), 'Environment 1 created');
  $this
    ->assertTrue(in_array($this->envid2, $envs), 'Environment 2 created');
  $perms = array_keys(search_by_page_permission());
  $this
    ->assertTrue(in_array('search page environment ' . $this->envinfo1['environment_name'], $perms), 'Environment 1 perm created');
  $this
    ->assertTrue(in_array('search page environment ' . $this->envinfo2['environment_name'], $perms), 'Environment 2 perm created');
  $this
    ->assertEqual('search page environment ' . $this->envinfo1['environment_name'], $this
    ->searchPerm($this->envinfo1), 'searchPerm function working');
  $this->superuser = $this
    ->drupalCreateUser(array(
    'administer blocks',
    'access administration pages',
    'administer search',
    'administer search by page',
    'search content',
    $this
      ->searchPerm($this->envinfo1),
    $this
      ->searchPerm($this->envinfo2),
    'administer site configuration',
    'administer permissions',
  ));
  $this->user1 = $this
    ->drupalCreateUser(array(
    'search content',
    $this
      ->searchPerm($this->envinfo1),
  ));
  $this->user2 = $this
    ->drupalCreateUser(array(
    'search content',
    $this
      ->searchPerm($this->envinfo2),
  ));
}