You are here

function GlobalRedirectTestCase::setUp in Global Redirect 7

Same name and namespace in other branches
  1. 6 globalredirect.test \GlobalRedirectTestCase::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()

1 call to GlobalRedirectTestCase::setUp()
GlobalRedirectTestCaseConfigLanguages::setUp in ./globalredirect.test
Sets up a Drupal site for running functional and integration tests.
1 method overrides GlobalRedirectTestCase::setUp()
GlobalRedirectTestCaseConfigLanguages::setUp in ./globalredirect.test
Sets up a Drupal site for running functional and integration tests.

File

./globalredirect.test, line 19
Global Redirect functionality tests

Class

GlobalRedirectTestCase
@file Global Redirect functionality tests

Code

function setUp(array $modules = array()) {
  $modules[] = 'path';
  $modules[] = 'globalredirect';
  $modules[] = 'taxonomy';
  $modules[] = 'forum';
  parent::setUp($modules);

  // Clean URLs should be enabled for testing.
  variable_set('clean_url', 1);

  // Create a user
  $this->normal_user = $this
    ->drupalCreateUser(array(
    'access content',
    'create page content',
    'create url aliases',
    'access administration pages',
  ));
  $this
    ->drupalLogin($this->normal_user);

  // Create a dummy node
  $node = array(
    'type' => 'page',
    'title' => 'Test Page Node',
    'path' => array(
      'alias' => 'test-node',
    ),
    'language' => LANGUAGE_NONE,
  );

  // Save the node
  $node = $this
    ->drupalCreateNode($node);

  // Create an alias for the create story path - this is used in the "redirect with permissions testing" test.
  $path = array(
    'source' => 'node/add/article',
    'alias' => 'node-add-article',
  );
  path_save($path);

  // Create an alias for the admin URL - this is used in the "ignore admin path" test.
  $path = array(
    'source' => 'admin',
    'alias' => 'administration',
  );
  path_save($path);

  // The forum vocab should already be created - should be term 1?
  $forum_term = (object) array(
    'vid' => variable_get('forum_nav_vocabulary', 0),
    'name' => 'Test Forum Term',
  );
  taxonomy_term_save($forum_term);
  $this->gr_forum_term = taxonomy_term_load($forum_term->tid);

  // Create another test vocab (with a default module) - should be vocab 2?
  $vocab = (object) array(
    'name' => 'test vocab',
    'machine_name' => 'test-vocab',
    'hierarchy' => 0,
    'module' => 'taxonomy',
  );
  taxonomy_vocabulary_save($vocab);
  $vocab = taxonomy_vocabulary_load($vocab->vid, TRUE);

  // Create a test term - Should be term 2?
  $term = (object) array(
    'vid' => $vocab->vid,
    'name' => 'Test Term',
    'path' => array(
      'alias' => 'test-term',
    ),
  );
  taxonomy_term_save($term);
  $this->gr_term = taxonomy_term_load($term->tid);
}