SecurityInfoTest.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Store\Test\Unit\Url\Plugin;
  7. class SecurityInfoTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \PHPUnit_Framework_MockObject_MockObject
  11. */
  12. protected $_scopeConfigMock;
  13. /**
  14. * @var \Magento\Store\Url\Plugin\SecurityInfo
  15. */
  16. protected $_model;
  17. protected function setUp()
  18. {
  19. $this->_scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
  20. $this->_model = new \Magento\Store\Url\Plugin\SecurityInfo($this->_scopeConfigMock);
  21. }
  22. public function testAroundIsSecureDisabledInConfig()
  23. {
  24. $this->_scopeConfigMock
  25. ->expects($this->once())
  26. ->method('getValue')
  27. ->with(
  28. \Magento\Store\Model\Store::XML_PATH_SECURE_IN_FRONTEND,
  29. \Magento\Store\Model\ScopeInterface::SCOPE_STORE
  30. )
  31. ->will($this->returnValue(false));
  32. $this->assertFalse(
  33. $this->_model->aroundIsSecure(
  34. $this->createMock(\Magento\Framework\Url\SecurityInfo::class),
  35. function () {
  36. },
  37. 'http://example.com/account'
  38. )
  39. );
  40. }
  41. public function testAroundIsSecureEnabledInConfig()
  42. {
  43. $this->_scopeConfigMock
  44. ->expects($this->once())
  45. ->method('getValue')
  46. ->with(
  47. \Magento\Store\Model\Store::XML_PATH_SECURE_IN_FRONTEND,
  48. \Magento\Store\Model\ScopeInterface::SCOPE_STORE
  49. )
  50. ->will($this->returnValue(true));
  51. $this->assertTrue(
  52. $this->_model->aroundIsSecure(
  53. $this->createMock(\Magento\Framework\Url\SecurityInfo::class),
  54. function () {
  55. return true;
  56. },
  57. 'https://example.com/account'
  58. )
  59. );
  60. }
  61. }