Created
January 25, 2017 10:42
-
-
Save martsie/a3639dd3aadbac4036231aee21c54bdf to your computer and use it in GitHub Desktop.
Example of an abstract Drupal Web Test Case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Common testing class for this Drupal site. | |
*/ | |
abstract class SiteTesting extends DrupalWebTestCase { | |
/** | |
* Overrides default set up handler to prevent database sand-boxing. | |
*/ | |
protected function setUp() { | |
// Use the test mail class instead of the default mail handler class. | |
variable_set('mail_system', array('default-system' => 'TestingMailSystem')); | |
$this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files'); | |
$this->public_files_directory = $this->originalFileDirectory; | |
$this->private_files_directory = variable_get('file_private_path'); | |
$this->temp_files_directory = file_directory_temp(); | |
drupal_set_time_limit($this->timeLimit); | |
$this->setup = TRUE; | |
} | |
/** | |
* Overrides default tear down handler to prevent database sandbox deletion. | |
*/ | |
protected function tearDown() { | |
// In case a fatal error occurred that was not in the test process read the | |
// log to pick up any fatal errors. | |
simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE); | |
$emailCount = count(variable_get('drupal_test_email_collector', array())); | |
if ($emailCount) { | |
$message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.'); | |
$this->pass($message, t('E-mail')); | |
} | |
// Close the CURL handler. | |
$this->curlClose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment