You are here

public function TaxonomyAccessConfigTest::setUp in Taxonomy Access Control 7

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

See also

DrupalWebTestCase::prepareDatabasePrefix()

DrupalWebTestCase::changeDatabasePrefix()

DrupalWebTestCase::prepareEnvironment()

File

./taxonomy_access.test, line 437
Automated tests for the Taxonomy Access Control module.

Class

TaxonomyAccessConfigTest
Tests the module's configuration forms.

Code

public function setUp() {
  parent::setUp();

  // Add two taxonomy fields to pages.
  foreach (array(
    'v1',
    'v2',
  ) as $vocab) {
    $this->vocabs[$vocab] = $this
      ->createVocab($vocab);
    $this
      ->createField($vocab);
    $this->terms[$vocab . 't1'] = $this
      ->createTerm($vocab . 't1', $this->vocabs[$vocab]);
    $this->terms[$vocab . 't2'] = $this
      ->createTerm($vocab . 't2', $this->vocabs[$vocab]);
  }

  // Set up a variety of nodes with different term combinations.
  $this->articles['no_tags'] = $this
    ->createArticle();
  $this->articles['one_tag'] = $this
    ->createArticle(array(
    $this
      ->randomName(),
  ));
  $this->articles['two_tags'] = $this
    ->createArticle(array(
    $this
      ->randomName(),
    $this
      ->randomName(),
  ));
  $this->pages['no_tags'] = $this
    ->createPage();
  foreach ($this->terms as $t1) {
    $this->pages[$t1->name] = $this
      ->createPage(array(
      $t1->name,
    ));
    foreach ($this->terms as $t2) {
      $this->pages[$t1->name . '_' . $t2->name] = $this
        ->createPage(array(
        $t1->name,
        $t2->name,
      ));
    }
  }
}