public function testMatch() { $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); $urlRewrite = $this->getMockBuilder('Magento\\UrlRewrite\\Service\\V1\\Data\\UrlRewrite')->disableOriginalConstructor()->getMock(); $urlRewrite->expects($this->any())->method('getRedirectType')->will($this->returnValue(0)); $urlRewrite->expects($this->any())->method('getTargetPath')->will($this->returnValue('target-path')); $this->urlFinder->expects($this->any())->method('findOneByData')->will($this->returnValue($urlRewrite)); $this->request->expects($this->once())->method('setPathInfo')->with('/target-path'); $this->actionFactory->expects($this->once())->method('create')->with('Magento\\Framework\\App\\Action\\Forward', ['request' => $this->request]); $this->router->match($this->request); }
public function testMatchEmptyActionInstance() { // Test Data $nullActionInstance = null; $moduleFrontName = 'module front name'; $actionPath = 'action path'; $actionName = 'action name'; $actionClassName = 'Magento\\Cms\\Controller\\Index\\Index'; $moduleName = 'module name'; $moduleList = [$moduleName]; // Stubs $this->requestMock->expects($this->any())->method('getModuleName')->willReturn($moduleFrontName); $this->routeConfigMock->expects($this->any())->method('getModulesByFrontName')->willReturn($moduleList); $this->requestMock->expects($this->any())->method('getControllerName')->willReturn($actionPath); $this->requestMock->expects($this->any())->method('getActionName')->willReturn($actionName); $this->appStateMock->expects($this->any())->method('isInstalled')->willReturn(false); $this->actionListMock->expects($this->any())->method('get')->willReturn($actionClassName); $this->actionFactoryMock->expects($this->any())->method('create')->willReturn($nullActionInstance); // Expectations and Test $this->assertNull($this->model->match($this->requestMock)); }