You are here

public function SiteDisclaimerWebTestCase::setUp in Site Disclaimer 6

Same name and namespace in other branches
  1. 7 tests/site_disclaimer.test \SiteDisclaimerWebTestCase::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

tests/site_disclaimer.test, line 26
Site Disclaimer module functionality tests.

Class

SiteDisclaimerWebTestCase
Base class for all terms od use web test cases.

Code

public function setUp() {

  // String for XSS Test.
  $this->label = $this
    ->testXssString();
  $this->label_link = $this
    ->testXssString() . ' @link ' . $this
    ->testXssString();
  $this->title = $this
    ->testXssString();
  $this->body1 = $this
    ->randomName();

  // Enable the Site Disclaimer module.
  parent::setUp('site_disclaimer');

  // Don't require e-mail verification.
  variable_set('user_email_verification', FALSE);

  // Allow registration by site visitors without administrator approval.
  variable_set('user_register', 1);

  // Disable clean URLs (on qa.d.o they are disabled!).

  //variable_set('clean_url', 0);
  $this->admin_user = $this
    ->drupalCreateUser(array(
    'administer site configuration',
  ));
  $this
    ->drupalLogin($this->admin_user);

  // A node linked from default Site Disclaimer node.
  $this->node1 = $this
    ->drupalCreateNode(array(
    'type' => 'page',
    'body' => $this->body1,
  ));

  // A label linking to node1 by title
  $this->label_link_titles = $this
    ->testXssString() . ' @"' . $this->node1->title . '" ';

  // Default Site Disclaimer node (contains a link to node1)
  // We are using 'absolute' => TRUE to avoid Drupal problems in dealing with
  // content links when installation is in webserver's subdirectory, i.e. http://example.com/drupal/...
  $this->body = $this
    ->randomName() . ' ' . l($this->node1->title, 'node/' . $this->node1->nid, array(
    'absolute' => TRUE,
  )) . ' ' . $this
    ->randomName();
  $this->node = $this
    ->drupalCreateNode(array(
    'type' => 'page',
    'body' => $this->body,
  ));
}