Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
NoRouteHandlerListTest.php
Go to the documentation of this file.
1 <?php
8 
9 class NoRouteHandlerListTest extends \PHPUnit\Framework\TestCase
10 {
15 
19  protected $_model;
20 
21  protected function setUp()
22  {
23  $this->_objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
24  $handlersList = [
25  'default_handler' => ['class' => \Magento\Framework\App\Router\NoRouteHandler::class, 'sortOrder' => 100],
26  'backend_handler' => ['class' => \Magento\Backend\App\Router\NoRouteHandler::class, 'sortOrder' => 10],
27  ];
28 
29  $this->_model = new \Magento\Framework\App\Router\NoRouteHandlerList($this->_objectManagerMock, $handlersList);
30  }
31 
32  public function testGetHandlers()
33  {
34  $backendHandlerMock = $this->createMock(\Magento\Backend\App\Router\NoRouteHandler::class);
35  $defaultHandlerMock = $this->createMock(\Magento\Framework\App\Router\NoRouteHandler::class);
36 
37  $this->_objectManagerMock->expects(
38  $this->at(0)
39  )->method(
40  'create'
41  )->with(
42  \Magento\Backend\App\Router\NoRouteHandler::class
43  )->will(
44  $this->returnValue($backendHandlerMock)
45  );
46 
47  $this->_objectManagerMock->expects(
48  $this->at(1)
49  )->method(
50  'create'
51  )->with(
52  \Magento\Framework\App\Router\NoRouteHandler::class
53  )->will(
54  $this->returnValue($defaultHandlerMock)
55  );
56 
57  $expectedResult = ['0' => $backendHandlerMock, '1' => $defaultHandlerMock];
58 
59  $this->assertEquals($expectedResult, $this->_model->getHandlers());
60  }
61 }