Skip to content

Commit 94a368b

Browse files
author
Alexander Akimov
authored
Merge pull request #2228 from magento-tsg/2.2.4-develop-pr21
[TSG] Backporting for 2.2 (pr21) (2.2.4)
2 parents 0f41a15 + 070f71f commit 94a368b

File tree

2 files changed

+25
-3
lines changed
  • app/code/Magento/Backend/Model
  • dev/tests/integration/testsuite/Magento/Backend/Model

2 files changed

+25
-3
lines changed

app/code/Magento/Backend/Model/Url.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ public function getUrl($routePath = null, $routeParams = null)
211211
return $result;
212212
}
213213

214+
$this->getRouteParamsResolver()->unsetData('route_params');
214215
$this->_setRoutePath($routePath);
216+
$extraParams = $this->getRouteParamsResolver()->getRouteParams();
215217
$routeName = $this->_getRouteName('*');
216218
$controllerName = $this->_getControllerName(self::DEFAULT_CONTROLLER_NAME);
217219
$actionName = $this->_getActionName(self::DEFAULT_ACTION_NAME);
@@ -226,6 +228,10 @@ public function getUrl($routePath = null, $routeParams = null)
226228
$routeParams[self::SECRET_KEY_PARAM_NAME] = $secretKey;
227229
}
228230

231+
if (!empty($extraParams)) {
232+
$routeParams = array_merge($extraParams, $routeParams);
233+
}
234+
229235
return parent::getUrl("{$routeName}/{$controllerName}/{$actionName}", $routeParams);
230236
}
231237

dev/tests/integration/testsuite/Magento/Backend/Model/UrlTest.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,21 @@ protected function setUp()
3737
/**
3838
* App isolation is enabled to protect next tests from polluted registry by getUrl().
3939
*
40+
* @param string $routePath
4041
* @param array $requestParams
4142
* @param string $expectedResult
4243
* @param array|null $routeParams
4344
* @dataProvider getUrlDataProvider
4445
* @magentoAppIsolation enabled
4546
*/
46-
public function testGetUrl(array $requestParams, string $expectedResult, array $routeParams = null)
47-
{
47+
public function testGetUrl(
48+
string $routePath,
49+
array $requestParams,
50+
string $expectedResult,
51+
array $routeParams = null
52+
) {
4853
$this->request->setParams($requestParams);
49-
$url = $this->_model->getUrl('adminhtml/auth/login', $routeParams);
54+
$url = $this->_model->getUrl($routePath, $routeParams);
5055
$this->assertContains($expectedResult, $url);
5156
}
5257

@@ -62,10 +67,12 @@ public function getUrlDataProvider()
6267

6368
return [
6469
[
70+
'routePath' => 'adminhtml/auth/login',
6571
'requestParams' => [],
6672
'expectedResult'=> 'admin/auth/login/key/',
6773
],
6874
[
75+
'routePath' => 'adminhtml/auth/login',
6976
'requestParams' => [],
7077
'expectedResult'=> '/param1/a1==/',
7178
'routeParams' => [
@@ -74,6 +81,7 @@ public function getUrlDataProvider()
7481
],
7582
],
7683
[
84+
'routePath' => 'adminhtml/auth/login',
7785
'requestParams' => [],
7886
'expectedResult'=> '/param1/a1==/',
7987
'routeParams' => [
@@ -82,6 +90,7 @@ public function getUrlDataProvider()
8290
],
8391
],
8492
[
93+
'routePath' => 'adminhtml/auth/login',
8594
'requestParams' => ['param2' => 'a2=='],
8695
'expectedResult'=> '/param2/a2==/',
8796
'routeParams' => [
@@ -90,6 +99,7 @@ public function getUrlDataProvider()
9099
],
91100
],
92101
[
102+
'routePath' => 'adminhtml/auth/login',
93103
'requestParams' => [],
94104
'expectedResult' => '/param3/' . $escaper->encodeUrlParam('a3==') . '/',
95105
'routeParams' => [
@@ -98,13 +108,19 @@ public function getUrlDataProvider()
98108
],
99109
],
100110
[
111+
'routePath' => 'adminhtml/auth/login',
101112
'requestParams' => ['param4' => 'a4=='],
102113
'expectedResult' => '/param4/' . $escaper->encodeUrlParam('a4==') . '/',
103114
'routeParams' => [
104115
'_current' => true,
105116
'_escape_params' => true,
106117
],
107118
],
119+
[
120+
'routePath' => 'route/controller/action/id/100',
121+
'requestParams' => [],
122+
'expectedResult' => 'id/100',
123+
],
108124
];
109125
}
110126

0 commit comments

Comments
 (0)