diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php index 3b9f810fb4512..b0fc84e6db46a 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php @@ -17,9 +17,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = new \Magento\TestFramework\Request( - $this->getMock('Magento\Framework\App\Route\ConfigInterface\Proxy', [], [], '', false), - $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface', [], [], '', false), $this->getMock('Magento\Framework\Stdlib\Cookie\CookieReaderInterface'), + $this->getMock('Magento\Framework\App\Route\ConfigInterface\Proxy', [], [], '', false), + $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface'), $this->getMock('Magento\Framework\ObjectManagerInterface') ); } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php index 55fde7a3cf543..f8d7b83b9dd7c 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php @@ -19,9 +19,9 @@ protected function setUp() { $this->messageManager = $this->getMock('\Magento\Framework\Message\Manager', [], [], '', false); $request = new \Magento\TestFramework\Request( - $this->getMock('Magento\Framework\App\Route\ConfigInterface\Proxy', [], [], '', false), - $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface', [], [], '', false), $this->getMock('Magento\Framework\Stdlib\Cookie\CookieReaderInterface'), + $this->getMock('Magento\Framework\App\Route\ConfigInterface\Proxy', [], [], '', false), + $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface'), $this->getMock('Magento\Framework\ObjectManagerInterface') ); $response = new \Magento\TestFramework\Response( diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index f48b7d26e1c5e..ae92f80739245 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -2087,7 +2087,6 @@ ['getFiles', 'Magento\Framework\App\Request\Http'], ['getAlias', 'Magento\Framework\App\Request\Http', 'Magento\Framework\HTTP\PhpEnvironment\Request'], ['setAlias', 'Magento\Framework\App\Request\Http', 'Magento\Framework\HTTP\PhpEnvironment\Request'], - ['getParam', 'Magento\Framework\App\RequestInterface'], [ 'render', 'Magento\Framework\Webapi\ErrorProcessor', diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php index c5e1208b47ac3..a476abeb5353e 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php @@ -27,7 +27,7 @@ class SaveTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject */ protected $context; - /** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $request; /** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject */ @@ -150,13 +150,8 @@ protected function prepareContext() ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMock( - 'Magento\Framework\App\RequestInterface', - ['getParam', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getCookie', 'isSecure'], - [], - '', - false - ); + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); $this->eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php index e08309c1cf9db..9c311292c10b2 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php @@ -51,21 +51,8 @@ class CartTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMock( - '\Magento\Framework\App\RequestInterface', - [ - 'getRouteName', - 'getControllerName', - 'getParam', - 'setActionName', - 'getActionName', - 'setModuleName', - 'getModuleName', - 'getCookie', - 'isAjax', - 'isSecure', - ] - ); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); /** @var \Magento\Framework\App\Helper\Context $context */ $context = $objectManagerHelper->getObject( diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php index e7975a3071b89..d637676a1d845 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php @@ -43,7 +43,7 @@ class OnepageTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; - /** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $requestMock; /** @var \PHPUnit_Framework_MockObject_MockObject */ @@ -132,19 +132,8 @@ protected function setUp() false ); $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') - ->setMethods([ - 'isAjax', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'isSecure', - ]) - ->getMock(); - + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->addressFactoryMock = $this->getMock('Magento\Customer\Model\AddressFactory', [], [], '', false); $this->formFactoryMock = $this->getMock('Magento\Customer\Model\Metadata\FormFactory', [], [], '', false); $this->customerFactoryMock = $this->getMock('Magento\Customer\Model\CustomerFactory', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreateTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreateTest.php index 90500dec18685..2a10341c6a3f2 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreateTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreateTest.php @@ -63,18 +63,8 @@ protected function setUp() $this->registrationMock = $this->getMock('\Magento\Customer\Model\Registration', [], [], '', false); $this->redirectMock = $this->getMock('Magento\Framework\App\Response\RedirectInterface'); $this->response = $this->getMock('Magento\Framework\App\ResponseInterface'); - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') - ->setMethods([ - 'isPost', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'isSecure', - ]) - ->getMock(); + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->redirectResultMock = $this->getMock('Magento\Framework\Controller\Result\Redirect', [], [], '', false); $this->redirectFactoryMock = $this->getMock( diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/LoginPostTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/LoginPostTest.php index b855334c37648..2ee2813391650 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/LoginPostTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/LoginPostTest.php @@ -22,7 +22,7 @@ class LoginPostTest extends \PHPUnit_Framework_TestCase protected $object; /** - * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $request; @@ -98,18 +98,8 @@ class LoginPostTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') - ->setMethods([ - 'isPost', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'isSecure', - ]) - ->getMock(); + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->response = $this->getMock( 'Magento\Framework\App\ResponseInterface', ['setRedirect', 'sendResponse'], diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/IndexTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/IndexTest.php index 99cfb8635e1e1..39fa7b006bd74 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/IndexTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/IndexTest.php @@ -21,7 +21,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase protected $context; /** - * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Request|\PHPUnit_Framework_MockObject_MockObject */ protected $requestMock; @@ -62,20 +62,8 @@ class IndexTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') - ->setMethods( - [ - 'getQuery', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'isSecure', - ] - ) - ->getMock(); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') ->disableOriginalConstructor() ->setMethods(['create']) diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Ajax/LoginTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Ajax/LoginTest.php index 0d742c0e5cfc7..0b655312dff85 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Ajax/LoginTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Ajax/LoginTest.php @@ -21,7 +21,7 @@ class LoginTest extends \PHPUnit_Framework_TestCase protected $object; /** - * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $request; @@ -67,21 +67,8 @@ class LoginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') - ->setMethods([ - 'isPost', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'getContent', - 'getMethod', - 'isXmlHttpRequest', - 'isSecure', - ]) - ->getMock(); + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->response = $this->getMock( 'Magento\Framework\App\ResponseInterface', ['setRedirect', 'sendResponse', 'representJson', 'setHttpResponseCode'], diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php index 533a78ed59499..9d6e3d0316874 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php @@ -21,7 +21,7 @@ class FileTest extends AbstractFormTestCase /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Filesystem */ protected $fileSystemMock; - /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\RequestInterface */ + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\Request\Http */ protected $requestMock; /** @@ -38,20 +38,8 @@ protected function setUp() ->disableOriginalConstructor()->getMock(); $this->fileSystemMock = $this->getMockBuilder('Magento\Framework\Filesystem') ->disableOriginalConstructor()->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') - ->setMethods( - [ - 'getParam', - 'getParams', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getCookie', - 'isSecure', - ] - ) - ->getMock(); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->uploaderFactoryMock = $this->getMock('Magento\Framework\File\UploaderFactory', [], [], '', false); } diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php index 4062acc756834..fdc2f5b67190d 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php @@ -66,9 +66,6 @@ public function testMatch( ) { $this->_model = $this->_prepareMocksForTestMatch($request, $isVde, $isLoggedIn, $routers); $this->assertEquals($matchedValue, $this->_model->match($request)); - if ($isVde && $isLoggedIn) { - $this->assertEquals(self::TEST_PATH, $request->getPathInfo()); - } } /** @@ -79,30 +76,26 @@ public function testMatch( */ public function matchDataProvider() { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); $this->_cookieReaderMock = $this->getMock('Magento\Framework\Stdlib\Cookie\CookieReaderInterface'); - $uri = self::TEST_HOST . '/' . self::VDE_FRONT_NAME . self::TEST_PATH; - $notVdeUrl = self::TEST_HOST . self::TEST_PATH; + $vdePath = '/' . self::VDE_FRONT_NAME . self::TEST_PATH; + $notVdePath = self::TEST_PATH; $excludedRouters = ['admin' => 'admin router', 'vde' => 'vde router']; - $routerListMock = $this->getMock( - '\Magento\Framework\App\Route\ConfigInterface\Proxy', - [], - [], - '', - false - ); - $infoProcessorMock = $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface'); $infoProcessorMock->expects($this->any())->method('process')->will($this->returnArgument(1)); // test data to verify routers match logic - $matchedRequest = $this->getMock( - 'Magento\Framework\App\Request\Http', - ['_isFrontArea'], - [$routerListMock, $infoProcessorMock, $this->_cookieReaderMock, $objectManagerMock, $uri] - ); + $notVdeRequest = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); + $notVdeRequest->expects($this->any()) + ->method('getPathInfo') + ->willReturn($vdePath); + $vdeRequest = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); + $vdeRequest->expects($this->any()) + ->method('getPathInfo') + ->willReturn($notVdePath); $matchedController = $this->getMockForAbstractClass( 'Magento\Framework\App\Action\AbstractAction', @@ -118,13 +111,13 @@ public function matchDataProvider() )->method( 'match' )->with( - $matchedRequest + $notVdeRequest )->will( $this->returnValue($matchedController) ); $matchedRouter->expects($this->once()) ->method('match') - ->with($matchedRequest) + ->with($notVdeRequest) ->will($this->returnValue($matchedController)); // method "match" will not be invoked for this router because controller will be found by first router @@ -138,39 +131,23 @@ public function matchDataProvider() $routers = [ 'not vde request' => [ - '$request' => $this->getMock( - 'Magento\Framework\App\Request\Http', ['_isFrontArea'], [ - $routerListMock, - $infoProcessorMock, - $this->_cookieReaderMock, - $objectManagerMock, - $notVdeUrl - ] - ), + '$request' => $vdeRequest, '$isVde' => false, '$isLoggedIn' => true, ], 'not logged as admin' => [ - '$request' => $this->getMock( - 'Magento\Framework\App\Request\Http', - ['_isFrontArea'], - [$routerListMock, $infoProcessorMock, $this->_cookieReaderMock, $objectManagerMock, $uri] - ), + '$request' => $notVdeRequest, '$isVde' => true, '$isLoggedIn' => false, ], 'no matched routers' => [ - '$request' => $this->getMock( - 'Magento\Framework\App\Request\Http', - ['_isFrontArea'], - [$routerListMock, $infoProcessorMock, $this->_cookieReaderMock, $objectManagerMock, $uri] - ), + '$request' => $notVdeRequest, '$isVde' => true, '$isLoggedIn' => true, '$routers' => $excludedRouters ], 'matched routers' => [ - '$request' => $matchedRequest, + '$request' => $notVdeRequest, '$isVde' => true, '$isLoggedIn' => true, '$routers' => $matchedRouters, diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php index f050a148bb391..7fad943e88c27 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php @@ -17,7 +17,7 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected $objectManagerHelper; /** - * @var \Magento\Framework\App\RequestInterface + * @var \Magento\Framework\App\Request\Http */ protected $request; @@ -50,18 +50,8 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->request = $this->getMock( - 'Magento\Framework\App\RequestInterface', - [ - 'getParam', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getCookie', - 'isSecure', - ] - ); + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->response = $this->getMock( '\Magento\Framework\App\ResponseInterface', [ diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php index e6d21a7bb4b6c..49a3f8ad5218d 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php @@ -17,7 +17,7 @@ class SampleTest extends \PHPUnit_Framework_TestCase protected $objectManagerHelper; /** - * @var \Magento\Framework\App\RequestInterface + * @var \Magento\Framework\App\Request\Http */ protected $request; @@ -50,18 +50,8 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->request = $this->getMock( - 'Magento\Framework\App\RequestInterface', - [ - 'getParam', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getCookie', - 'isSecure', - ] - ); + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->response = $this->getMock( '\Magento\Framework\App\ResponseInterface', [ diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Download/LinkTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Download/LinkTest.php index 5a18bd5bf5c9f..3f3450b2d7e81 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Download/LinkTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Download/LinkTest.php @@ -16,7 +16,7 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected $objectManagerHelper; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\RequestInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Request\Http */ protected $request; @@ -82,18 +82,8 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->request = $this->getMock( - 'Magento\Framework\App\RequestInterface', - [ - 'getParam', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getCookie', - 'isSecure', - ] - ); + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->response = $this->getMock( '\Magento\Framework\App\ResponseInterface', [ diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Action/ActionTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Action/ActionTest.php index 96a8d0ddde938..7ac97cc2deda4 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Action/ActionTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Action/ActionTest.php @@ -19,7 +19,7 @@ class ActionTest extends \PHPUnit_Framework_TestCase protected $objectManagerHelper; /** - * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $_requestMock; @@ -85,28 +85,8 @@ protected function setUp() $this->_eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); $this->_actionFlagMock = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false); $this->_redirectMock = $this->getMock('Magento\Framework\App\Response\RedirectInterface', [], [], '', false); - $this->_requestMock = $this->getMock( - 'Magento\Framework\App\RequestInterface', - [ - 'getFullActionName', - 'getRouteName', - 'isDispatched', - 'initForward', - 'setParams', - 'setControllerName', - 'setDispatched', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'isSecure', - ], - [], - '', - false - ); + $this->_requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->_responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); $this->pageConfigMock = $this->getMock('Magento\Framework\View\Page\Config', ['getConfig'], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Request/HttpTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Request/HttpTest.php index 51d74829500bc..82b7d73755261 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Request/HttpTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Request/HttpTest.php @@ -28,11 +28,6 @@ class HttpTest extends \PHPUnit_Framework_TestCase */ protected $_infoProcessorMock; - /** - * @var \Magento\Framework\Stdlib\Cookie\CookieReaderInterface | \PHPUnit_Framework_MockObject_MockObject - */ - protected $cookieReaderMock; - /** * @var \Magento\TestFramework\Helper\ObjectManager | \PHPUnit_Framework_MockObject_MockObject */ @@ -55,7 +50,6 @@ protected function setUp() ); $this->_infoProcessorMock = $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface'); $this->_infoProcessorMock->expects($this->any())->method('process')->will($this->returnArgument(1)); - $this->cookieReaderMock = $this->getMock('Magento\Framework\Stdlib\Cookie\CookieReaderInterface'); $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); // Stash the $_SERVER array to protect it from modification in test @@ -67,14 +61,20 @@ public function tearDown() $_SERVER = $this->serverArray; } + /** + * @return \Magento\Framework\App\Request\Http + */ private function getModel($uri = null) { - return new \Magento\Framework\App\Request\Http( - $this->_routerListMock, - $this->_infoProcessorMock, - $this->cookieReaderMock, - $this->objectManager, - $uri + $testFrameworkObjectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + return $testFrameworkObjectManager->getObject( + 'Magento\Framework\App\Request\Http', + [ + 'routeConfig' => $this->_routerListMock, + 'pathInfoProcessor' => $this->_infoProcessorMock, + 'objectManager' => $this->objectManager, + 'uri' => $uri, + ] ); } @@ -255,48 +255,6 @@ public function getDistroBaseUrlPathDataProvider() ]; } - public function testGetCookieDefault() - { - $key = "cookieName"; - $default = "defaultValue"; - - $this->cookieReaderMock - ->expects($this->once()) - ->method('getCookie') - ->with($key, $default) - ->will($this->returnValue($default)); - - $this->assertEquals($default, $this->getModel()->getCookie($key, $default)); - } - - public function testGetCookieNameExists() - { - $key = "cookieName"; - $default = "defaultValue"; - $value = "cookieValue"; - - $this->cookieReaderMock - ->expects($this->once()) - ->method('getCookie') - ->with($key, $default) - ->will($this->returnValue($value)); - - $this->assertEquals($value, $this->getModel()->getCookie($key, $default)); - } - - public function testGetCookieNullName() - { - $nullKey = null; - $default = "defaultValue"; - - $this->cookieReaderMock - ->expects($this->once()) - ->method('getCookie') - ->with($nullKey, $default) - ->will($this->returnValue($default)); - - $this->assertEquals($default, $this->getModel()->getCookie($nullKey, $default)); - } public function serverVariablesProvider() { diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Router/BaseTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Router/BaseTest.php index 5d2b90f5ab961..82ff2cfda586f 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Router/BaseTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Router/BaseTest.php @@ -15,7 +15,7 @@ class BaseTest extends \Magento\Test\BaseTestCase private $model; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\RequestInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Request\Http */ private $requestMock; @@ -53,26 +53,7 @@ public function setUp() { parent::setUp(); // Create mocks - $requestMethods = [ - 'getActionName', - 'getModuleName', - 'getParam', - 'setActionName', - 'setModuleName', - 'setRouteName', - 'getPathInfo', - 'getControllerName', - 'setControllerName', - 'setControllerModule', - 'setAlias', - 'getCookie', - 'getOriginalPathInfo', - 'getPostValue', - 'isSecure', - 'setParams', - ]; - - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface', $requestMethods); + $this->requestMock = $this->basicMock('Magento\Framework\App\Request\Http'); $this->routeConfigMock = $this->basicMock('Magento\Framework\App\Route\ConfigInterface'); $this->appStateMock = $this->basicMock('Magento\Framework\App\State'); $this->actionListMock = $this->basicMock('Magento\Framework\App\Router\ActionList'); diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Router/NoRouteHandlerTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Router/NoRouteHandlerTest.php index a4e4da533f5e2..152e1f06084b6 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Router/NoRouteHandlerTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Router/NoRouteHandlerTest.php @@ -23,7 +23,7 @@ class NoRouteHandlerTest extends \Magento\Test\BaseTestCase private $configMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\RequestInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Request\Http */ private $requestMock; @@ -31,20 +31,7 @@ public function setUp() { parent::setUp(); $this->configMock = $this->basicMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $requestMethods = [ - 'getActionName', - 'getModuleName', - 'getParam', - 'setActionName', - 'setModuleName', - 'setControllerName', - 'getCookie', - 'isSecure', - ]; - $this->requestMock = $this->getMock( - 'Magento\Framework\App\RequestInterface', - $requestMethods - ); + $this->requestMock = $this->basicMock('Magento\Framework\App\Request\Http'); $this->model = $this->objectManager->getObject('Magento\Framework\App\Router\NoRouteHandler', [ 'config' => $this->configMock, diff --git a/dev/tests/unit/testsuite/Magento/Framework/Controller/Result/ForwardTest.php b/dev/tests/unit/testsuite/Magento/Framework/Controller/Result/ForwardTest.php index 857a9d000a916..3eec4c336d046 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Controller/Result/ForwardTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Controller/Result/ForwardTest.php @@ -13,7 +13,7 @@ class ForwardTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Controller\Result\Forward */ protected $forward; - /** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $requestInterface; /** @var ObjectManagerHelper */ @@ -23,25 +23,8 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->requestInterface = $this->getMock( - 'Magento\Framework\App\RequestInterface', - [ - 'initForward', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'setDispatched', - 'setParams', - 'setControllerName', - 'isSecure', - ], - [], - '', - false - ); + $this->requestInterface = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->forward = $this->objectManagerHelper->getObject( 'Magento\Framework\Controller\Result\Forward', [ diff --git a/dev/tests/unit/testsuite/Magento/Framework/HTTP/PhpEnvironment/RequestTest.php b/dev/tests/unit/testsuite/Magento/Framework/HTTP/PhpEnvironment/RequestTest.php index 437bcd0fbc28c..33326fcdb23e6 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/HTTP/PhpEnvironment/RequestTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/HTTP/PhpEnvironment/RequestTest.php @@ -19,6 +19,11 @@ class RequestTest extends \PHPUnit_Framework_TestCase */ protected $objectManager; + /** + * @var \Magento\Framework\Stdlib\Cookie\CookieReaderInterface | \PHPUnit_Framework_MockObject_MockObject + */ + private $cookieReader; + /** * @var array */ @@ -27,7 +32,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); - + $this->cookieReader = $this->getMock('Magento\Framework\Stdlib\Cookie\CookieReaderInterface'); // Stash the $_SERVER array to protect it from modification in test $this->serverArray = $_SERVER; } @@ -39,7 +44,7 @@ public function tearDown() private function getModel($uri = null) { - return new Request($uri); + return new Request($this->cookieReader, $uri); } public function testSetPathInfoWithNullValue() @@ -199,4 +204,62 @@ public function testGetAliasWhenAliasAreEmpty() $this->model = $this->getModel(); $this->assertNull($this->model->getAlias('')); } + + + public function testGetCookie() + { + $key = "cookieName"; + $default = "defaultValue"; + + $this->cookieReader + ->expects($this->once()) + ->method('getCookie') + ->with($key, $default); + + $this->getModel()->getCookie($key, $default); + } + + + public function testGetCookieDefault() + { + $key = "cookieName"; + $default = "defaultValue"; + + $this->cookieReader + ->expects($this->once()) + ->method('getCookie') + ->with($key, $default) + ->will($this->returnValue($default)); + + $this->assertEquals($default, $this->getModel()->getCookie($key, $default)); + } + + public function testGetCookieNameExists() + { + $key = "cookieName"; + $default = "defaultValue"; + $value = "cookieValue"; + + $this->cookieReader + ->expects($this->once()) + ->method('getCookie') + ->with($key, $default) + ->will($this->returnValue($value)); + + $this->assertEquals($value, $this->getModel()->getCookie($key, $default)); + } + + public function testGetCookieNullName() + { + $nullKey = null; + $default = "defaultValue"; + + $this->cookieReader + ->expects($this->once()) + ->method('getCookie') + ->with($nullKey, $default) + ->will($this->returnValue($default)); + + $this->assertEquals($default, $this->getModel()->getCookie($nullKey, $default)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/UrlTest.php b/dev/tests/unit/testsuite/Magento/Framework/UrlTest.php index 6f2dedc362663..870ea1d702684 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/UrlTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/UrlTest.php @@ -91,13 +91,12 @@ protected function getRouteParamsResolver() /** * @param array $mockMethods - * @return \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + * @return \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ - protected function getRequestMock($mockMethods = []) + protected function getRequestMock() { - $interfaceMethods = - ['getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie', 'isSecure']; - return $this->getMock('Magento\Framework\App\RequestInterface', array_merge($interfaceMethods, $mockMethods)); + return $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); } /** @@ -118,7 +117,7 @@ protected function getUrlModel($arguments = []) */ public function testGetCurrentUrl($port, $url) { - $requestMock = $this->getRequestMock(['getServer', 'getScheme', 'getHttpHost']); + $requestMock = $this->getRequestMock(); $requestMock->expects($this->at(0))->method('getServer')->with('SERVER_PORT') ->will($this->returnValue($port)); $requestMock->expects($this->at(1))->method('getServer')->with('REQUEST_URI') @@ -182,7 +181,7 @@ public function testGetUrlValidateFilter() */ public function testGetUrl($query, $queryResult, $returnUri) { - $requestMock = $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']); + $requestMock = $this->getRequestMock(); $routeConfigMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface'); $model = $this->getUrlModel( ['scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), @@ -235,7 +234,7 @@ public function testGetUrlIdempotentSetRouteName() $model = $this->getUrlModel([ 'scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), - 'request' => $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']), + 'request' => $this->getRequestMock() ]); $model->setData('route_name', 'catalog'); @@ -253,7 +252,7 @@ public function testGetUrlRouteHasParams() $model = $this->getUrlModel([ 'scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), - 'request' => $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']), + 'request' => $this->getRequestMock() ]); $this->scopeResolverMock->expects($this->any()) @@ -267,7 +266,7 @@ public function testGetUrlRouteUseRewrite() { $this->routeParamsResolverMock->expects($this->any())->method('getRouteParams') ->will($this->returnValue(['foo' => 'bar'])); - $request = $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']); + $request = $this->getRequestMock(); $request->expects($this->once())->method('getAlias')->will($this->returnValue('/catalog/product/view/')); $model = $this->getUrlModel([ 'scopeResolver' => $this->scopeResolverMock, @@ -297,12 +296,7 @@ public function getUrlDataProvider() public function testGetUrlWithAsterisksPath() { - $requestMock = $this->getRequestMock([ - 'isDirectAccessFrontendName', - 'getAlias', - 'getRouteName', - 'getControllerName', - ]); + $requestMock = $this->getRequestMock(); $routeConfigMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface'); $model = $this->getUrlModel( ['scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), @@ -335,7 +329,7 @@ public function testGetUrlWithAsterisksPath() public function testGetDirectUrl() { - $requestMock = $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']); + $requestMock = $this->getRequestMock(); $routeConfigMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface'); $model = $this->getUrlModel( ['scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), @@ -363,7 +357,7 @@ public function testGetDirectUrl() */ public function testGetRebuiltUrl($url) { - $requestMock = $this->getRequestMock(['getHttpHost']); + $requestMock = $this->getRequestMock(); $model = $this->getUrlModel([ 'session' => $this->sessionMock, 'request' => $requestMock, @@ -458,7 +452,7 @@ public function testAddSessionParam() */ public function testIsOwnOriginUrl($result, $baseUrl, $referrer) { - $requestMock = $this->getRequestMock(['setServer', 'getServer']); + $requestMock = $this->getRequestMock(); $model = $this->getUrlModel(['scopeResolver' => $this->scopeResolverMock, 'request' => $requestMock]); $this->scopeMock->expects($this->any())->method('getBaseUrl')->will($this->returnValue($baseUrl)); @@ -566,7 +560,7 @@ public function testGetConfigDataWithSecureIsForcedParam() */ public function testSessionUrlVarWithMatchedHostsAndBaseUrl($html, $result) { - $requestMock = $this->getRequestMock(['getHttpHost']); + $requestMock = $this->getRequestMock(); $model = $this->getUrlModel( ['session' => $this->sessionMock, 'request' => $requestMock, 'sidResolver' => $this->sidResolverMock, 'scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), ] @@ -589,7 +583,7 @@ public function testSessionUrlVarWithMatchedHostsAndBaseUrl($html, $result) public function testSessionUrlVarWithoutMatchedHostsAndBaseUrl() { - $requestMock = $this->getRequestMock(['getHttpHost']); + $requestMock = $this->getRequestMock(); $model = $this->getUrlModel( ['session' => $this->sessionMock, 'request' => $requestMock, 'sidResolver' => $this->sidResolverMock, 'scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), ] @@ -637,9 +631,8 @@ public function sessionUrlVarWithMatchedHostsAndBaseUrlDataProvider() public function testSetRequest() { - $requestMethods = ['getServer', 'getScheme', 'getHttpHost']; - $initRequestMock = $this->getRequestMock($requestMethods); - $requestMock = $this->getRequestMock($requestMethods); + $initRequestMock = $this->getRequestMock(); + $requestMock = $this->getRequestMock(); $initRequestMock->expects($this->any())->method('getScheme')->will($this->returnValue('fake')); $initRequestMock->expects($this->any())->method('getHttpHost')->will($this->returnValue('fake-host')); $requestMock->expects($this->any())->method('getScheme')->will($this->returnValue('http')); diff --git a/dev/tests/unit/testsuite/Magento/Framework/Webapi/RequestTest.php b/dev/tests/unit/testsuite/Magento/Framework/Webapi/RequestTest.php deleted file mode 100644 index a97bfa7d14d22..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Framework/Webapi/RequestTest.php +++ /dev/null @@ -1,49 +0,0 @@ -cookieReader = $this->getMock('Magento\Framework\Stdlib\Cookie\CookieReaderInterface'); - - $this->request = $objectManager->getObject( - 'Magento\Framework\Webapi\Request', - ['cookieReader' => $this->cookieReader] - ); - } - - public function testGetCookie() - { - $key = "cookieName"; - $default = "defaultValue"; - - $this->cookieReader - ->expects($this->once()) - ->method('getCookie') - ->with($key, $default); - - $this->request->getCookie($key, $default); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Webapi/Rest/RequestTest.php b/dev/tests/unit/testsuite/Magento/Framework/Webapi/Rest/RequestTest.php index c49d0518da8b1..6869243b7317c 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Webapi/Rest/RequestTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Webapi/Rest/RequestTest.php @@ -41,7 +41,7 @@ protected function setUp() $this->_request = $this->getMock( 'Magento\Framework\Webapi\Rest\Request', ['getHeader', 'getMethod', 'isGet', 'isPost', 'isPut', 'isDelete', 'getContent'], - [$areaListMock, $configScopeMock, $this->_cookieManagerMock, $this->_deserializerFactory, ] + [$this->_cookieManagerMock, $areaListMock, $configScopeMock, $this->_deserializerFactory, ] ); parent::setUp(); diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Block/JavascriptTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Block/JavascriptTest.php index 208cfec820e07..09a38c0194f22 100644 --- a/dev/tests/unit/testsuite/Magento/PageCache/Block/JavascriptTest.php +++ b/dev/tests/unit/testsuite/Magento/PageCache/Block/JavascriptTest.php @@ -48,18 +48,6 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') - ->disableOriginalConstructor() - ->setMethods( - [ - 'isSecure', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie' - ] - ) ->getMock(); $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') ->disableOriginalConstructor() diff --git a/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php b/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php index 060f75aa0a197..baf85e570580a 100644 --- a/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php +++ b/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php @@ -117,20 +117,9 @@ protected function setUp() */ protected function _prepareMockObjects() { - $requestMethods = [ - 'getPostValue', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'isSecure', - ]; $this->_registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $this->_requestMock = $this->getMock( - '\Magento\Framework\App\RequestInterface', $requestMethods - ); + $this->_requestMock = $this->getMockBuilder('\Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->_responseMock = $this->getMock( '\Magento\Framework\App\ResponseInterface', ['setRedirect', 'sendResponse'] ); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/EmailTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/EmailTest.php index 038ffac7db25a..20987ebf30028 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/EmailTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/EmailTest.php @@ -27,7 +27,7 @@ class EmailTest extends \PHPUnit_Framework_TestCase protected $context; /** - * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $request; @@ -98,18 +98,8 @@ public function setUp() false ); - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') - ->setMethods([ - 'isPost', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'isSecure', - ]) - ->getMock(); + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->objectManager = $this->getMock( 'Magento\Framework\ObjectManager\ObjectManager', ['create'], diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php index de383d870ecf4..7aeee4269ac17 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php @@ -32,7 +32,7 @@ class EmailTest extends \PHPUnit_Framework_TestCase protected $resultRedirect; /** - * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $request; @@ -99,18 +99,8 @@ public function setUp() '', false ); - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') - ->setMethods([ - 'isPost', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'isSecure', - ]) - ->getMock(); + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->objectManager = $this->getMock( 'Magento\Framework\ObjectManager\ObjectManager', ['create'], diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddTrackTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddTrackTest.php index da99f5ed211d3..f3e472a06a862 100644 --- a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddTrackTest.php +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddTrackTest.php @@ -33,7 +33,7 @@ class AddTrackTest extends \PHPUnit_Framework_TestCase protected $context; /** - * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $request; @@ -95,23 +95,8 @@ public function setUp() '', false ); - $this->request = $this->getMock( - 'Magento\Framework\App\RequestInterface', - [ - 'isPost', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getPost', - 'getCookie', - 'isSecure', - ], - [], - '', - false - ); + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->objectManager = $this->getMock( 'Magento\Framework\ObjectManager\ObjectManager', ['create', 'get'], @@ -193,9 +178,9 @@ public function testExecute() ->will( $this->returnValueMap( [ - ['carrier', $carrier], - ['number', $number], - ['title', $title], + ['carrier', null, $carrier], + ['number', null, $number], + ['title', null, $title], ] ) ); diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewActionTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewActionTest.php index fbba3a450175f..fb071c76c3daf 100644 --- a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewActionTest.php +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewActionTest.php @@ -32,7 +32,7 @@ class NewActionTest extends \PHPUnit_Framework_TestCase protected $context; /** - * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $request; @@ -126,18 +126,8 @@ public function setUp() '', false ); - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') - ->setMethods([ - 'isPost', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'isSecure', - ]) - ->getMock(); + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->messageManager = $this->getMock( 'Magento\Framework\Message\Manager', ['addSuccess', 'addError'], diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/SaveTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/SaveTest.php index 3cfd2c126a6a4..667566ccb8c55 100644 --- a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/SaveTest.php +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/SaveTest.php @@ -39,7 +39,7 @@ class SaveTest extends \PHPUnit_Framework_TestCase protected $context; /** - * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $request; @@ -111,18 +111,8 @@ public function setUp() '', false ); - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') - ->setMethods([ - 'isPost', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'isSecure', - ]) - ->getMock(); + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->objectManager = $this->getMock( 'Magento\Framework\ObjectManager\ObjectManager', ['create', 'get'], diff --git a/dev/tests/unit/testsuite/Magento/Store/App/Request/PathInfoProcessorTest.php b/dev/tests/unit/testsuite/Magento/Store/App/Request/PathInfoProcessorTest.php index 9ed20be85150a..ebb91ba2cfde6 100644 --- a/dev/tests/unit/testsuite/Magento/Store/App/Request/PathInfoProcessorTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/App/Request/PathInfoProcessorTest.php @@ -29,19 +29,8 @@ class PathInfoProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_requestMock = $this->getMock( - 'Magento\Framework\App\RequestInterface', - [ - 'isDirectAccessFrontendName', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'isSecure', - ] - ); + $this->_requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->_storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManager', [], [], '', false); $this->_model = new \Magento\Store\App\Request\PathInfoProcessor($this->_storeManagerMock); } diff --git a/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php b/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php index e868c9ed34438..fd97585bb572c 100644 --- a/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php @@ -46,19 +46,8 @@ class RedirectTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_requestMock = $this->getMock( - 'Magento\Framework\App\RequestInterface', - [ - 'getServer', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getCookie', - 'isSecure', - ] - ); + $this->_requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); $this->_storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); $this->_urlCoderMock = $this->getMock( '\Magento\Framework\Encryption\UrlCoder', diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Controller/WishlistProviderTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Controller/WishlistProviderTest.php index 729dcfcf4d56c..a4468402514c0 100644 --- a/dev/tests/unit/testsuite/Magento/Wishlist/Controller/WishlistProviderTest.php +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Controller/WishlistProviderTest.php @@ -41,13 +41,7 @@ public function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->request = $this->getMock( - '\Magento\Framework\App\RequestInterface', - ['getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getCookie', 'getParam', 'isSecure'], - [], - '', - false - ); + $this->request = $this->getMock('Magento\Framework\App\RequestInterface'); $this->wishlistFactory = $this->getMock( '\Magento\Wishlist\Model\WishlistFactory', diff --git a/lib/internal/Magento/Framework/App/Console/Request.php b/lib/internal/Magento/Framework/App/Console/Request.php index 6d229f22f74e3..6caa41fdc17b5 100644 --- a/lib/internal/Magento/Framework/App/Console/Request.php +++ b/lib/internal/Magento/Framework/App/Console/Request.php @@ -19,18 +19,7 @@ class Request implements \Magento\Framework\App\RequestInterface */ public function __construct(array $parameters = []) { - $this->setParams($parameters); - } - - /** - * Initialize console parameters - * - * @param array $parameters - * @return void - */ - public function setParams(array $parameters) - { - $this->params = getopt(null, $parameters); + $this->setParams(getopt(null, $parameters)); } /** @@ -88,6 +77,28 @@ public function getParam($key, $defaultValue = null) return $defaultValue; } + /** + * Retrieve all params as array + * + * @return array + */ + public function getParams() + { + return $this->params; + } + + /** + * Set params from key value array + * + * @param array $data + * @return $this + */ + public function setParams(array $data) + { + $this->params = $data; + return $this; + } + /** * Stub to satisfy RequestInterface * diff --git a/lib/internal/Magento/Framework/App/Request/Http.php b/lib/internal/Magento/Framework/App/Request/Http.php index 639a82f3d81ff..841922d5aa122 100644 --- a/lib/internal/Magento/Framework/App/Request/Http.php +++ b/lib/internal/Magento/Framework/App/Request/Http.php @@ -71,37 +71,31 @@ class Http extends Request implements RequestInterface */ protected $pathInfoProcessor; - /** - * @var CookieReaderInterface - */ - protected $cookieReader; - /** * @var ObjectManagerInterface */ protected $objectManager; /** + * @param CookieReaderInterface $cookieReader * @param ConfigInterface $routeConfig * @param PathInfoProcessorInterface $pathInfoProcessor - * @param CookieReaderInterface $cookieReader - * @param ObjectManagerInterface $objectManager, + * @param ObjectManagerInterface $objectManager * @param string|null $uri * @param array $directFrontNames */ public function __construct( + CookieReaderInterface $cookieReader, ConfigInterface $routeConfig, PathInfoProcessorInterface $pathInfoProcessor, - CookieReaderInterface $cookieReader, ObjectManagerInterface $objectManager, $uri = null, $directFrontNames = [] ) { + parent::__construct($cookieReader, $uri); $this->routeConfig = $routeConfig; $this->pathInfoProcessor = $pathInfoProcessor; - $this->cookieReader = $cookieReader; $this->objectManager = $objectManager; - parent::__construct($uri); $this->directFrontNames = $directFrontNames; } @@ -373,18 +367,6 @@ public function __sleep() return []; } - /** - * Retrieve a value from a cookie. - * - * @param string|null $name - * @param string|null $default The default value to return if no value could be found for the given $name. - * @return string|null - */ - public function getCookie($name = null, $default = null) - { - return $this->cookieReader->getCookie($name, $default); - } - /** * {@inheritdoc} * diff --git a/lib/internal/Magento/Framework/App/RequestInterface.php b/lib/internal/Magento/Framework/App/RequestInterface.php index f08f468ffc0f3..7b23c8f8e9e0b 100644 --- a/lib/internal/Magento/Framework/App/RequestInterface.php +++ b/lib/internal/Magento/Framework/App/RequestInterface.php @@ -48,6 +48,22 @@ public function setActionName($name); */ public function getParam($key, $defaultValue = null); + /** + * Set params from key value array + * + * @param array $params + * @return $this + */ + public function setParams(array $params); + + /** + * Retrieve all params as array + * + * @return array + */ + public function getParams(); + + /** * Retrieve cookie value * diff --git a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Request.php b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Request.php index 6dbc82c681b40..fb97e6c445f61 100644 --- a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Request.php +++ b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Request.php @@ -5,6 +5,7 @@ */ namespace Magento\Framework\HTTP\PhpEnvironment; +use Magento\Framework\Stdlib\Cookie\CookieReaderInterface; use Zend\Http\Header\HeaderInterface; use Zend\Stdlib\Parameters; use Zend\Stdlib\ParametersInterface; @@ -66,11 +67,21 @@ class Request extends \Zend\Http\PhpEnvironment\Request */ protected $dispatched = false; + + /** + * @var CookieReaderInterface + */ + protected $cookieReader; + /** + * @param CookieReaderInterface $cookieReader * @param UriInterface|string|null $uri */ - public function __construct($uri = null) - { + public function __construct( + CookieReaderInterface $cookieReader, + $uri = null + ) { + $this->cookieReader = $cookieReader; if (null !== $uri) { if (!$uri instanceof UriInterface) { $uri = UriFactory::factory($uri); @@ -373,6 +384,18 @@ public function isSecure() return ($this->getScheme() == self::SCHEME_HTTPS); } + /** + * Retrieve a value from a cookie. + * + * @param string|null $name + * @param string|null $default The default value to return if no value could be found for the given $name. + * @return string|null + */ + public function getCookie($name = null, $default = null) + { + return $this->cookieReader->getCookie($name, $default); + } + /** * Retrieve SERVER parameters * diff --git a/lib/internal/Magento/Framework/Webapi/Request.php b/lib/internal/Magento/Framework/Webapi/Request.php index 589573c8dd2c5..e40112ce2d646 100644 --- a/lib/internal/Magento/Framework/Webapi/Request.php +++ b/lib/internal/Magento/Framework/Webapi/Request.php @@ -15,11 +15,6 @@ class Request extends HttpRequest implements RequestInterface { - /** - * @var CookieReaderInterface - */ - protected $_cookieReader; - /** * Modify pathInfo: strip down the front name and query parameters. * @@ -29,13 +24,12 @@ class Request extends HttpRequest implements RequestInterface * @param null|string|\Zend_Uri $uri */ public function __construct( + CookieReaderInterface $cookieReader, AreaList $areaList, ScopeInterface $configScope, - CookieReaderInterface $cookieReader, $uri = null ) { - parent::__construct($uri); - $this->_cookieReader = $cookieReader; + parent::__construct($cookieReader, $uri); $pathInfo = $this->getRequestUri(); /** Remove base url and area from path */ @@ -45,16 +39,4 @@ public function __construct( $pathInfo = preg_replace('#\?.*#', '', $pathInfo); $this->setPathInfo($pathInfo); } - - /** - * Retrieve a value from a cookie. - * - * @param string|null $name - * @param string|null $default The default value to return if no value could be found for the given $name. - * @return string|null - */ - public function getCookie($name = null, $default = null) - { - return $this->_cookieReader->getCookie($name, $default); - } } diff --git a/lib/internal/Magento/Framework/Webapi/Rest/Request.php b/lib/internal/Magento/Framework/Webapi/Rest/Request.php index eeee99a42f98d..9f97855cb7a89 100644 --- a/lib/internal/Magento/Framework/Webapi/Rest/Request.php +++ b/lib/internal/Magento/Framework/Webapi/Rest/Request.php @@ -46,20 +46,20 @@ class Request extends \Magento\Framework\Webapi\Request /** * Initialize dependencies * + * @param \Magento\Framework\Stdlib\Cookie\CookieReaderInterface $cookieReader * @param \Magento\Framework\App\AreaList $areaList * @param \Magento\Framework\Config\ScopeInterface $configScope - * @param \Magento\Framework\Stdlib\Cookie\CookieReaderInterface $cookieReader * @param \Magento\Framework\Webapi\Rest\Request\DeserializerFactory $deserializerFactory * @param null|string $uri */ public function __construct( + \Magento\Framework\Stdlib\Cookie\CookieReaderInterface $cookieReader, \Magento\Framework\App\AreaList $areaList, \Magento\Framework\Config\ScopeInterface $configScope, - \Magento\Framework\Stdlib\Cookie\CookieReaderInterface $cookieReader, \Magento\Framework\Webapi\Rest\Request\DeserializerFactory $deserializerFactory, $uri = null ) { - parent::__construct($areaList, $configScope, $cookieReader, $uri); + parent::__construct($cookieReader, $areaList, $configScope, $uri); $this->_deserializerFactory = $deserializerFactory; }