当前位置: 首页>>代码示例>>PHP>>正文


PHP Http::expects方法代码示例

本文整理汇总了PHP中Magento\Framework\App\Request\Http::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::expects方法的具体用法?PHP Http::expects怎么用?PHP Http::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\App\Request\Http的用法示例。


在下文中一共展示了Http::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testLog

 /**
  * @dataProvider logDataProvider
  */
 public function testLog($logLevel, $method)
 {
     $message = 'Error message';
     $this->request->expects($this->once())->method('getRequestUri')->willReturn($this->requestUri);
     $this->psrLogger->expects($this->once())->method($method)->with($message . ' ' . $this->requestUri);
     $this->logger->log($message, $logLevel);
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:10,代码来源:LoggerTest.php

示例2: testDispatchPostDispatch

 public function testDispatchPostDispatch()
 {
     $this->_requestMock->expects($this->exactly(3))->method('getFullActionName')->will($this->returnValue(self::FULL_ACTION_NAME));
     $this->_requestMock->expects($this->exactly(2))->method('getRouteName')->will($this->returnValue(self::ROUTE_NAME));
     $expectedEventParameters = ['controller_action' => $this->action, 'request' => $this->_requestMock];
     $this->_eventManagerMock->expects($this->at(0))->method('dispatch')->with('controller_action_predispatch', $expectedEventParameters);
     $this->_eventManagerMock->expects($this->at(1))->method('dispatch')->with('controller_action_predispatch_' . self::ROUTE_NAME, $expectedEventParameters);
     $this->_eventManagerMock->expects($this->at(2))->method('dispatch')->with('controller_action_predispatch_' . self::FULL_ACTION_NAME, $expectedEventParameters);
     $this->_requestMock->expects($this->once())->method('isDispatched')->will($this->returnValue(true));
     $this->_actionFlagMock->expects($this->at(0))->method('get')->with('', Action::FLAG_NO_DISPATCH)->will($this->returnValue(false));
     // _forward expectations
     $this->_requestMock->expects($this->once())->method('initForward');
     $this->_requestMock->expects($this->once())->method('setParams')->with(self::$actionParams);
     $this->_requestMock->expects($this->once())->method('setControllerName')->with(self::CONTROLLER_NAME);
     $this->_requestMock->expects($this->once())->method('setModuleName')->with(self::MODULE_NAME);
     $this->_requestMock->expects($this->once())->method('setActionName')->with(self::ACTION_NAME);
     $this->_requestMock->expects($this->once())->method('setDispatched')->with(false);
     // _redirect expectations
     $this->_redirectMock->expects($this->once())->method('redirect')->with($this->_responseMock, self::FULL_ACTION_NAME, self::$actionParams);
     $this->_actionFlagMock->expects($this->at(1))->method('get')->with('', Action::FLAG_NO_POST_DISPATCH)->will($this->returnValue(false));
     $this->_eventManagerMock->expects($this->at(3))->method('dispatch')->with('controller_action_postdispatch_' . self::FULL_ACTION_NAME, $expectedEventParameters);
     $this->_eventManagerMock->expects($this->at(4))->method('dispatch')->with('controller_action_postdispatch_' . self::ROUTE_NAME, $expectedEventParameters);
     $this->_eventManagerMock->expects($this->at(5))->method('dispatch')->with('controller_action_postdispatch', $expectedEventParameters);
     $this->assertEquals($this->_responseMock, $this->action->dispatch($this->_requestMock));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:ActionTest.php

示例3: setUp

 protected function setUp()
 {
     $orderId = 1;
     $shipmentId = 1;
     $shipment = [];
     $tracking = [];
     $this->shipmentLoaderMock = $this->getMock('Magento\\Shipping\\Controller\\Adminhtml\\Order\\ShipmentLoader', ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], [], '', false);
     $this->requestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', ['getParam'], [], '', false);
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false);
     $this->sessionMock = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', ['get'], [], '', false);
     $this->shipmentMock = $this->getMock('Magento\\Sales\\Model\\Order\\Shipment', ['__wakeup'], [], '', false);
     $this->fileFactoryMock = $this->getMock('Magento\\Framework\\App\\Response\\Http\\FileFactory', ['create'], [], '', false);
     $contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getObjectManager', 'getResponse', 'getSession', 'getActionFlag'], [], '', false);
     $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock));
     $contextMock->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->objectManagerMock));
     $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock));
     $contextMock->expects($this->any())->method('getSession')->will($this->returnValue($this->sessionMock));
     $contextMock->expects($this->any())->method('getActionFlag')->will($this->returnValue($this->actionFlag));
     $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->will($this->returnValue($orderId));
     $this->requestMock->expects($this->at(1))->method('getParam')->with('shipment_id')->will($this->returnValue($shipmentId));
     $this->requestMock->expects($this->at(2))->method('getParam')->with('shipment')->will($this->returnValue($shipment));
     $this->requestMock->expects($this->at(3))->method('getParam')->with('tracking')->will($this->returnValue($tracking));
     $this->shipmentLoaderMock->expects($this->once())->method('setOrderId')->with($orderId);
     $this->shipmentLoaderMock->expects($this->once())->method('setShipmentId')->with($shipmentId);
     $this->shipmentLoaderMock->expects($this->once())->method('setShipment')->with($shipment);
     $this->shipmentLoaderMock->expects($this->once())->method('setTracking')->with($tracking);
     $this->controller = new \Magento\Shipping\Controller\Adminhtml\Order\Shipment\PrintPackage($contextMock, $this->shipmentLoaderMock, $this->fileFactoryMock);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:30,代码来源:PrintPackageTest.php

示例4: testExecute

 /**
  * Run test execute method
  */
 public function testExecute()
 {
     $orderId = 1;
     $shipmentId = 1;
     $shipment = [];
     $tracking = [];
     $result = 'result-html';
     $layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', ['createBlock'], [], '', false);
     $gridMock = $this->getMock('Magento\\Shipping\\Block\\Adminhtml\\Order\\Packaging\\Grid', ['setIndex', 'toHtml'], [], '', false);
     $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->will($this->returnValue($orderId));
     $this->requestMock->expects($this->at(1))->method('getParam')->with('shipment_id')->will($this->returnValue($shipmentId));
     $this->requestMock->expects($this->at(2))->method('getParam')->with('shipment')->will($this->returnValue($shipment));
     $this->requestMock->expects($this->at(3))->method('getParam')->with('tracking')->will($this->returnValue($tracking));
     $this->shipmentLoaderMock->expects($this->once())->method('setOrderId')->with($orderId);
     $this->shipmentLoaderMock->expects($this->once())->method('setShipmentId')->with($shipmentId);
     $this->shipmentLoaderMock->expects($this->once())->method('setShipment')->with($shipment);
     $this->shipmentLoaderMock->expects($this->once())->method('setTracking')->with($tracking);
     $this->shipmentLoaderMock->expects($this->once())->method('load');
     $layoutMock->expects($this->once())->method('createBlock')->with('Magento\\Shipping\\Block\\Adminhtml\\Order\\Packaging\\Grid')->will($this->returnValue($gridMock));
     $this->viewMock->expects($this->once())->method('getLayout')->will($this->returnValue($layoutMock));
     $this->responseMock->expects($this->once())->method('setBody')->with($result)->will($this->returnSelf());
     $this->requestMock->expects($this->at(4))->method('getParam')->with('index');
     $gridMock->expects($this->once())->method('setIndex')->will($this->returnSelf());
     $gridMock->expects($this->once())->method('toHtml')->will($this->returnValue($result));
     $this->assertNotEmpty('result-html', $this->controller->execute());
 }
开发者ID:,项目名称:,代码行数:29,代码来源:

示例5: testProcess

    /**
     * @dataProvider processProvider
     * @param bool $isPost
     */
    public function testProcess($isPost)
    {
        $this->requestMock->expects($this->once())->method('isPost')->will($this->returnValue($isPost));
        if ($isPost) {
            $publicCookieMetadataMock = $this->getMock('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata');
            $publicCookieMetadataMock->expects($this->once())
                ->method('setPath')
                ->with('/')
                ->will($this->returnSelf());

            $publicCookieMetadataMock->expects($this->once())
                ->method('setDuration')
                ->with(Version::COOKIE_PERIOD)
                ->will($this->returnSelf());

            $publicCookieMetadataMock->expects($this->once())
                ->method('setHttpOnly')
                ->with(false)
                ->will($this->returnSelf());

            $this->cookieMetadataFactoryMock->expects($this->once())
                ->method('createPublicCookieMetadata')
                ->with()
                ->will(
                    $this->returnValue($publicCookieMetadataMock)
                );

            $this->cookieManagerMock->expects($this->once())
                ->method('setPublicCookie');
        }
        $this->version->process();
    }
开发者ID:rafaelstz,项目名称:magento2,代码行数:36,代码来源:VersionTest.php

示例6: testProcess

 /**
  * @dataProvider processProvider
  * @param bool $isPost
  */
 public function testProcess($isPost)
 {
     $this->requestMock->expects($this->once())->method('isPost')->will($this->returnValue($isPost));
     if ($isPost) {
         $this->cookieMock->expects($this->once())->method('set');
     }
     $this->version->process();
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:12,代码来源:VersionTest.php

示例7: testGetThemeByRequest

 /**
  * @param string $userAgent
  * @param bool $useConfig
  * @param bool|string $result
  * @param array $expressions
  * @dataProvider getThemeByRequestDataProvider
  */
 public function testGetThemeByRequest($userAgent, $useConfig, $result, $expressions = [])
 {
     $this->requestMock->expects($this->once())->method('getServer')->with($this->equalTo('HTTP_USER_AGENT'))->will($this->returnValue($userAgent));
     if ($useConfig) {
         $this->scopeConfigMock->expects($this->once())->method('getValue')->with($this->equalTo($this->exceptionConfigPath), $this->equalTo($this->scopeType))->will($this->returnValue(serialize($expressions)));
     }
     $this->assertSame($result, $this->designExceptions->getThemeByRequest($this->requestMock));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:DesignExceptionsTest.php

示例8: testGetScopeTitleDefault

 public function testGetScopeTitleDefault()
 {
     $scope = 'default';
     $scopeId = 0;
     $scopeTypeName = 'Default';
     $this->request->expects($this->exactly(2))->method('getParam')->willReturnMap([['scope', null, $scope], ['scope_id', null, $scopeId]]);
     $this->assertEquals($scopeTypeName, $this->block->getScopeTitle()->render());
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:8,代码来源:ScopeTest.php

示例9: testGetViewFileUrl

 /**
  * @param bool $isSecure
  * @dataProvider getViewFileUrlDataProvider
  */
 public function testGetViewFileUrl($isSecure)
 {
     $this->request->expects($this->once())->method('isSecure')->will($this->returnValue($isSecure));
     $this->assetRepo->expects($this->once())->method('getUrlWithParams')->with('some file', $this->callback(function ($value) use($isSecure) {
         return isset($value['_secure']) && $value['_secure'] === $isSecure;
     }))->will($this->returnValue('result url'));
     $this->assertEquals('result url', $this->model->getViewFileUrl('some file'));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:ReviewTest.php

示例10: testExecuteNotPost

 public function testExecuteNotPost()
 {
     $this->validatorMock->expects($this->once())->method('validate')->willReturn(false);
     $this->request->expects($this->once())->method('isPost')->willReturn(false);
     $this->messageManager->expects($this->once())->method('addError')->with('You have not canceled the item.');
     $this->resultRedirect->expects($this->once())->method('setPath')->with('sales/*/')->willReturnSelf();
     $this->assertEquals($this->resultRedirect, $this->controller->execute());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:CancelTest.php

示例11: testGetRequestUri

 /**
  * @param boolean $clean
  * @param string $expectedValue
  *
  * @dataProvider getRequestUriDataProvider
  */
 public function testGetRequestUri($clean, $expectedValue)
 {
     $this->_request->expects($this->once())->method('getRequestUri')->will($this->returnValue('value'));
     $this->_prepareCleanString($clean);
     $headerObject = $this->_objectManager->getObject('Magento\\Framework\\HTTP\\Header', ['httpRequest' => $this->_request, 'converter' => $this->_converter]);
     $result = $headerObject->getRequestUri($clean);
     $this->assertEquals($expectedValue, $result);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:HeaderTest.php

示例12: testPathDifferentiator

 public function testPathDifferentiator()
 {
     $this->requestMock->method('isSecure')->willReturn(true);
     $this->requestMock->expects($this->at(1))->method('getUriString')->willReturn('http://example.com/path/');
     $this->requestMock->expects($this->at(4))->method('getUriString')->willReturn('http://example.com/path1/');
     $this->contextMock->method('getVaryString')->willReturn(self::VARY);
     $valuePath1 = $this->model->getValue();
     $valuePath2 = $this->model->getValue();
     $this->assertNotEquals($valuePath1, $valuePath2);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:IdentifierTest.php

示例13: testExecuteWithWishlist

 public function testExecuteWithWishlist()
 {
     $wishlist = $this->getMockBuilder('Magento\\Wishlist\\Model\\Wishlist')->disableOriginalConstructor()->getMock();
     $this->wishlistProvider->expects($this->once())->method('getWishlist')->willReturn($wishlist);
     $this->request->expects($this->once())->method('getParam')->with('qty')->will($this->returnValue(2));
     $this->itemCarrier->expects($this->once())->method('moveAllToCart')->with($wishlist, 2)->will($this->returnValue('http://redirect-url.com'));
     $this->response->expects($this->once())->method('setRedirect')->will($this->returnValue('http://redirect-url.com'));
     $controller = $this->getController();
     $controller->execute();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:AllcartTest.php

示例14: testExecutePageDirectAccess

 public function testExecutePageDirectAccess()
 {
     $this->request->expects($this->any())->method('getParam')->with('filters')->willReturn(null);
     $this->request->expects($this->any())->method('getParams')->willReturn([]);
     $this->attributeHelper->expects($this->any())->method('getProductIds')->willReturn(null);
     $resultRedirect = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->setMethods(['setPath'])->disableOriginalConstructor()->getMock();
     $resultRedirect->expects($this->any())->method('setPath')->with('catalog/product/', ['_current' => true])->willReturnSelf();
     $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($resultRedirect);
     $this->assertSame($resultRedirect, $this->object->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:EditTest.php

示例15: testExecuteWithWishlist

 public function testExecuteWithWishlist()
 {
     $url = 'http://redirect-url.com';
     $quantity = 2;
     $this->wishlistProviderMock->expects($this->once())->method('getWishlist')->willReturn($this->wishlistMock);
     $this->requestMock->expects($this->any())->method('getParam')->with('qty')->willReturn($quantity);
     $this->itemCarrierMock->expects($this->once())->method('moveAllToCart')->with($this->wishlistMock, 2)->willReturn($url);
     $this->resultRedirectMock->expects($this->once())->method('setUrl')->with($url)->willReturnSelf();
     $this->assertSame($this->resultRedirectMock, $this->allcartController->execute());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:AllcartTest.php


注:本文中的Magento\Framework\App\Request\Http::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。