Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#865: add getParams/setParam to RequestInterface #1053

Merged
merged 2 commits into from
Mar 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ protected function setUp()
'getActionName',
'setModuleName',
'getModuleName',
'getCookie'
'getCookie',
'getParams',
'setParams'
]
);
$contextMock = $this->getMock('\Magento\Framework\App\Helper\Context', [], [], '', false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected function setUp()
$this->storeManagerMock = $this->getMock('Magento\Framework\Store\StoreManagerInterface');
$this->requestMock = $this->getMock(
'Magento\Framework\App\RequestInterface',
['isAjax', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie']
['isAjax', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie', 'getParams', 'setParams']
);
$this->addressFactoryMock = $this->getMock('Magento\Customer\Model\AddressFactory', [], [], '', false);
$this->formFactoryMock = $this->getMock('Magento\Customer\Model\Metadata\FormFactory', [], [], '', false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function setUp()
'getPost',
'isSecure',
'setParams',
'getParams'
];

$this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface', $requestMethods);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public function setUp()
'setModuleName',
'setControllerName',
'getCookie',
'getParams',
'setParams'
];
$this->requestMock = $this->getMock(
'Magento\Framework\App\RequestInterface',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function setUp()
$this->response = $this->getMock('Magento\Framework\App\ResponseInterface');
$this->request = $this->getMock(
'Magento\Framework\App\RequestInterface',
['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'],
['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie', 'setParams', 'getParams'],
[],
'',
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function setUp()
{
$this->request = $this->getMock(
'Magento\Framework\App\RequestInterface',
['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'],
['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie', 'getParams', 'getParams'],
[],
'',
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ protected function setUp()
'getActionName',
'setActionName',
'getParam',
'getCookie'
'getCookie',
'getParams',
'setParams'
]
)
->getMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ protected function setUp()
'getCookie',
'getRawBody',
'getMethod',
'isXmlHttpRequest'
'isXmlHttpRequest',
'getParams',
'setParams'
],
[],
'',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected function setUp()
'getActionName',
'setActionName',
'getCookie',
'setParams'
]
)
->getMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ protected function setUp()
'setModuleName',
'getActionName',
'setActionName',
'getCookie'
'getCookie',
'getParams',
'setParams'
]
);
$this->response = $this->getMock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ protected function setUp()
'setModuleName',
'getActionName',
'setActionName',
'getCookie'
'getCookie',
'getParams',
'setParams'
]
);
$this->response = $this->getMock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ protected function setUp()
'setModuleName',
'getActionName',
'setActionName',
'getCookie'
'getCookie',
'getParams',
'setParams'
]
);
$this->response = $this->getMock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ protected function setUp()
'getActionName',
'setActionName',
'getParam',
'getCookie'
'getCookie',
'getParams'
],
[],
'',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ protected function setUp()
'getCookie',
'setDispatched',
'setParams',
'setControllerName'
'setControllerName',
'getParams'
],
[],
'',
Expand Down
22 changes: 12 additions & 10 deletions dev/tests/unit/testsuite/Magento/Framework/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function getRouteParamsResolver()
protected function getRequestMock($mockMethods = [])
{
$interfaceMethods =
['getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'];
['getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie', 'getParams', 'setParams'];
return $this->getMock('Magento\Framework\App\RequestInterface', array_merge($interfaceMethods, $mockMethods));
}

Expand All @@ -118,7 +118,7 @@ protected function getUrlModel($arguments = [])
*/
public function testGetCurrentUrl($port, $url)
{
$requestMock = $this->getRequestMock(['getServer', 'getScheme', 'getHttpHost']);
$requestMock = $this->getRequestMock(['getServer', 'getScheme', 'getHttpHost', 'getParams', 'setParams']);
$requestMock->expects($this->at(0))->method('getServer')->with('SERVER_PORT')
->will($this->returnValue($port));
$requestMock->expects($this->at(1))->method('getServer')->with('REQUEST_URI')
Expand Down Expand Up @@ -182,7 +182,7 @@ public function testGetUrlValidateFilter()
*/
public function testGetUrl($query, $queryResult, $returnUri)
{
$requestMock = $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']);
$requestMock = $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias', 'getParams', 'setParams']);
$routeConfigMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface');
$model = $this->getUrlModel(
['scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(),
Expand Down Expand Up @@ -267,7 +267,7 @@ public function testGetUrlRouteUseRewrite()
{
$this->routeParamsResolverMock->expects($this->any())->method('getRouteParams')
->will($this->returnValue(['foo' => 'bar']));
$request = $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']);
$request = $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias', 'getParams', 'setParams']);
$request->expects($this->once())->method('getAlias')->will($this->returnValue('/catalog/product/view/'));
$model = $this->getUrlModel([
'scopeResolver' => $this->scopeResolverMock,
Expand Down Expand Up @@ -303,6 +303,8 @@ public function testGetUrlWithAsterisksPath()
'getRequestedRouteName',
'getRequestedControllerName',
'getRequestedActionName',
'getParams',
'setParams'
]);
$routeConfigMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface');
$model = $this->getUrlModel(
Expand Down Expand Up @@ -336,7 +338,7 @@ public function testGetUrlWithAsterisksPath()

public function testGetDirectUrl()
{
$requestMock = $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']);
$requestMock = $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias', 'getParams', 'setParams']);
$routeConfigMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface');
$model = $this->getUrlModel(
['scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(),
Expand Down Expand Up @@ -364,7 +366,7 @@ public function testGetDirectUrl()
*/
public function testGetRebuiltUrl($url)
{
$requestMock = $this->getRequestMock(['getHttpHost']);
$requestMock = $this->getRequestMock(['getHttpHost', 'getParams', 'setParams']);
$model = $this->getUrlModel([
'session' => $this->sessionMock,
'request' => $requestMock,
Expand Down Expand Up @@ -459,7 +461,7 @@ public function testAddSessionParam()
*/
public function testIsOwnOriginUrl($result, $baseUrl, $referrer)
{
$requestMock = $this->getRequestMock(['setServer', 'getServer']);
$requestMock = $this->getRequestMock(['setServer', 'getServer', 'getParams', 'setParams']);
$model = $this->getUrlModel(['scopeResolver' => $this->scopeResolverMock, 'request' => $requestMock]);

$this->scopeMock->expects($this->any())->method('getBaseUrl')->will($this->returnValue($baseUrl));
Expand Down Expand Up @@ -567,7 +569,7 @@ public function testGetConfigDataWithSecureIsForcedParam()
*/
public function testSessionUrlVarWithMatchedHostsAndBaseUrl($html, $result)
{
$requestMock = $this->getRequestMock(['getHttpHost']);
$requestMock = $this->getRequestMock(['getHttpHost', 'setParams', 'getParams']);
$model = $this->getUrlModel(
['session' => $this->sessionMock, 'request' => $requestMock, 'sidResolver' => $this->sidResolverMock,
'scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), ]
Expand All @@ -590,7 +592,7 @@ public function testSessionUrlVarWithMatchedHostsAndBaseUrl($html, $result)

public function testSessionUrlVarWithoutMatchedHostsAndBaseUrl()
{
$requestMock = $this->getRequestMock(['getHttpHost']);
$requestMock = $this->getRequestMock(['getHttpHost', 'getParams', 'setParams']);
$model = $this->getUrlModel(
['session' => $this->sessionMock, 'request' => $requestMock, 'sidResolver' => $this->sidResolverMock,
'scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), ]
Expand Down Expand Up @@ -638,7 +640,7 @@ public function sessionUrlVarWithMatchedHostsAndBaseUrlDataProvider()

public function testSetRequest()
{
$requestMethods = ['getServer', 'getScheme', 'getHttpHost'];
$requestMethods = ['getServer', 'getScheme', 'getHttpHost', 'getParams', 'setParams'];
$initRequestMock = $this->getRequestMock($requestMethods);
$requestMock = $this->getRequestMock($requestMethods);
$initRequestMock->expects($this->any())->method('getScheme')->will($this->returnValue('fake'));
Expand Down