Exemple #1
0
 public function testProcessIfStoreCodeIsNotExist()
 {
     $store = $this->getMock('\\Magento\\Store\\Model\\Store', array(), array(), '', false);
     $this->_storeManagerMock->expects($this->once())->method('getStores')->with(false, true)->will($this->returnValue(array('0' => $store)));
     $store->expects($this->never())->method('isUseStoreInUrl');
     $this->_requestMock->expects($this->never())->method('isDirectAccessFrontendName');
     $this->assertEquals($this->_pathInfo, $this->_model->process($this->_requestMock, $this->_pathInfo));
 }
 public function testProcessIfStoreCodeIsNotExist()
 {
     $store = $this->getMock('\\Magento\\Store\\Model\\Store', [], [], '', false);
     $this->_storeManagerMock->expects($this->once())->method('getStore')->with('storeCode')->willThrowException(new NoSuchEntityException());
     $store->expects($this->never())->method('isUseStoreInUrl');
     $this->_requestMock->expects($this->never())->method('isDirectAccessFrontendName');
     $this->assertEquals($this->_pathInfo, $this->_model->process($this->_requestMock, $this->_pathInfo));
 }
 /**
  * Process path info
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @param string $pathInfo
  * @return string
  */
 public function process(\Magento\Framework\App\RequestInterface $request, $pathInfo)
 {
     $pathParts = explode('/', ltrim($pathInfo, '/'), 2);
     $firstPart = $pathParts[0];
     if ($firstPart != $this->_helper->getAreaFrontName()) {
         return $this->_subject->process($request, $pathInfo);
     }
     return $pathInfo;
 }
 /**
  * @covers \Magento\Store\App\Request\PathInfoProcessor::process
  * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
  */
 public function testProcessValidStoreCodeCase3()
 {
     /** @var \Magento\Store\Model\Store $store */
     $store = Bootstrap::getObjectManager()->get('Magento\\Store\\Model\\Store');
     $store->load('fixturestore', 'code');
     /** @var \Magento\Framework\App\RequestInterface $request */
     $request = Bootstrap::getObjectManager()->create('Magento\\Framework\\App\\RequestInterface', ['directFrontNames' => [$store->getCode() => true]]);
     /** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */
     $config = Bootstrap::getObjectManager()->get('\\Magento\\Framework\\App\\Config\\ReinitableConfigInterface');
     $config->setValue(Store::XML_PATH_STORE_IN_URL, true, ScopeInterface::SCOPE_STORE, $store->getCode());
     $pathInfo = sprintf('/%s/m/c/a', $store->getCode());
     $this->assertEquals($pathInfo, $this->pathProcessor->process($request, $pathInfo));
     $this->assertEquals('noroute', $request->getActionName());
 }