Last modified: 2014-09-16 21:17:28 UTC
Inside of an extension create a parser tests file, name it parserTests.txt, and use $wgParserTestFiles[] = __DIR__ . '/parserTests.txt'; Running parserTests will work perfectly fine. However attempting to run unit tests will result in the following. PHP Fatal error: Cannot redeclare class ParserTests in {core}/tests/phpunit/includes/parser/MediaWikiParserTest.php(27) : eval()'d code on line 3 It appears that the phpunit parser test code makes really generic class names for parser test files based on the filename alone completely ignoring different paths.
Rephrased to Parsertests generated class names are not unique. See implementation in phpunit/includes/parser/MediaWikiParserTest.php which uses basename(). Definitely easy to fix, just have to find out a new convention.
Related URL: https://gerrit.wikimedia.org/r/67098 (Gerrit Change Idf14b4cbdb8ec103340d48855e0361acf707b101)
Thanks Bawolff for the patch, I just run into this as well. PHP Fatal error: Cannot redeclare class ParserTests in /srv/vagrant/mediawiki/tests/phpunit/includes/parser/MediaWikiParserTest.php(106) : eval()'d code on line 9 PHP Stack trace: PHP 1. {main}() /srv/vagrant/mediawiki/tests/phpunit/phpunit.php:0 PHP 2. MediaWikiPHPUnitCommand::main() /srv/vagrant/mediawiki/tests/phpunit/phpunit.php:160 PHP 3. PHPUnit_TextUI_Command->run() /srv/vagrant/mediawiki/tests/phpunit/MediaWikiPHPUnitCommand.php:42 PHP 4. MediaWikiPHPUnitCommand->handleArguments() /srv/vagrant/mediawiki/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:138 PHP 5. PHPUnit_TextUI_Command->handleArguments() /srv/vagrant/mediawiki/tests/phpunit/MediaWikiPHPUnitCommand.php:25 PHP 6. PHPUnit_Util_Configuration->getTestSuiteConfiguration() /srv/vagrant/mediawiki/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:657 PHP 7. PHPUnit_Util_Configuration->getTestSuite() /srv/vagrant/mediawiki/vendor/phpunit/phpunit/PHPUnit/Util/Configuration.php:797 PHP 8. PHPUnit_Framework_TestSuite->addTestFile() /srv/vagrant/mediawiki/vendor/phpunit/phpunit/PHPUnit/Util/Configuration.php:912 PHP 9. ReflectionMethod->invoke() /srv/vagrant/mediawiki/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:382 PHP 10. ExtensionsParserTestSuite::suite() /srv/vagrant/mediawiki/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:382 PHP 11. MediaWikiParserTest::suite() /srv/vagrant/mediawiki/tests/phpunit/suites/ExtensionsParserTestSuite.php:5 Fatal error: Cannot redeclare class ParserTests in /srv/vagrant/mediawiki/tests/phpunit/includes/parser/MediaWikiParserTest.php(106) : eval()'d code on line 9
Change 67098 merged by jenkins-bot: Make generating Parser test class names more robust https://gerrit.wikimedia.org/r/67098
Reedy CR ftw