SecurityInfoTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Url\Test\Unit;
  7. class SecurityInfoTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \PHPUnit_Framework_MockObject_MockObject
  11. */
  12. protected $_scopeConfigMock;
  13. /**
  14. * @var \Magento\Framework\Url\SecurityInfo
  15. */
  16. protected $_model;
  17. protected function setUp()
  18. {
  19. $this->_model = new \Magento\Framework\Url\SecurityInfo(['/account', '/cart'], ['/cart/remove', 'customer']);
  20. }
  21. /**
  22. * @param string $url
  23. * @param bool $expected
  24. * @dataProvider secureUrlDataProvider
  25. */
  26. public function testIsSecureChecksIfUrlIsInSecureList($url, $expected)
  27. {
  28. $this->assertEquals($expected, $this->_model->isSecure($url));
  29. }
  30. /**
  31. * @return array
  32. */
  33. public function secureUrlDataProvider()
  34. {
  35. return [
  36. ['/account', true],
  37. ['/product', false],
  38. ['/product/12312', false],
  39. ['/cart', true],
  40. ['/cart/add', true],
  41. ['/cart/remove', false],
  42. ['/customer', false]
  43. ];
  44. }
  45. }