You are here

function GlobalRedirectTestCase::setUp in Global Redirect 6

Same name and namespace in other branches
  1. 7 globalredirect.test \GlobalRedirectTestCase::setUp()

Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix. A temporary files directory is created with the same name as the database prefix.

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

File

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

Class

GlobalRedirectTestCase
@file Global Redirect functionality tests

Code

function setUp() {

  // Enable the required modules
  parent::setUp('path', 'globalredirect', 'taxonomy', 'forum');

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

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

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

  // 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_set_alias('node/add/story', 'add-node-story');

  // Create an alias for the admin URL - this is used in the "ignore admin path" test.
  path_set_alias('admin', 'administration');

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

  // Create another test vocab (with a default module) - should be vocab 2?
  $vocab = array(
    'name' => 'test vocab',
    'multiple' => 0,
    'required' => 0,
    'hierarchy' => 0,
    'module' => 'taxonomy',
    'nodes' => array(
      'page',
      'story',
    ),
  );
  taxonomy_save_vocabulary($vocab);
  $vocab = taxonomy_vocabulary_load($vocab['vid'], TRUE);

  // Create a test term - Should be term 2?
  $term = array(
    'vid' => $vocab->vid,
    'name' => 'Test Term',
  );
  taxonomy_save_term($term);
  $term = taxonomy_get_term($term['tid']);
  path_set_alias(taxonomy_term_path($term), 'test-term');
}