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


PHP Http::expects方法代码示例

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


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

示例1: testExecute

 public function testExecute()
 {
     $this->objectManager->expects($this->once())->method('get')->with('Magento\\Theme\\Helper\\Storage')->willReturn($this->storageHelper);
     $this->storageHelper->expects($this->once())->method('getRelativeUrl')->willReturn('http://relative.url/');
     $this->response->expects($this->once())->method('setBody')->with('http://relative.url/');
     $this->controller->execute();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:7,代码来源:OnInsertTest.php

示例2: testDisplay

 public function testDisplay()
 {
     $this->markTestSkipped('Remove it when task(MAGETWO-33495) will be fixed');
     $this->_response->expects($this->atLeastOnce())->method('sendHeaders');
     $this->_request->expects($this->atLeastOnce())->method('getHeader');
     $stat = (include __DIR__ . '/_files/timers.php');
     $this->_output->display($stat);
     $actualHeaders = $this->_response->getHeaders();
     $this->assertNotEmpty($actualHeaders);
     $actualProtocol = false;
     $actualProfilerData = false;
     foreach ($actualHeaders as $oneHeader) {
         $headerName = $oneHeader->getFieldName();
         $headerValue = $oneHeader->getFieldValue();
         if (!$actualProtocol && $headerName == 'X-Wf-Protocol-1') {
             $actualProtocol = $headerValue;
         }
         if (!$actualProfilerData && $headerName == 'X-Wf-1-1-1-1') {
             $actualProfilerData = $headerValue;
         }
     }
     $this->assertNotEmpty($actualProtocol, 'Cannot get protocol header');
     $this->assertNotEmpty($actualProfilerData, 'Cannot get profiler header');
     $this->assertContains('Protocol/JsonStream', $actualProtocol);
     $this->assertRegExp('/"Type":"TABLE","Label":"Code Profiler \\(Memory usage: real - \\d+, emalloc - \\d+\\)"/', $actualProfilerData);
     $this->assertContains('[' . '["Timer Id","Time","Avg","Cnt","Emalloc","RealMem"],' . '["root","0.080000","0.080000","1","1,000","50,000"],' . '[". init","0.040000","0.040000","1","200","2,500"],' . '[". . init_store","0.020000","0.010000","2","100","2,000"],' . '["system","0.030000","0.015000","2","400","20,000"]' . ']', $actualProfilerData);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:27,代码来源:FirebugTest.php

示例3: testAroundDispatchDisabled

 /**
  * @dataProvider dataProvider
  */
 public function testAroundDispatchDisabled($state)
 {
     $this->configMock->expects($this->any())->method('getType')->will($this->returnValue(null));
     $this->versionMock->expects($this->never())->method('process');
     $this->stateMock->expects($this->any())->method('getMode')->will($this->returnValue($state));
     $this->responseMock->expects($this->never())->method('setHeader');
     $this->plugin->aroundDispatch($this->frontControllerMock, $this->closure, $this->requestMock);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:VarnishPluginTest.php

示例4: testExecuteWithWrongRequest

 public function testExecuteWithWrongRequest()
 {
     $this->request->expects($this->once())->method('isPost')->willReturn(false);
     $jsonData = $this->getMock('Magento\\Framework\\Json\\Helper\\Data', [], [], '', false);
     $jsonData->expects($this->once())->method('jsonEncode')->with(['error' => true, 'message' => 'Wrong request'])->willReturn('{"error":"true","message":"Wrong request"}');
     $this->objectManager->expects($this->once())->method('get')->with('Magento\\Framework\\Json\\Helper\\Data')->willReturn($jsonData);
     $this->response->expects($this->once())->method('representJson')->with('{"error":"true","message":"Wrong request"}');
     $this->controller->execute();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:9,代码来源:DeleteFilesTest.php

示例5: testAuthenticate

 public function testAuthenticate()
 {
     $urlMock = $this->getMock('Magento\\Framework\\Url', [], [], '', false);
     $urlMock->expects($this->exactly(2))->method('getUrl')->will($this->returnValue(''));
     $urlMock->expects($this->once())->method('getRebuiltUrl')->will($this->returnValue(''));
     $this->urlFactoryMock->expects($this->exactly(3))->method('create')->will($this->returnValue($urlMock));
     $this->responseMock->expects($this->once())->method('setRedirect')->with('')->will($this->returnValue(''));
     $this->assertFalse($this->_model->authenticate());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:SessionTest.php

示例6: 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

示例7: testExecuteLocalizedException

 /**
  * Executes the controller action and asserts non exception logic
  */
 public function testExecuteLocalizedException()
 {
     $phrase = new \Magento\Framework\Phrase('some error');
     $objectManager = new ObjectManager($this);
     $this->vault->expects($this->once())->method('processNonce')->willThrowException(new LocalizedException($phrase));
     $this->resultJson->expects($this->once())->method('setData')->with(['success' => false, 'error_message' => 'some error']);
     $this->resultFactory->expects($this->once())->method('create')->willReturn($this->resultJson);
     $this->messageManager->expects($this->once())->method('addError')->with($phrase);
     $notification = $objectManager->getObject('Magento\\Braintree\\Controller\\Creditcard\\AjaxSave', ['request' => $this->request, 'resultFactory' => $this->resultFactory, 'vault' => $this->vault, 'messageManager' => $this->messageManager]);
     $this->assertSame($this->resultJson, $notification->execute());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:AjaxSaveTest.php

示例8: testAroundResultWithPluginDeveloperMode

 public function testAroundResultWithPluginDeveloperMode()
 {
     $this->registry->expects($this->once())->method('registry')->with('use_page_cache_plugin')->willReturn(true);
     $this->state->expects($this->once())->method('getMode')->willReturn(\Magento\Framework\App\State::MODE_DEVELOPER);
     $this->header->expects($this->any())->method('getFieldValue')->willReturnOnConsecutiveCalls('test', 'tag,tag2');
     $this->response->expects($this->any())->method('setHeader')->withConsecutive(['X-Magento-Cache-Control', 'test'], ['X-Magento-Cache-Debug', 'MISS', true], ['X-Magento-Tags', 'tag,tag2,' . \Magento\PageCache\Model\Cache\Type::CACHE_TAG]);
     $this->response->expects($this->once())->method('clearHeader')->with('X-Magento-Tags');
     $this->registry->expects($this->once())->method('registry')->with('use_page_cache_plugin')->will($this->returnValue(true));
     $this->kernel->expects($this->once())->method('process')->with($this->response);
     $result = call_user_func($this->closure);
     $this->assertSame($result, $this->plugin->aroundRenderResult($this->subject, $this->closure, $this->response));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:BuiltinPluginTest.php

示例9: testExecuteInternalLocalizedException

 /**
  * Executes the controller action and asserts non exception logic
  */
 public function testExecuteInternalLocalizedException()
 {
     $phrase = new \Magento\Framework\Phrase('Something went wrong while processing.');
     $objectManager = new ObjectManager($this);
     $this->vault->expects($this->once())->method('generatePaymentMethodToken')->willThrowException(new LocalizedException($phrase));
     $this->resultJson->expects($this->once())->method('setData')->with(['success' => false, 'error_message' => 'Something went wrong while processing.']);
     $this->resultFactory->expects($this->once())->method('create')->willReturn($this->resultJson);
     $this->messageManager->expects($this->once())->method('addError')->with($phrase);
     $this->request->expects($this->any())->method('getParam')->willReturn(true);
     /** @var \Magento\Braintree\Controller\Creditcard\Generate $controller */
     $controller = $objectManager->getObject('Magento\\Braintree\\Controller\\Creditcard\\Generate', ['request' => $this->request, 'resultFactory' => $this->resultFactory, 'vault' => $this->vault, 'messageManager' => $this->messageManager]);
     $this->assertSame($this->resultJson, $controller->executeInternal());
 }
开发者ID:nblair,项目名称:magescotch,代码行数:16,代码来源:GenerateTest.php

示例10: testExecute

 public function testExecute()
 {
     $blocks = ['block1', 'block2'];
     $handles = ['handle1', 'handle2'];
     $originalRequest = '{"route":"route","controller":"controller","action":"action","uri":"uri"}';
     $expectedData = ['block1' => 'data1', 'block2' => 'data2'];
     $blockInstance1 = $this->getMock('Magento\\PageCache\\Test\\Unit\\Block\\Controller\\StubBlock', ['toHtml'], [], '', false);
     $blockInstance1->expects($this->once())->method('toHtml')->will($this->returnValue($expectedData['block1']));
     $blockInstance2 = $this->getMock('Magento\\PageCache\\Test\\Unit\\Block\\Controller\\StubBlock', ['toHtml'], [], '', false);
     $blockInstance2->expects($this->once())->method('toHtml')->will($this->returnValue($expectedData['block2']));
     $this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(true));
     $this->requestMock->expects($this->at(1))->method('getRouteName')->will($this->returnValue('magento_pagecache'));
     $this->requestMock->expects($this->at(2))->method('getControllerName')->will($this->returnValue('block'));
     $this->requestMock->expects($this->at(3))->method('getActionName')->will($this->returnValue('render'));
     $this->requestMock->expects($this->at(4))->method('getRequestUri')->will($this->returnValue('uri'));
     $this->requestMock->expects($this->at(5))->method('getParam')->with($this->equalTo('originalRequest'))->will($this->returnValue($originalRequest));
     $this->requestMock->expects($this->at(10))->method('getParam')->with($this->equalTo('blocks'), $this->equalTo(''))->will($this->returnValue(json_encode($blocks)));
     $this->requestMock->expects($this->at(11))->method('getParam')->with($this->equalTo('handles'), $this->equalTo(''))->will($this->returnValue(json_encode($handles)));
     $this->viewMock->expects($this->once())->method('loadLayout')->with($this->equalTo($handles));
     $this->viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($this->layoutMock));
     $this->layoutMock->expects($this->at(0))->method('getBlock')->with($this->equalTo($blocks[0]))->will($this->returnValue($blockInstance1));
     $this->layoutMock->expects($this->at(1))->method('getBlock')->with($this->equalTo($blocks[1]))->will($this->returnValue($blockInstance2));
     $this->translateInline->expects($this->once())->method('processResponseBody')->with($expectedData)->willReturnSelf();
     $this->responseMock->expects($this->once())->method('appendBody')->with($this->equalTo(json_encode($expectedData)));
     $this->action->execute();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:26,代码来源:RenderTest.php

示例11: redirectSection

 /**
  * Redirect into response section
  *
  * @return void
  */
 protected function redirectSection()
 {
     $this->actionFlag->expects($this->once())->method('get')->with('', \Magento\Backend\App\AbstractAction::FLAG_IS_URLS_CHECKED)->will($this->returnValue(true));
     $this->sessionMock->expects($this->once())->method('setIsUrlNotice')->with(true);
     $this->helperMock->expects($this->once())->method('getUrl')->will($this->returnValue('redirect-path'));
     $this->responseMock->expects($this->once())->method('setRedirect');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:PrintLabelTest.php

示例12: testExecute

 /**
  * Run test execute method
  */
 public function testExecute()
 {
     $data = ['comment' => 'comment'];
     $result = 'result-html';
     $orderId = 1;
     $shipmentId = 1;
     $shipment = [];
     $tracking = [];
     $resultLayoutMock = $this->getMock('Magento\\Framework\\View\\Result\\Layout', ['getBlock', 'getDefaultLayoutHandle', 'addDefaultHandle', 'getLayout'], [], '', false);
     $this->requestMock->expects($this->once())->method('setParam')->with('shipment_id', $shipmentId);
     $this->requestMock->expects($this->once())->method('getPost')->with('comment')->will($this->returnValue($data));
     $this->requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap([['id', null, $shipmentId], ['order_id', null, $orderId], ['shipment_id', null, $shipmentId], ['shipment', null, $shipment], ['tracking', null, $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')->will($this->returnValue($this->shipmentMock));
     $this->shipmentMock->expects($this->once())->method('addComment');
     $this->shipmentCommentSenderMock->expects($this->once())->method('send');
     $this->shipmentMock->expects($this->once())->method('save');
     $layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', ['getBlock'], [], '', false);
     $blockMock = $this->getMock('Magento\\Shipping\\Block\\Adminhtml\\View\\Comments', ['toHtml'], [], '', false);
     $blockMock->expects($this->once())->method('toHtml')->willReturn($result);
     $layoutMock->expects($this->once())->method('getBlock')->with('shipment_comments')->willReturn($blockMock);
     $resultLayoutMock->expects($this->once())->method('getLayout')->willReturn($layoutMock);
     $resultLayoutMock->expects($this->once())->method('addDefaultHandle');
     $this->resultLayoutFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultLayoutMock));
     $this->responseMock->expects($this->once())->method('setBody')->with($result);
     $this->assertNull($this->controller->execute());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:33,代码来源:AddCommentTest.php

示例13: testExecute

 public function testExecute()
 {
     $layout = $this->getMockForAbstractClass('Magento\\Framework\\View\\LayoutInterface', [], '', false);
     $storage = $this->getMock('Magento\\Theme\\Model\\Wysiwyg\\Storage', [], [], '', false);
     $block = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\BlockInterface', [], '', false, false, true, ['setStorage']);
     $this->view->expects($this->once())->method('loadLayout')->with('empty');
     $this->view->expects($this->once())->method('getLayout')->willReturn($layout);
     $layout->expects($this->once())->method('getBlock')->with('wysiwyg_files.files')->willReturn($block);
     $block->expects($this->once())->method('setStorage')->with($storage);
     $this->objectManager->expects($this->at(0))->method('get')->with('Magento\\Theme\\Model\\Wysiwyg\\Storage')->willReturn($storage);
     $this->storage->expects($this->once())->method('getCurrentPath')->willThrowException(new \Exception('Message'));
     $jsonData = $this->getMock('Magento\\Framework\\Json\\Helper\\Data', [], [], '', false);
     $jsonData->expects($this->once())->method('jsonEncode')->with(['error' => true, 'message' => 'Message'])->willReturn('{"error":"true","message":"Message"}');
     $this->objectManager->expects($this->at(1))->method('get')->with('Magento\\Framework\\Json\\Helper\\Data')->willReturn($jsonData);
     $this->response->expects($this->once())->method('representJson');
     $this->controller->execute();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:ContentsTest.php

示例14: testExecutePassed

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

示例15: testProcessNotSaveCache

 /**
  * @dataProvider processNotSaveCacheProvider
  * @param string $cacheControlHeader
  * @param int $httpCode
  * @param bool $isGet
  * @param bool $overrideHeaders
  */
 public function testProcessNotSaveCache($cacheControlHeader, $httpCode, $isGet, $overrideHeaders)
 {
     $this->responseMock->expects($this->once())->method('getHeader')->with('Cache-Control')->will($this->returnValue(array('value' => $cacheControlHeader)));
     $this->responseMock->expects($this->any())->method('getHttpResponseCode')->will($this->returnValue($httpCode));
     $this->requestMock->expects($this->any())->method('isGet')->will($this->returnValue($isGet));
     if ($overrideHeaders) {
         $this->responseMock->expects($this->once())->method('setNoCacheHeaders');
     }
     $this->cacheMock->expects($this->never())->method('save');
     $this->kernel->process($this->responseMock);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:18,代码来源:KernelTest.php


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