DefaultRouterTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * RouterList model test class
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Framework\App\Test\Unit\Router;
  9. class DefaultRouterTest extends \PHPUnit\Framework\TestCase
  10. {
  11. /**
  12. * @var \Magento\Framework\App\Router\DefaultRouter
  13. */
  14. protected $_model;
  15. public function testMatch()
  16. {
  17. $request = $this->createMock(\Magento\Framework\App\RequestInterface::class);
  18. $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  19. $actionFactory = $this->createMock(\Magento\Framework\App\ActionFactory::class);
  20. $actionFactory->expects($this->once())->method('create')->with(
  21. \Magento\Framework\App\Action\Forward::class
  22. )->will(
  23. $this->returnValue(
  24. $this->getMockForAbstractClass(\Magento\Framework\App\Action\AbstractAction::class, [], '', false)
  25. )
  26. );
  27. $noRouteHandler = $this->createMock(\Magento\Framework\App\Router\NoRouteHandler::class);
  28. $noRouteHandler->expects($this->any())->method('process')->will($this->returnValue(true));
  29. $noRouteHandlerList = $this->createMock(\Magento\Framework\App\Router\NoRouteHandlerList::class);
  30. $noRouteHandlerList->expects($this->any())->method('getHandlers')->will($this->returnValue([$noRouteHandler]));
  31. $this->_model = $helper->getObject(
  32. \Magento\Framework\App\Router\DefaultRouter::class,
  33. [
  34. 'actionFactory' => $actionFactory,
  35. 'noRouteHandlerList' => $noRouteHandlerList
  36. ]
  37. );
  38. $this->assertInstanceOf(\Magento\Framework\App\Action\AbstractAction::class, $this->_model->match($request));
  39. }
  40. }