本文整理匯總了PHP中Magento\TestFramework\Helper\Bootstrap::canTestHeaders方法的典型用法代碼示例。如果您正苦於以下問題:PHP Bootstrap::canTestHeaders方法的具體用法?PHP Bootstrap::canTestHeaders怎麽用?PHP Bootstrap::canTestHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\TestFramework\Helper\Bootstrap
的用法示例。
在下文中一共展示了Bootstrap::canTestHeaders方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testDispatch
public function testDispatch()
{
if (!\Magento\TestFramework\Helper\Bootstrap::canTestHeaders()) {
$this->markTestSkipped('Can\'t test dispatch process without sending headers');
}
$_SERVER['HTTP_HOST'] = 'localhost';
$this->_objectManager->get('Magento\\Framework\\App\\State')->setAreaCode('frontend');
$request = $this->_objectManager->create('Magento\\Framework\\App\\Request\\Http');
/* empty action */
$request->setRequestUri('core/index/index');
$this->assertInstanceOf('Magento\\Framework\\Controller\\ResultInterface', $this->_model->dispatch($request));
}
示例2: testMatch
/**
* @magentoAppArea frontend
*/
public function testMatch()
{
if (!\Magento\TestFramework\Helper\Bootstrap::canTestHeaders()) {
$this->markTestSkipped('Can\'t test get match without sending headers');
}
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/** @var $request \Magento\TestFramework\Request */
$request = $objectManager->get('Magento\\TestFramework\\Request');
$this->assertInstanceOf('Magento\\Framework\\App\\ActionInterface', $this->_model->match($request));
$request->setRequestUri('core/index/index');
$this->assertInstanceOf('Magento\\Framework\\App\\ActionInterface', $this->_model->match($request));
$request->setPathInfo('not_exists/not_exists/not_exists')->setModuleName('not_exists')->setControllerName('not_exists')->setActionName('not_exists');
$this->assertNull($this->_model->match($request));
}
示例3: testMatchCustomNoRouteAction
public function testMatchCustomNoRouteAction()
{
if (!\Magento\TestFramework\Helper\Bootstrap::canTestHeaders()) {
$this->markTestSkipped('Can\'t test get match without sending headers');
}
$routers = array('testmodule' => array('frontName' => 'testfixture', 'id' => 'testfixture', 'modules' => array('Magento_TestFixture')));
$routeConfig = $this->getMock('Magento\\Framework\\App\\Route\\Config', array('_getRoutes'), array('reader' => $this->objectManager->get('Magento\\Framework\\App\\Route\\Config\\Reader'), 'cache' => $this->objectManager->get('Magento\\Framework\\Config\\CacheInterface'), 'configScope' => $this->objectManager->get('Magento\\Framework\\Config\\ScopeInterface'), 'areaList' => $this->objectManager->get('Magento\\Framework\\App\\AreaList'), 'cacheId' => 'RoutesConfig'));
$routeConfig->expects($this->any())->method('_getRoutes')->will($this->returnValue($routers));
$defaultRouter = $this->objectManager->create('Magento\\Backend\\App\\Router', array('routeConfig' => $routeConfig));
/** @var $request \Magento\TestFramework\Request */
$request = $this->objectManager->get('Magento\\TestFramework\\Request');
$request->setPathInfo('backend/testfixture/test_controller');
$controller = $defaultRouter->match($request);
$this->assertInstanceOf('Magento\\TestFixture\\Controller\\Adminhtml\\Noroute', $controller);
$this->assertEquals('noroute', $request->getActionName());
}
示例4: testCanTestHeaders
public function testCanTestHeaders()
{
if (!function_exists('xdebug_get_headers')) {
$this->assertFalse(\Magento\TestFramework\Helper\Bootstrap::canTestHeaders(), 'Expected inability to test headers.');
return;
}
$expectedHeader = 'SomeHeader: header-value';
$expectedCookie = 'Set-Cookie: SomeCookie=cookie-value';
/* Make sure that chosen reference samples are unique enough to rely on them */
$actualHeaders = xdebug_get_headers();
$this->assertNotContains($expectedHeader, $actualHeaders);
$this->assertNotContains($expectedCookie, $actualHeaders);
/* Determine whether header-related functions can be in fact called with no error */
$expectedCanTest = true;
set_error_handler(function () use(&$expectedCanTest) {
$expectedCanTest = false;
});
header($expectedHeader);
setcookie('SomeCookie', 'cookie-value');
restore_error_handler();
$this->assertEquals($expectedCanTest, \Magento\TestFramework\Helper\Bootstrap::canTestHeaders());
if ($expectedCanTest) {
$actualHeaders = xdebug_get_headers();
$this->assertContains($expectedHeader, $actualHeaders);
$this->assertContains($expectedCookie, $actualHeaders);
}
}