*/
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
// 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' );
}
* @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;
$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 );