UrlCoderTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Encryption\Test\Unit;
  7. class UrlCoderTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Framework\Encryption\UrlCoder
  11. */
  12. protected $_urlCoder;
  13. /**
  14. * @var \PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $_urlMock;
  17. /**
  18. * @var string
  19. */
  20. protected $_url = 'http://example.com';
  21. /**
  22. * @var string
  23. */
  24. protected $_encodeUrl = 'aHR0cDovL2V4YW1wbGUuY29t';
  25. protected function setUp()
  26. {
  27. $this->_urlMock = $this->createMock(\Magento\Framework\UrlInterface::class);
  28. $this->_urlCoder = new \Magento\Framework\Encryption\UrlCoder($this->_urlMock);
  29. }
  30. public function testDecode()
  31. {
  32. $this->_urlMock->expects(
  33. $this->once()
  34. )->method(
  35. 'sessionUrlVar'
  36. )->with(
  37. $this->_url
  38. )->will(
  39. $this->returnValue('expected')
  40. );
  41. $this->assertEquals('expected', $this->_urlCoder->decode($this->_encodeUrl));
  42. }
  43. public function testEncode()
  44. {
  45. $this->assertEquals($this->_encodeUrl, $this->_urlCoder->encode($this->_url));
  46. }
  47. }