. implode( ' ', $filesToTest ) );
$suite = new PHPUnit_Framework_TestSuite;
+ $testList = array();
+ $counter = 0;
foreach ( $filesToTest as $fileName ) {
- $testsName = basename( $fileName, '.txt' );
+ // Call the highest level directory the extension name.
+ // It may or may not actually be, but it should be close
+ // enough to cause there to be separate names for different
+ // things, which is good enough for our purposes.
+ $extensionName = basename( dirname( $fileName ) );
+ $testsName = $extensionName . '⁄' . basename( $fileName, '.txt' );
$escapedFileName = strtr( $fileName, array( "'" => "\\'", '\\' => '\\\\' ) );
- /* This used to be ucfirst( basename( dirname( $filename ) ) )
- * and then was ucfirst( basename( $filename, '.txt' )
- * but that didn't work with names like foo.tests.txt
- */
- $parserTestClassName = str_replace( '.', '_', ucfirst( $testsName ) );
+ $parserTestClassName = ucfirst( $testsName );
+ // Official spec for class names: http://php.net/manual/en/language.oop5.basic.php
+ // Prepend 'ParserTest_' to be paranoid about it not starting with a number
+ $parserTestClassName = 'ParserTest_' . preg_replace( '/[^a-zA-Z0-9_\x7f-\xff]/', '_', $parserTestClassName );
+ if ( isset( $testList[$parserTestClassName] ) ) {
+ // If a conflict happens, gives a very unclear fatal.
+ // So as a last ditch effort to prevent that eventuality, if there
+ // is a conflict, append a number.
+ $counter++;
+ $parserTestClassName .= $counter;
+ }
+ $testList[$parserTestClassName] = true;
$parserTestClassDefinition = <<<EOT
/**
* @group Database