Last modified: 2014-10-19 17:47:08 UTC
This fails when running a test that extends CentralAuthTestCaseUsingDatabase: /** * @dataProvider provideWfWikiID */ public function testWfWikiID($expect) { $this->assertSame( $expect, wfWikiID() ); } public function provideWfWikiID() { return array( array( wfWikiID() ), ); } CentralAuthPluginUsingDatabaseTest::testWfWikiID with data set #0 ('wiki') Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ -wiki +wiki-unittest_ I tried to use $this->dbPrefix() inside the provider to kludge the right value and got a failure with this stacktrace which might help figure out where we could initialize $wgDBprefix to get consistent behavior: Fatal error: Call to a member function getType() on a non-object in /vagrant/mediawiki/tests/phpunit/MediaWikiTestCase.php on line 400 Call Stack: 0.0008 253704 1. {main}() /vagrant/mediawiki/tests/phpunit/phpunit.php:0 0.2053 8666952 2. MediaWikiPHPUnitCommand::main() /vagrant/mediawiki/tests/phpunit/phpunit.php:160 0.2053 8680808 3. PHPUnit_TextUI_Command->run() /vagrant/mediawiki/tests/phpunit/MediaWikiPHPUnitCommand.php:42 0.2263 9419016 4. PHPUnit_Runner_BaseTestRunner->getTest() /vagrant/mediawiki/vendor/phpunit/phpunit/src/TextUI/Command.php:153 0.2502 11030928 5. PHPUnit_Framework_TestSuite->__construct() /vagrant/mediawiki/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php:138 0.2587 11389784 6. PHPUnit_Framework_TestSuite->addTestMethod() /vagrant/mediawiki/vendor/phpunit/phpunit/src/Framework/TestSuite.php:219 0.2588 11390232 7. PHPUnit_Framework_TestSuite::createTest() /vagrant/mediawiki/vendor/phpunit/phpunit/src/Framework/TestSuite.php:800 0.2590 11394056 8. PHPUnit_Util_Test::getProvidedData() /vagrant/mediawiki/vendor/phpunit/phpunit/src/Framework/TestSuite.php:472 0.2591 11398136 9. ReflectionMethod->invoke() /vagrant/mediawiki/vendor/phpunit/phpunit/src/Util/Test.php:377 0.2591 11398208 10. CentralAuthPluginUsingDatabaseTest->provideAuthenticateWithPreRenameUsername() /vagrant/mediawiki/vendor/phpunit/phpunit/src/Util/Test.php:377 0.2592 11398320 11. MediaWikiTestCase->dbPrefix() /vagrant/mediawiki/extensions/CentralAuth/tests/CentralAuthPluginUsingDatabaseTest.php:205
*** Bug 68650 has been marked as a duplicate of this bug. ***
bug 68650 logged the same issue with ProofreadPage\FileProviderTest::testGetForIndexPage and ProofreadPage\FileProviderTest::testGetForPagePage
Thanks for filling this bug. I have noticed that when running the PHPUnit test suite with the wmf deployed extensions (bug 67216). An example run is: https://integration.wikimedia.org/ci/job/mediawiki-core-extensions-integration/76/consoleFull CentralAuth is not used in that job because of an unrelated issue (it has a central database). But ProofreadPage (was bug 68650) definitely does.
Change 150169 had a related patch set uploaded by Hashar: test: coverage for wfWikiID() https://gerrit.wikimedia.org/r/150169
About the stacktrace: PHPUnit providers are static functions which are evaluated before the test run. So you can not rely on the object state (i.e. $this->dbprefix does not exist).
Change 150169 merged by jenkins-bot: test: coverage for wfWikiID() https://gerrit.wikimedia.org/r/150169
I have a work around for the particular test where I encountered this problem originally: https://gerrit.wikimedia.org/r/#/c/147020/9/tests/CentralAuthPluginUsingDatabaseTest.php,unified