コード例 #1
0
 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
0
ファイル: BaseTest.php プロジェクト: aiesh/magento2
 /**
  * @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
0
ファイル: RouterTest.php プロジェクト: aiesh/magento2
 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
0
 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);
     }
 }