function simpletest_phpunit_testcase_to_row

Converts a PHPUnit testcase result to a simpletest result row.

Parameters

int $test_id: The current test ID.

\SimpleXMLElement $testcase: The PHPUnit testcase represented as XML element.

string $file: The path to test file, which was executed.

Return value

array An array containg the simpletest result row.

1 call to simpletest_phpunit_testcase_to_row()
simpletest_phpunit_xml_to_rows in drupal/core/modules/simpletest/simpletest.module
Converts phpunit's junit xml output to an array.

File

drupal/core/modules/simpletest/simpletest.module, line 807
Provides testing functionality.

Code

function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcase, $file) {
  $message = '';
  $pass = TRUE;
  if ($testcase->failure) {
    $lines = explode("\n", $testcase->failure);
    $message = $lines[2];
    $pass = FALSE;
  }
  if ($testcase->error) {
    $message = $testcase->error;
    $pass = FALSE;
  }
  $attributes = $testcase
    ->attributes();
  $record = array(
    'test_id' => $test_id,
    'test_class' => (string) $attributes->class,
    'status' => $pass ? 'pass' : 'fail',
    'message' => $message,
    // @todo: Check on the proper values for this.
    'message_group' => 'Other',
    'function' => $attributes->class . '->' . $attributes->name . '()',
    'line' => $attributes->line ?: 0,
    'file' => $file,
  );
  return $record;
}