public function SiteDisclaimerWebTestCase::setUp in Site Disclaimer 7
Same name and namespace in other branches
- 6 tests/site_disclaimer.test \SiteDisclaimerWebTestCase::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
- 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', USER_REGISTER_VISITORS);
// Disable clean URLs (on qa.d.o they are disabled!).
//variable_set('clean_url', 0);
$this->admin_user = $this
->drupalCreateUser(array(
'administer site disclaimer',
));
$this
->drupalLogin($this->admin_user);
// A node linked from default Site Disclaimer node.
$this->node1 = $this
->drupalCreateNode(array(
'type' => 'page',
'body' => array(
LANGUAGE_NONE => array(
array(
'value' => $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' => array(
LANGUAGE_NONE => array(
array(
'value' => $this->body,
),
),
),
));
}