public $regex = '';
public $runDisabled = false;
+ /**
+ * $called tracks whether the setUp and tearDown method has been called.
+ * class extending MediaWikiTestCase usually override setUp and tearDown
+ * but forget to call the parent.
+ *
+ * The array format takes a method name as key and anything as a value.
+ * By asserting the key exist, we know the child class has called the
+ * parent.
+ *
+ * This property must be private, we do not want child to override it,
+ * they should call the appropriate parent method instead.
+ */
+ private $called = array();
+
/**
* @var Array of TestUser
*/
protected function setUp() {
wfProfileIn( __METHOD__ );
parent::setUp();
+ $this->called['setUp'] = 1;
/*
//@todo: global variables to restore for *every* test
wfProfileOut( __METHOD__ );
}
+ /**
+ * Make sure MediaWikiTestCase extending classes have called their
+ * parent setUp method
+ */
+ final public function testMediaWikiTestCaseParentSetupCalled() {
+ $this->assertArrayHasKey( 'setUp', $this->called,
+ get_called_class() . "::setUp() must call parent::setUp()"
+ );
+ }
+
/**
* Individual test functions may override globals (either directly or through this
* setMwGlobals() function), however one must call this method at least once for
global $wgNamespaceProtection, $wgNamespaceAliases;
global $wgHooks, $IP;
+ parent::setUp();
+
$wgLanguageCode = 'en';
$wgContLang = Language::factory( 'en' );
// Restore backends
RepoGroup::destroySingleton();
FileBackendGroup::destroySingleton();
+
+ parent::tearDown();
}
function addDBData() {