protected function DrupalTestCase::assert

7.x drupal_web_test_case.php protected DrupalTestCase::assert($status, $message = '', $group = 'Other', array $caller = NULL)

Internal helper: stores the assert.


$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.

42 calls to DrupalTestCase::assert()
AggregatorRenderingTestCase::testBlockLinks in drupal/modules/aggregator/aggregator.test
Adds a feed block to the page and checks its links.
AJAXMultiFormTestCase::testMultiForm in drupal/modules/simpletest/tests/ajax.test
Test that a page with the 'page_node_form' included twice works correctly.
CascadingStylesheetsTestCase::testAlter in drupal/modules/simpletest/tests/common.test
Tests Locale module's CSS Alter to include RTL overrides.
CascadingStylesheetsTestCase::testRenderOverride in drupal/modules/simpletest/tests/common.test
Test CSS override.
CommentActionsTestCase::assertWatchdogMessage in drupal/modules/comment/comment.test
Verify that a watchdog message has been entered.

... See full list


drupal/modules/simpletest/drupal_web_test_case.php, line 119


Base class for Drupal tests.


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.
  try {
    $connection = Database::getConnection('default', 'simpletest_original_default');
  catch (DatabaseConnectionNotDefinedException $e) {
    // If the test was not set up, the simpletest_original_default
    // connection does not exist.
    $connection = Database::getConnection('default', 'default');

  // We do not use a ternary operator here to allow a breakpoint on
  // test failure.
  if ($status == 'pass') {
    return TRUE;
  else {
    return FALSE;