protected function DrupalTestCase::assert in SimpleTest 6.2
Same name and namespace in other branches
- 7.2 drupal_web_test_case.php \DrupalTestCase::assert()
- 7 drupal_web_test_case.php \DrupalTestCase::assert()
Internal helper: stores the assert.
Parameters
$status: Can be 'pass', 'fail', 'exception'. TRUE is a synonym for 'pass', FALSE for 'fail'.
$message: The message string.
$group: Which group this assert belongs to.
$caller: By default, the assert comes from a function whose name starts with 'test'. Instead, you can specify where this assert originates from by passing in an associative array as $caller. Key 'file' is the name of the source file, 'line' is the line number and 'function' is the caller function itself.
22 calls to DrupalTestCase::assert()
- DrupalTestCase::assertEqual in ./
drupal_web_test_case.php - Check to see if two values are equal.
- DrupalTestCase::assertFalse in ./
drupal_web_test_case.php - Check to see if a value is false (an empty string, 0, NULL, or FALSE).
- DrupalTestCase::assertIdentical in ./
drupal_web_test_case.php - Check to see if two values are identical.
- DrupalTestCase::assertNotEqual in ./
drupal_web_test_case.php - Check to see if two values are not equal.
- DrupalTestCase::assertNotIdentical in ./
drupal_web_test_case.php - Check to see if two values are not identical.
File
- ./
drupal_web_test_case.php, line 110
Class
- DrupalTestCase
- Base class for Drupal tests.
Code
protected function assert($status, $message = '', $group = 'Other', array $caller = NULL) {
// Convert boolean status to string status.
if (is_bool($status)) {
$status = $status ? 'pass' : 'fail';
}
// Increment summary result counter.
$this->results['#' . $status]++;
// Get the function information about the call to the assertion method.
if (!$caller) {
$caller = $this
->getAssertionCall();
}
// Creation assertion array that can be displayed while tests are running.
$this->assertions[] = $assertion = array(
'test_id' => $this->testId,
'test_class' => get_class($this),
'status' => $status,
'message' => $message,
'message_group' => $group,
'function' => $caller['function'],
'line' => $caller['line'],
'file' => $caller['file'],
);
// Store assertion for display after the test has completed.
$current_db_prefix = $GLOBALS['db_prefix'];
$GLOBALS['db_prefix'] = $this->originalPrefix;
db_query("INSERT INTO {simpletest}\n (test_id, test_class, status, message, message_group, function, line, file)\n VALUES (%d, '%s', '%s', '%s', '%s', '%s', %d, '%s')", array_values($assertion));
$GLOBALS['db_prefix'] = $current_db_prefix;
// We do not use a ternary operator here to allow a breakpoint on
// test failure.
if ($status == 'pass') {
return TRUE;
}
else {
return FALSE;
}
}