123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Backend\Test\Unit\App\Router;
- class NoRouteHandlerTest extends \PHPUnit\Framework\TestCase
- {
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $_helperMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $_requestMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $_routeConfigMock;
- /**
- * @var \Magento\Backend\App\Router\NoRouteHandler
- */
- protected $_model;
- protected function setUp()
- {
- $this->_requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class);
- $this->_routeConfigMock = $this->createMock(\Magento\Framework\App\Route\ConfigInterface::class);
- $this->_helperMock = $this->createMock(\Magento\Backend\Helper\Data::class);
- $this->_helperMock->expects($this->any())->method('getAreaFrontName')->will($this->returnValue('backend'));
- $this->_model = new \Magento\Backend\App\Router\NoRouteHandler($this->_helperMock, $this->_routeConfigMock);
- }
- /**
- * @covers \Magento\Backend\App\Router\NoRouteHandler::process
- */
- public function testProcessWithBackendAreaFrontName()
- {
- $this->_routeConfigMock
- ->expects($this->once())
- ->method('getRouteFrontName')
- ->with('adminhtml')
- ->will($this->returnValue('admin'));
- $this->_requestMock
- ->expects($this->once())
- ->method('getPathInfo')
- ->will($this->returnValue('backend/admin/custom'));
- $this->_requestMock->expects(
- $this->once()
- )->method(
- 'setModuleName'
- )->with(
- 'admin'
- )->will(
- $this->returnValue($this->_requestMock)
- );
- $this->_requestMock->expects(
- $this->once()
- )->method(
- 'setControllerName'
- )->with(
- 'noroute'
- )->will(
- $this->returnValue($this->_requestMock)
- );
- $this->_requestMock->expects(
- $this->once()
- )->method(
- 'setActionName'
- )->with(
- 'index'
- )->will(
- $this->returnValue($this->_requestMock)
- );
- $this->assertEquals(true, $this->_model->process($this->_requestMock));
- }
- /**
- * @covers \Magento\Backend\App\Router\NoRouteHandler::process
- */
- public function testProcessWithoutAreaFrontName()
- {
- $this->_requestMock->expects(
- $this->once()
- )->method(
- 'getPathInfo'
- )->will(
- $this->returnValue('module/controller/action')
- );
- $this->_requestMock->expects($this->never())->method('setModuleName');
- $this->_requestMock->expects($this->never())->method('setControllerName');
- $this->_requestMock->expects($this->never())->method('setActionName');
- $this->assertEquals(false, $this->_model->process($this->_requestMock));
- }
- }
|