14 private $actionFactoryMock;
19 private $actionListMock;
24 private $routeConfigMock;
33 $this->actionFactoryMock = $this->getMockBuilder(\
Magento\Framework\
App\ActionFactory::class)
34 ->disableOriginalConstructor()
35 ->setMethods([
'create'])
38 $this->actionListMock = $this->getMockBuilder(\
Magento\Framework\
App\Router\ActionList::class)
39 ->disableOriginalConstructor()
42 $this->routeConfigMock = $this->getMockBuilder(\
Magento\Framework\
App\Route\ConfigInterface::class)
43 ->getMockForAbstractClass();
45 $this->router = new \Magento\Robots\Controller\Router(
46 $this->actionFactoryMock,
47 $this->actionListMock,
48 $this->routeConfigMock
59 $requestMock = $this->getMockBuilder(\
Magento\Framework\
App\RequestInterface::class)
60 ->setMethods([
'getPathInfo'])
61 ->getMockForAbstractClass();
62 $requestMock->expects($this->once())
63 ->method(
'getPathInfo')
64 ->willReturn($identifier);
66 $this->assertNull($this->router->match($requestMock));
74 $identifier =
'robots.txt';
76 $requestMock = $this->getMockBuilder(\
Magento\Framework\
App\RequestInterface::class)
77 ->setMethods([
'getPathInfo'])
78 ->getMockForAbstractClass();
79 $requestMock->expects($this->once())
80 ->method(
'getPathInfo')
81 ->willReturn($identifier);
83 $this->routeConfigMock->expects($this->once())
84 ->method(
'getModulesByFrontName')
88 $this->assertNull($this->router->match($requestMock));
96 $identifier =
'robots.txt';
97 $moduleName =
'Magento_Robots';
98 $actionClassName = \Magento\Robots\Controller\Index\Index::class;
100 $requestMock = $this->getMockBuilder(\
Magento\Framework\
App\RequestInterface::class)
101 ->setMethods([
'getPathInfo'])
102 ->getMockForAbstractClass();
103 $requestMock->expects($this->once())
104 ->method(
'getPathInfo')
105 ->willReturn($identifier);
107 $this->routeConfigMock->expects($this->once())
108 ->method(
'getModulesByFrontName')
110 ->willReturn([$moduleName]);
112 $this->actionListMock->expects($this->once())
114 ->with($moduleName,
null,
'index',
'index')
115 ->willReturn($actionClassName);
117 $actionClassMock = $this->getMockBuilder(\
Magento\Robots\Controller\Index\Index::class)
118 ->disableOriginalConstructor()
121 $this->actionFactoryMock->expects($this->once())
123 ->with($actionClassName)
124 ->willReturn($actionClassMock);
126 $this->assertInstanceOf($actionClassName, $this->router->match($requestMock));
testMatchNoRobotsRequested()
testMatchNoRobotsModules()