'DelayedParserTest' => "$testDir/testHelpers.inc",
'ParserTestResult' => "$testDir/parser/ParserTestResult.php",
'TestFileIterator' => "$testDir/testHelpers.inc",
+ 'TestFileDataProvider' => "$testDir/testHelpers.inc",
'TestRecorder' => "$testDir/testHelpers.inc",
'ITestRecorder' => "$testDir/testHelpers.inc",
'DjVuSupport' => "$testDir/testHelpers.inc",
// "extra language links"
// see https://gerrit.wikimedia.org/r/111390
array_push( $wgExtraInterlanguageLinkPrefixes, 'mul' );
+
+ // Reset namespace cache
+ MWNamespace::getCanonicalNamespaces( true );
+ Language::factory( 'en' )->resetNamespaces();
}
/**
$result =
$this->runTest( $t['test'], $t['input'], $t['result'], $t['options'], $t['config'] );
$ok = $ok && $result;
- $this->recorder->record( $t['test'], $result );
+ $this->recorder->record( $t['test'], $t['subtest'], $result );
}
if ( $this->showProgress ) {
/**
* Called after each test
* @param string $test
+ * @param integer $subtest
* @param bool $result
*/
- public function record( $test, $result );
+ public function record( $test, $subtest, $result );
/**
* Called before finishing the test run
$this->success = 0;
}
- function record( $test, $result ) {
+ function record( $test, $subtest, $result ) {
$this->total++;
$this->success += ( $result ? 1 : 0 );
}
$this->results = [];
}
- function record( $test, $result ) {
- parent::record( $test, $result );
- $this->results[$test] = $result;
+ function getName( $test, $subtest ) {
+ if ( $subtest ) {
+ return "$test subtest #$subtest";
+ } else {
+ return $test;
+ }
+ }
+
+ function record( $test, $subtest, $result ) {
+ parent::record( $test, $subtest, $result );
+ $this->results[ $this->getName( $test, $subtest ) ] = $result;
}
function report() {
}
/**
- * Commit transaction and clean up for result recording
+ * Close the DB connection
*/
function end() {
- $this->lb->commitMasterChanges();
$this->lb->closeAll();
parent::end();
}
* @param string $test
* @param bool $result
*/
- function record( $test, $result ) {
- parent::record( $test, $result );
+ function record( $test, $subtest, $result ) {
+ parent::record( $test, $subtest, $result );
$this->db->insert( 'testitem',
[
'ti_run' => $this->curRun,
- 'ti_name' => $test,
+ 'ti_name' => $this->getName( $test, $subtest ),
'ti_success' => $result ? 1 : 0,
],
__METHOD__ );
}
+
+ /**
+ * Commit transaction and clean up for result recording
+ */
+ function end() {
+ $this->db->commit( __METHOD__ );
+ parent::end();
+ }
}
class TestFileIterator implements Iterator {
$this->test = [
'test' => ParserTest::chomp( $this->sectionData['test'] ),
+ 'subtest' => $this->nextSubTest,
'input' => ParserTest::chomp( $this->sectionData[$input] ),
'result' => ParserTest::chomp( $this->sectionData[$result] ),
'options' => ParserTest::chomp( $this->sectionData['options'] ),
}
}
+/**
+ * An iterator for use as a phpunit data provider. Provides the test arguments
+ * in the order expected by NewParserTest::testParserTest().
+ */
+class TestFileDataProvider extends TestFileIterator {
+ function current() {
+ $test = parent::current();
+ if ( $test ) {
+ return [
+ $test['test'],
+ $test['input'],
+ $test['result'],
+ $test['options'],
+ $test['config'],
+ ];
+ } else {
+ return $test;
+ }
+ }
+}
+
/**
* A class to delay execution of a parser test hooks.
*/