32 $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
33 $this->_urlBuilderMock = $this->createMock(\
Magento\Framework\UrlInterface::class);
34 $this->_requestMock = $this->createMock(\
Magento\Framework\
App\Request\Http::class);
35 $this->_defaultPathMock = $this->createMock(\
Magento\Framework\
App\DefaultPathInterface::class);
38 public function testGetUrl()
41 $url =
'http://example.com/asdasd';
43 $this->_urlBuilderMock->expects($this->once())->method(
'getUrl')->with(
$path)->will($this->returnValue(
$url));
46 $link = $this->_objectManager->getObject(
48 [
'urlBuilder' => $this->_urlBuilderMock]
52 $this->assertEquals(
$url,
$link->getHref());
55 public function testIsCurrentIfIsset()
59 $link->setCurrent(
true);
60 $this->assertTrue(
$link->isCurrent());
63 public function testIsCurrent()
66 $url =
'http://example.com/a/b';
68 $this->_requestMock->expects($this->once())->method(
'getModuleName')->will($this->returnValue(
'a'));
69 $this->_requestMock->expects($this->once())->method(
'getControllerName')->will($this->returnValue(
'b'));
70 $this->_requestMock->expects($this->once())->method(
'getActionName')->will($this->returnValue(
'd'));
71 $this->_defaultPathMock->expects($this->atLeastOnce())->method(
'getPart')->will($this->returnValue(
'd'));
73 $this->_urlBuilderMock->expects($this->at(0))->method(
'getUrl')->with(
$path)->will($this->returnValue(
$url));
74 $this->_urlBuilderMock->expects($this->at(1))->method(
'getUrl')->with(
'a/b')->will($this->returnValue(
$url));
76 $this->_requestMock->expects($this->once())->method(
'getControllerName')->will($this->returnValue(
'b'));
78 $link = $this->_objectManager->getObject(
81 'urlBuilder' => $this->_urlBuilderMock,
82 'request' => $this->_requestMock,
83 'defaultPath' => $this->_defaultPathMock
87 $this->assertTrue(
$link->isCurrent());
90 public function testIsCurrentFalse()
92 $this->_urlBuilderMock->expects($this->at(0))->method(
'getUrl')->will($this->returnValue(
'1'));
93 $this->_urlBuilderMock->expects($this->at(1))->method(
'getUrl')->will($this->returnValue(
'2'));
96 $link = $this->_objectManager->getObject(
98 [
'urlBuilder' => $this->_urlBuilderMock,
'request' => $this->_requestMock]
100 $this->assertFalse(
$link->isCurrent());