@@ -57,26 +57,31 @@ public function testIsCurrentIfIsset()
57
57
/**
58
58
* Test if the current url is the same as link path
59
59
*
60
- * @dataProvider linkPathProvider
61
- * @param string $linkPath
62
- * @param string $currentPathInfo
63
- * @param bool $expected
64
60
* @return void
65
61
*/
66
- public function testIsCurrent ($ linkPath , $ currentPathInfo , $ expected )
62
+ public function testIsCurrent ()
67
63
{
68
- $ baseUrl = 'http://example.com/ ' ;
69
- $ trimmed = trim ( $ currentPathInfo , ' / ' ) ;
64
+ $ path = 'test/index ' ;
65
+ $ url = ' http://example.com/test/index ' ;
70
66
71
- $ this ->_requestMock ->expects ($ this ->any ())->method ('getPathInfo ' )->willReturn ($ currentPathInfo );
67
+ $ this ->_requestMock ->expects ($ this ->once ())
68
+ ->method ('getModuleName ' )
69
+ ->will ($ this ->returnValue ('test ' ));
70
+ $ this ->_requestMock ->expects ($ this ->once ())
71
+ ->method ('getControllerName ' )
72
+ ->will ($ this ->returnValue ('index ' ));
73
+ $ this ->_requestMock ->expects ($ this ->once ())
74
+ ->method ('getActionName ' )
75
+ ->will ($ this ->returnValue ('index ' ));
72
76
$ this ->_urlBuilderMock ->expects ($ this ->at (0 ))
73
77
->method ('getUrl ' )
74
- ->with ($ linkPath )
75
- ->will ($ this ->returnValue ($ baseUrl . $ linkPath ));
78
+ ->with ($ path )
79
+ ->will ($ this ->returnValue ($ url ));
76
80
$ this ->_urlBuilderMock ->expects ($ this ->at (1 ))
77
81
->method ('getUrl ' )
78
- ->with ($ trimmed )
79
- ->will ($ this ->returnValue ($ baseUrl . $ trimmed ));
82
+ ->with ('test/index ' )
83
+ ->will ($ this ->returnValue ($ url ));
84
+
80
85
/** @var \Magento\Framework\View\Element\Html\Link\Current $link */
81
86
$ link = $ this ->_objectManager ->getObject (
82
87
\Magento \Framework \View \Element \Html \Link \Current::class,
@@ -86,22 +91,8 @@ public function testIsCurrent($linkPath, $currentPathInfo, $expected)
86
91
]
87
92
);
88
93
89
- $ link ->setCurrent (false );
90
- $ link ->setPath ($ linkPath );
91
- $ this ->assertEquals ($ expected , $ link ->isCurrent ());
92
- }
93
-
94
- /**
95
- * @return array
96
- */
97
- public function linkPathProvider ()
98
- {
99
- return [
100
- ['test/index ' , '/test/index/ ' , true ],
101
- ['test/index/index ' , '/test/index/index/ ' , true ],
102
- ['test/route ' , '/test/index/ ' , false ],
103
- ['test/index ' , '/test/ ' , false ]
104
- ];
94
+ $ link ->setPath ($ path );
95
+ $ this ->assertTrue ($ link ->isCurrent ());
105
96
}
106
97
107
98
public function testIsCurrentFalse ()
0 commit comments