You are here

protected function MenuTrailByPathTestCase::setUp in Menu Trail By Path 7.3

Same name and namespace in other branches
  1. 7.2 menu_trail_by_path.test \MenuTrailByPathTestCase::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

./menu_trail_by_path.test, line 42
Tests for menu_trail_by_path module.

Class

MenuTrailByPathTestCase
@file Tests for menu_trail_by_path module.

Code

protected function setUp() {
  parent::setUp(array(
    'menu_trail_by_path',
  ));

  // Create users
  $this->adminUser = $this
    ->drupalCreateUser(array(
    'administer blocks',
    'access administration pages',
  ));
  $this->authenticatedUser = $this
    ->drupalCreateUser();

  // Create nodes
  $node1 = $this
    ->drupalCreateNode();
  $node2 = $this
    ->drupalCreateNode();

  // Create aliases
  $node1_path = array(
    'source' => 'node/' . $node1->nid,
    'alias' => 'news',
  );
  $node2_path = array(
    'source' => 'node/' . $node2->nid,
    'alias' => 'news/category-a',
  );
  path_save($node1_path);
  path_save($node2_path);

  // Set menuUrls
  $this->menuUrls = array(
    'Home' => '<front>',
    'User password' => 'user/password',
    'User login' => 'user/login',
    'User' => 'user',
    'News' => 'node/' . $node1->nid,
    'News » News overview' => 'node/' . $node1->nid,
    'News » Category A' => 'node/' . $node2->nid,
  );

  // Build the main menu.
  $this
    ->buildMenu();
  $this
    ->moveDrupalBlock('system_main-menu', 'header');
}