Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UrlCoderTest.php
Go to the documentation of this file.
1 <?php
7 
8 class UrlCoderTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_urlCoder;
14 
18  protected $_urlMock;
19 
23  protected $_url = 'http://example.com';
24 
28  protected $_encodeUrl = 'aHR0cDovL2V4YW1wbGUuY29t';
29 
30  protected function setUp()
31  {
32  $this->_urlMock = $this->createMock(\Magento\Framework\UrlInterface::class);
33  $this->_urlCoder = new \Magento\Framework\Encryption\UrlCoder($this->_urlMock);
34  }
35 
36  public function testDecode()
37  {
38  $this->_urlMock->expects(
39  $this->once()
40  )->method(
41  'sessionUrlVar'
42  )->with(
43  $this->_url
44  )->will(
45  $this->returnValue('expected')
46  );
47  $this->assertEquals('expected', $this->_urlCoder->decode($this->_encodeUrl));
48  }
49 
50  public function testEncode()
51  {
52  $this->assertEquals($this->_encodeUrl, $this->_urlCoder->encode($this->_url));
53  }
54 }