summaryrefslogtreecommitdiff
path: root/modules/simpletest/drupal_web_test_case.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest/drupal_web_test_case.php')
-rw-r--r--modules/simpletest/drupal_web_test_case.php44
1 files changed, 43 insertions, 1 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index 8f03bd5fc..302a2e86f 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -138,6 +138,39 @@ abstract class DrupalTestCase {
}
/**
+ * Make assertions from outside the test case.
+ *
+ * @see DrupalTestCase::assert()
+ */
+ public static function assertStatic($test_id, $test_class, $status, $message = '', $group = 'Other', array $caller = NULL) {
+ // Convert boolean status to string status.
+ if (is_bool($status)) {
+ $status = $status ? 'pass' : 'fail';
+ }
+
+ $caller += array(
+ 'function' => t('N/A'),
+ 'line' => -1,
+ 'file' => t('N/A'),
+ );
+
+ $assertion = array(
+ 'test_id' => $test_id,
+ 'test_class' => $test_class,
+ 'status' => $status,
+ 'message' => $message,
+ 'message_group' => $group,
+ 'function' => $caller['function'],
+ 'line' => $caller['line'],
+ 'file' => $caller['file'],
+ );
+
+ db_insert('simpletest')
+ ->fields($assertion)
+ ->execute();
+ }
+
+ /**
* Cycles through backtrace until the first non-assertion method is found.
*
* @return
@@ -981,7 +1014,12 @@ class DrupalWebTestCase extends DrupalTestCase {
$clean_url_original = variable_get('clean_url', 0);
// Generate temporary prefixed database to ensure that tests have a clean starting point.
- $db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
+ $db_prefix_new = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
+ db_update('simpletest_test_id')
+ ->fields(array('last_prefix' => $db_prefix_new))
+ ->condition('test_id', $this->testId)
+ ->execute();
+ $db_prefix = $db_prefix_new;
include_once DRUPAL_ROOT . '/includes/install.inc';
drupal_install_system();
@@ -1043,6 +1081,10 @@ class DrupalWebTestCase extends DrupalTestCase {
// Create the files directory.
file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+ // Log fatal errors.
+ ini_set('log_errors', 1);
+ ini_set('error_log', $directory . '/error.log');
+
set_time_limit($this->timeLimit);
}