xmlElementToRows example


  public static function xmlToRows($test_id$phpunit_xml_file) {
    $contents = @file_get_contents($phpunit_xml_file);
    if (!$contents) {
      return [];
    }
    return static::xmlElementToRows($test_idnew \SimpleXMLElement($contents));
  }

  /** * Parse test cases from XML to {simpletest} schema. * * @param int $test_id * The current test ID. * @param \SimpleXMLElement $element * The XML data from the JUnit file. * * @return array[] * The results as array of rows in a format that can be inserted into the * {simpletest} table of the results database. * * @internal */

        'test_id' => 23,
        'test_class' => 'Drupal\Tests\simpletest\Unit\TestDiscoveryTest',
        'status' => 'pass',
        'message' => '',
        'message_group' => 'Other',
        'function' => 'Drupal\Tests\simpletest\Unit\TestDiscoveryTest->testGetTestClasses()',
        'line' => 108,
        'file' => '/Users/paul/projects/drupal/core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php',
      ],
    ];
    $this->assertEquals($simpletest, JUnitConverter::xmlElementToRows(23, new \SimpleXMLElement($junit)));
  }

  /** * @covers ::convertTestCaseToSimpletestRow */
  public function testConvertTestCaseToSimpletestRow() {
    $junit = <<<EOD <testcase name="testGetTestClasses" class="Drupal\Tests\simpletest\Unit\TestDiscoveryTest" classname="Drupal.Tests.simpletest.Unit.TestDiscoveryTest" file="/Users/paul/projects/drupal/core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php" line="108" assertions="2" time="0.100787"/> EOD;
    $simpletest = [
      'test_id' => 23,
      
Home | Imprint | This part of the site doesn't use cookies.