BaseTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\App\Router;
  7. class BaseTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Framework\App\Router\Base
  11. */
  12. protected $_model;
  13. protected function setUp()
  14. {
  15. $options = ['routerId' => 'standard'];
  16. $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  17. \Magento\Framework\App\Router\Base::class,
  18. $options
  19. );
  20. }
  21. /**
  22. * @magentoAppArea frontend
  23. */
  24. public function testMatch()
  25. {
  26. if (!\Magento\TestFramework\Helper\Bootstrap::canTestHeaders()) {
  27. $this->markTestSkipped('Can\'t test get match without sending headers');
  28. }
  29. /** @var $objectManager \Magento\TestFramework\ObjectManager */
  30. $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  31. /** @var $request \Magento\TestFramework\Request */
  32. $request = $objectManager->get(\Magento\TestFramework\Request::class);
  33. $this->assertInstanceOf(\Magento\Framework\App\ActionInterface::class, $this->_model->match($request));
  34. $request->setRequestUri('framework/index/index');
  35. $this->assertInstanceOf(\Magento\Framework\App\ActionInterface::class, $this->_model->match($request));
  36. $request->setPathInfo(
  37. 'not_exists/not_exists/not_exists'
  38. )->setModuleName(
  39. 'not_exists'
  40. )->setControllerName(
  41. 'not_exists'
  42. )->setActionName(
  43. 'not_exists'
  44. );
  45. $this->assertNull($this->_model->match($request));
  46. }
  47. public function testGetControllerClassName()
  48. {
  49. $this->assertEquals(
  50. \Magento\Framework\Controller\Index::class,
  51. $this->_model->getActionClassName('Magento_Framework', 'index')
  52. );
  53. }
  54. }