public function HoneypotFormTestCase::setUp in Honeypot 7
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
- ./
honeypot.test, line 24 - Testing for Honeypot module.
Class
- HoneypotFormTestCase
- Test the functionality of the Honeypot module for forms.
Code
public function setUp() {
// Enable modules required for this test.
parent::setUp(array(
'honeypot',
'comment',
'honeypot_test',
));
// Set up required Honeypot variables.
variable_set('honeypot_element_name', 'url');
// Disable time_limit protection.
variable_set('honeypot_time_limit', 0);
// Test protecting all forms.
variable_set('honeypot_protect_all_forms', TRUE);
variable_set('honeypot_log', FALSE);
// Set up other required variables.
variable_set('user_email_verification', TRUE);
variable_set('user_register', USER_REGISTER_VISITORS);
// Set up admin user.
$this->adminUser = $this
->drupalCreateUser(array(
'administer honeypot',
'bypass honeypot protection',
'administer content types',
'administer users',
'access comments',
'post comments',
'skip comment approval',
'administer comments',
));
// Set up web user.
$this->webUser = $this
->drupalCreateUser(array(
'access comments',
'post comments',
'create article content',
));
// Set up example node.
$this->node = $this
->drupalCreateNode(array(
'type' => 'article',
'promote' => 1,
'uid' => $this->webUser->uid,
));
}