13 private $objectManager;
33 private $serializerMock;
37 $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
38 $this->cacheMock = $this->createMock(\
Magento\Framework\
Config\CacheInterface::class);
39 $this->readerMock = $this->createMock(\
Magento\Framework\Module\Dir\Reader::class);
40 $this->serializerMock = $this->createMock(\
Magento\Framework\
Serialize\SerializerInterface::class);
45 $this->cacheMock->expects($this->once())
47 ->willReturn(
'"data"');
48 $this->serializerMock->expects($this->once())
49 ->method(
'unserialize');
50 $this->cacheMock->expects($this->never())
52 $this->readerMock->expects($this->never())
53 ->method(
'getActionFiles');
54 $this->createActionListInstance();
59 $this->cacheMock->expects($this->once())
62 $this->serializerMock->expects($this->once())
63 ->method(
'serialize');
64 $this->cacheMock->expects($this->once())
66 $this->readerMock->expects($this->once())
67 ->method(
'getActionFiles')
70 $this->createActionListInstance();
82 public function testGet($module, $area, $namespace, $action,
$data, $expected)
84 $this->cacheMock->expects($this->once())
86 ->will($this->returnValue(
false));
87 $this->cacheMock->expects($this->once())
89 $this->readerMock->expects($this->once())
90 ->method(
'getActionFiles')
92 $this->createActionListInstance();
93 $this->assertEquals($expected, $this->actionList->get($module, $area, $namespace, $action));
101 $mockClassName =
'Mock_Action_Class';
102 $actionClass = $this->getMockClass(
103 \
Magento\Framework\
App\ActionInterface::class,
104 [
'execute',
'getResponse'],
115 [
'magento\module\controller\area\namespace\index' => $mockClassName],
123 [
'magento\module\controller\namespace\index' => $mockClassName],
131 [
'magento\module\controller\area\namespace\catchaction' => $mockClassName],
139 [
'magento\module\controller\area\namespace\index' =>
'Not_Exist_Class'],
155 'magento\module\controller\adminhtml\product\index' =>
'$mockClassName',
161 private function createActionListInstance()
163 $this->actionList = $this->objectManager->getObject(
164 \
Magento\Framework\
App\Router\ActionList::class,
166 'cache' => $this->cacheMock,
167 'moduleReader' => $this->readerMock,
168 'serializer' => $this->serializerMock,
testGet($module, $area, $namespace, $action, $data, $expected)
testConstructActionsCached()
testConstructActionsNoCached()