Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. JUnitConverter.php

function JUnitConverter::convertTestCaseToSimpletestRow

Converts a PHPUnit test case result to a {simpletest} result row.

@internal

Parameters

int $test_id: The current test ID.

\SimpleXMLElement $test_case: The PHPUnit test case represented as XML element.

Return value

array An array containing the {simpletest} result row.

1 call to JUnitConverter::convertTestCaseToSimpletestRow()
JUnitConverter::xmlElementToRows in core/lib/Drupal/Core/Test/JUnitConverter.php
Parse test cases from XML to {simpletest} schema.

File

core/lib/Drupal/Core/Test/JUnitConverter.php, line 111

Class

JUnitConverter
Converts JUnit XML to Drupal's {simpletest} schema.

Namespace

Drupal\Core\Test

Code

public static function convertTestCaseToSimpletestRow($test_id, \SimpleXMLElement $test_case) {
    $message = '';
    $pass = TRUE;
    if ($test_case->failure) {
        $lines = explode("\n", $test_case->failure);
        $message = $lines[2];
        $pass = FALSE;
    }
    if ($test_case->error) {
        $message = $test_case->error;
        $pass = FALSE;
    }
    $attributes = $test_case->attributes();
    $record = [
        'test_id' => $test_id,
        'test_class' => (string) $attributes->class,
        'status' => $pass ? 'pass' : 'fail',
        'message' => $message,
        'message_group' => 'Other',
        'function' => $attributes->class . '->' . $attributes->name . '()',
        'line' => (int) $attributes->line ?: 0,
        'file' => (string) $attributes->file,
    ];
    return $record;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal