X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2FMediaWikiTestCase.php;h=d5428268b52e1f4165d19b001a88c5b4fc58cb3d;hp=f04eec73b4d6e1801711107e648a19ca1920d2bc;hb=dbad540cd37617879aff6f28ce9c016dd8049d4e;hpb=91be4ee4645e28866910f654c6eda730a692fc90 diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index f04eec73b4..d5428268b5 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -14,6 +14,8 @@ use Wikimedia\TestingAccessWrapper; */ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { + use MediaWikiCoversValidator; + /** * The service locator created by prepareServices(). This service locator will * be restored after each test. Tests that pollute the global service locator @@ -515,8 +517,9 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { // XXX: reset maintenance triggers // Hook into period lag checks which often happen in long-running scripts - $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); - Maintenance::setLBFactoryTriggers( $lbFactory ); + $services = MediaWikiServices::getInstance(); + $lbFactory = $services->getDBLoadBalancerFactory(); + Maintenance::setLBFactoryTriggers( $lbFactory, $services->getMainConfig() ); ob_start( 'MediaWikiTestCase::wfResetOutputBuffersBarrier' ); } @@ -968,12 +971,13 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { * @since 1.18 */ public function needsDB() { - # if the test says it uses database tables, it needs the database + // If the test says it uses database tables, it needs the database if ( $this->tablesUsed ) { return true; } - # if the test says it belongs to the Database group, it needs the database + // If the test class says it belongs to the Database group, it needs the database. + // NOTE: This ONLY checks for the group in the class level doc comment. $rc = new ReflectionClass( $this ); if ( preg_match( '/@group +Database/im', $rc->getDocComment() ) ) { return true; @@ -1007,10 +1011,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { $user = static::getTestSysop()->getUser(); $comment = __METHOD__ . ': Sample page for unit test.'; - // Avoid memory leak...? - // LinkCache::singleton()->clear(); - // Maybe. But doing this absolutely breaks $title->isRedirect() when called during unit tests.... - $page = WikiPage::factory( $title ); $page->doEditContent( ContentHandler::makeContent( $text, $title ), $comment, 0, false, $user );