本文整理汇总了PHP中ApiMain::lacksSameOriginSecurity方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiMain::lacksSameOriginSecurity方法的具体用法?PHP ApiMain::lacksSameOriginSecurity怎么用?PHP ApiMain::lacksSameOriginSecurity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiMain
的用法示例。
在下文中一共展示了ApiMain::lacksSameOriginSecurity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLacksSameOriginSecurity
/**
* @covers ApiMain::lacksSameOriginSecurity
*/
public function testLacksSameOriginSecurity()
{
// Basic test
$main = new ApiMain(new FauxRequest(array('action' => 'query', 'meta' => 'siteinfo')));
$this->assertFalse($main->lacksSameOriginSecurity(), 'Basic test, should have security');
// JSONp
$main = new ApiMain(new FauxRequest(array('action' => 'query', 'format' => 'xml', 'callback' => 'foo')));
$this->assertTrue($main->lacksSameOriginSecurity(), 'JSONp, should lack security');
// Header
$request = new FauxRequest(array('action' => 'query', 'meta' => 'siteinfo'));
$request->setHeader('TrEaT-As-UnTrUsTeD', '');
// With falsey value!
$main = new ApiMain($request);
$this->assertTrue($main->lacksSameOriginSecurity(), 'Header supplied, should lack security');
// Hook
$this->mergeMwGlobalArrayValue('wgHooks', array('RequestHasSameOriginSecurity' => array(function () {
return false;
})));
$main = new ApiMain(new FauxRequest(array('action' => 'query', 'meta' => 'siteinfo')));
$this->assertTrue($main->lacksSameOriginSecurity(), 'Hook, should lack security');
}