GetUtilityPageIdentifiersTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Cms\Test\Unit\Model;
  7. use Magento\Cms\Model\GetUtilityPageIdentifiers;
  8. use Magento\Framework\App\Config\ScopeConfigInterface;
  9. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
  10. use Magento\Store\Model\ScopeInterface;
  11. use PHPUnit\Framework\TestCase;
  12. /**
  13. * Provide tests for GetUtilityPageIdentifiers model.
  14. */
  15. class GetUtilityPageIdentifiersTest extends TestCase
  16. {
  17. /**
  18. * Test subject.
  19. *
  20. * @var GetUtilityPageIdentifiers
  21. */
  22. private $model;
  23. /**
  24. * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
  25. */
  26. private $scopeConfig;
  27. /**
  28. * @inheritdoc
  29. */
  30. protected function setUp()
  31. {
  32. $objectManager = new ObjectManager($this);
  33. $this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)
  34. ->setMethods(['getValue'])
  35. ->disableOriginalConstructor()
  36. ->getMockForAbstractClass();
  37. $this->model = $objectManager->getObject(
  38. GetUtilityPageIdentifiers::class,
  39. [
  40. 'scopeConfig' => $this->scopeConfig,
  41. ]
  42. );
  43. }
  44. /**
  45. * Test GetUtilityPageIdentifiers::execute() will read config for getting correct routes.
  46. *
  47. * @return void
  48. */
  49. public function testExecute()
  50. {
  51. $cmsHomePage = 'testCmsHomePage';
  52. $cmsNoRoute = 'testCmsNoRoute';
  53. $cmsNoCookies = 'testCmsNoCookies';
  54. $this->scopeConfig->expects($this->exactly(3))
  55. ->method('getValue')
  56. ->withConsecutive(
  57. [$this->identicalTo('web/default/cms_home_page'), $this->identicalTo(ScopeInterface::SCOPE_STORE)],
  58. [$this->identicalTo('web/default/cms_no_route'), $this->identicalTo(ScopeInterface::SCOPE_STORE)],
  59. [$this->identicalTo('web/default/cms_no_cookies'), $this->identicalTo(ScopeInterface::SCOPE_STORE)]
  60. )->willReturnOnConsecutiveCalls(
  61. $cmsHomePage,
  62. $cmsNoRoute,
  63. $cmsNoCookies
  64. );
  65. $this->assertSame([$cmsHomePage, $cmsNoRoute, $cmsNoCookies], $this->model->execute());
  66. }
  67. }