public static function DrupalTestCase::insertAssert
7.x drupal_web_test_case.php | public static DrupalTestCase::insertAssert($test_id, $test_class, $status, $message = '', $group = 'Other', array $caller = array()) |
Store an assertion from outside the testing context.
This is useful for inserting assertions that can only be recorded after the test case has been destroyed, such as PHP fatal errors. The caller information is not automatically gathered since the caller is most likely inserting the assertion on behalf of other code. In all other respects the method behaves just like DrupalTestCase::assert() in terms of storing the assertion.
Return value
Message ID of the stored assertion.
See also
DrupalTestCase::deleteAssert()
2 calls to DrupalTestCase::insertAssert()
- DrupalTestCase::run in drupal-7.x/
modules/ simpletest/ drupal_web_test_case.php - Run all tests in this class.
- simpletest_log_read in drupal-7.x/
modules/ simpletest/ simpletest.module - Read the error log and report any errors as assertion failures.
File
- drupal-7.x/
modules/ simpletest/ drupal_web_test_case.php, line 185
Class
- DrupalTestCase
- Base class for Drupal tests.
Code
public static function insertAssert($test_id, $test_class, $status, $message = '', $group = 'Other', array $caller = array()) {
// Convert boolean status to string status.
if (is_bool($status)) {
$status = $status ? 'pass' : 'fail';
}
$caller += array(
'function' => t('Unknown'),
'line' => 0,
'file' => t('Unknown'),
);
$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'],
);
return db_insert('simpletest')
->fields($assertion)
->execute();
}