/** * @expectedException InvalidArgumentException */ function testStaticConstructorException() { TestingAccessWrapper::newFromClass(new WellProtectedClass()); }
public function tearDown() { parent::tearDown(); TestingAccessWrapper::newFromClass('Hooks')->handlers = $this->originalHandlers; SpecialPageFactory::resetList(); }
function resetAllEnv() { $_SESSION = array(); $_GET = array(); $_POST = array(); $_SERVER = array(); $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; $_SERVER['HTTP_HOST'] = TESTS_HOSTNAME; $_SERVER['SERVER_NAME'] = TESTS_HOSTNAME; $_SERVER['SCRIPT_NAME'] = __FILE__; RequestContext::resetMain(); // Wipe out the $instance of these classes to make sure they're // re-created with fresh gateway instances for the next test $singleton_classes = array('Gateway_Extras_ConversionLog', 'Gateway_Extras_CustomFilters', 'Gateway_Extras_CustomFilters_Functions', 'Gateway_Extras_CustomFilters_IP_Velocity', 'Gateway_Extras_CustomFilters_MinFraud', 'Gateway_Extras_CustomFilters_Referrer', 'Gateway_Extras_CustomFilters_Source', 'Gateway_Extras_SessionVelocityFilter'); foreach ($singleton_classes as $singleton_class) { $unwrapped = TestingAccessWrapper::newFromClass($singleton_class); $unwrapped->instance = null; } // Reset SmashPig context Context::set(null); }
public function testGlobalSettingsDocumentedInSchema() { global $IP; $globalSettings = TestingAccessWrapper::newFromClass(ExtensionProcessor::class)->globalSettings; $schema = FormatJson::decode(file_get_contents("{$IP}/docs/extension.schema.json"), true); $missing = []; foreach ($globalSettings as $global) { if (!isset($schema['properties'][$global])) { $missing[] = $global; } } $this->assertEquals([], $missing, "The following global settings are not documented in docs/extension.schema.json"); }
public function testNormalizeThrottleConditions2() { $priv = \TestingAccessWrapper::newFromClass(Throttler::class); $this->assertSame([], $priv->normalizeThrottleConditions(null)); $this->assertSame([], $priv->normalizeThrottleConditions('bad')); }
/** * @covers ResourceLoader::makeLoaderImplementScript */ public function testMakeLoaderImplementScriptInvalid() { $this->setExpectedException('MWException', 'Invalid scripts error'); $rl = TestingAccessWrapper::newFromClass('ResourceLoader'); $rl->makeLoaderImplementScript('test', 123, null, null, null); }
/** * Empty all tables so they can be repopulated for tests * * @param DatabaseBase $db|null Database to reset * @param array $tablesUsed Tables to reset */ private function resetDB($db, $tablesUsed) { if ($db) { $userTables = ['user', 'user_groups', 'user_properties']; $coreDBDataTables = array_merge($userTables, ['page', 'revision']); // If any of the user tables were marked as used, we should clear all of them. if (array_intersect($tablesUsed, $userTables)) { $tablesUsed = array_unique(array_merge($tablesUsed, $userTables)); // Totally clear User class in-process cache to avoid CAS errors TestingAccessWrapper::newFromClass('User')->getInProcessCache()->clear(); TestUserRegistry::clear(); } $truncate = in_array($db->getType(), ['oracle', 'mysql']); foreach ($tablesUsed as $tbl) { // TODO: reset interwiki table to its original content. if ($tbl == 'interwiki') { continue; } if ($truncate) { $db->query('TRUNCATE TABLE ' . $db->tableName($tbl), __METHOD__); } else { $db->delete($tbl, '*', __METHOD__); } if ($tbl === 'page') { // Forget about the pages since they don't // exist in the DB. LinkCache::singleton()->clear(); } } if (array_intersect($tablesUsed, $coreDBDataTables)) { // Re-add core DB data that was deleted $this->addCoreDBData(); } } }