本文整理汇总了PHP中TestingAccessWrapper::newFromClass方法的典型用法代码示例。如果您正苦于以下问题:PHP TestingAccessWrapper::newFromClass方法的具体用法?PHP TestingAccessWrapper::newFromClass怎么用?PHP TestingAccessWrapper::newFromClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestingAccessWrapper
的用法示例。
在下文中一共展示了TestingAccessWrapper::newFromClass方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testStaticConstructorException
/**
* @expectedException InvalidArgumentException
*/
function testStaticConstructorException()
{
TestingAccessWrapper::newFromClass(new WellProtectedClass());
}
示例2: tearDown
public function tearDown()
{
parent::tearDown();
TestingAccessWrapper::newFromClass('Hooks')->handlers = $this->originalHandlers;
SpecialPageFactory::resetList();
}
示例3: resetAllEnv
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);
}
示例4: testGlobalSettingsDocumentedInSchema
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");
}
示例5: testNormalizeThrottleConditions2
public function testNormalizeThrottleConditions2()
{
$priv = \TestingAccessWrapper::newFromClass(Throttler::class);
$this->assertSame([], $priv->normalizeThrottleConditions(null));
$this->assertSame([], $priv->normalizeThrottleConditions('bad'));
}
示例6: testMakeLoaderImplementScriptInvalid
/**
* @covers ResourceLoader::makeLoaderImplementScript
*/
public function testMakeLoaderImplementScriptInvalid()
{
$this->setExpectedException('MWException', 'Invalid scripts error');
$rl = TestingAccessWrapper::newFromClass('ResourceLoader');
$rl->makeLoaderImplementScript('test', 123, null, null, null);
}
示例7: resetDB
/**
* 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();
}
}
}