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


PHP ResponseInterface::expects方法代码示例

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


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

示例1: setUp

 /**
  * Prepare required values
  *
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->_request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->_response = $this->getMockBuilder('Magento\\Framework\\App\\Response\\Http')->disableOriginalConstructor()->setMethods(array('setRedirect', 'getHeader'))->getMock();
     $this->_response->expects($this->any())->method('getHeader')->with($this->equalTo('X-Frame-Options'))->will($this->returnValue(true));
     $this->_objectManager = $this->getMockBuilder('Magento\\Framework\\App\\ObjectManager')->disableOriginalConstructor()->setMethods(array('get', 'create'))->getMock();
     $frontControllerMock = $this->getMockBuilder('Magento\\Framework\\App\\FrontController')->disableOriginalConstructor()->getMock();
     $actionFlagMock = $this->getMockBuilder('Magento\\Framework\\App\\ActionFlag')->disableOriginalConstructor()->getMock();
     $this->_session = $this->getMockBuilder('Magento\\Backend\\Model\\Session')->disableOriginalConstructor()->setMethods(array('setIsUrlNotice', '__wakeup'))->getMock();
     $this->_session->expects($this->any())->method('setIsUrlNotice');
     $this->_helper = $this->getMockBuilder('Magento\\Backend\\Helper\\Data')->disableOriginalConstructor()->setMethods(array('getUrl'))->getMock();
     $this->messageManager = $this->getMockBuilder('Magento\\Framework\\Message\\Manager')->disableOriginalConstructor()->setMethods(array('addSuccess', 'addMessage', 'addException'))->getMock();
     $contextArgs = array('getHelper', 'getSession', 'getAuthorization', 'getTranslator', 'getObjectManager', 'getFrontController', 'getActionFlag', 'getMessageManager', 'getLayoutFactory', 'getEventManager', 'getRequest', 'getResponse', 'getTitle', 'getView');
     $contextMock = $this->getMockBuilder('\\Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->setMethods($contextArgs)->getMock();
     $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->_request));
     $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->_response));
     $contextMock->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->_objectManager));
     $contextMock->expects($this->any())->method('getFrontController')->will($this->returnValue($frontControllerMock));
     $contextMock->expects($this->any())->method('getActionFlag')->will($this->returnValue($actionFlagMock));
     $contextMock->expects($this->any())->method('getHelper')->will($this->returnValue($this->_helper));
     $contextMock->expects($this->any())->method('getSession')->will($this->returnValue($this->_session));
     $contextMock->expects($this->any())->method('getMessageManager')->will($this->returnValue($this->messageManager));
     $titleMock = $this->getMockBuilder('\\Magento\\Framework\\App\\Action\\Title')->getMock();
     $contextMock->expects($this->any())->method('getTitle')->will($this->returnValue($titleMock));
     $viewMock = $this->getMockBuilder('\\Magento\\Framework\\App\\ViewInterface')->getMock();
     $viewMock->expects($this->any())->method('loadLayout')->will($this->returnSelf());
     $contextMock->expects($this->any())->method('getView')->will($this->returnValue($viewMock));
     $this->_acctServiceMock = $this->getMockBuilder('Magento\\Customer\\Service\\V1\\CustomerAccountServiceInterface')->getMock();
     $args = array('context' => $contextMock, 'accountService' => $this->_acctServiceMock);
     $helperObjectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->_testedObject = $helperObjectManager->getObject('Magento\\Customer\\Controller\\Adminhtml\\Index\\Newsletter', $args);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:38,代码来源:NewsletterTest.php

示例2: testRender

 public function testRender()
 {
     $content = '<content>test</content>';
     $this->raw->setContents($content);
     $this->response->expects($this->once())->method('setBody')->with($content);
     $this->assertSame($this->raw, $this->raw->renderResult($this->response));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:7,代码来源:RawTest.php

示例3: testExecuteEmptyQuery

 public function testExecuteEmptyQuery()
 {
     $searchString = "";
     $this->request->expects($this->once())->method('getParam')->with('q')->will($this->returnValue($searchString));
     $this->url->expects($this->once())->method('getBaseUrl');
     $this->response->expects($this->once())->method('setRedirect');
     $this->controller->execute();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:8,代码来源:SuggestTest.php

示例4: testIndexActionException

 public function testIndexActionException()
 {
     $this->request->expects($this->once())->method('isPost')->will($this->returnValue(true));
     $exception = new \Exception();
     $this->request->expects($this->once())->method('getPostValue')->will($this->throwException($exception));
     $this->logger->expects($this->once())->method('critical')->with($this->identicalTo($exception));
     $this->response->expects($this->once())->method('setHttpResponseCode')->with(500);
     $this->model->executeInternal();
 }
开发者ID:nblair,项目名称:magescotch,代码行数:9,代码来源:IndexTest.php

示例5: testExecuteRandom

 public function testExecuteRandom()
 {
     $newKey = 'RSASHA9000VERYSECURESUPERMANKEY';
     $this->requestMock->expects($this->at(0))->method('getPost')->with($this->equalTo('generate_random'))->willReturn(1);
     $this->changeMock->expects($this->once())->method('changeEncryptionKey')->willReturn($newKey);
     $this->managerMock->expects($this->once())->method('addSuccessMessage');
     $this->managerMock->expects($this->once())->method('addNoticeMessage');
     $this->cacheMock->expects($this->once())->method('clean');
     $this->responseMock->expects($this->once())->method('setRedirect');
     $this->model->execute();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:SaveTest.php

示例6: testExecuteWithException

 public function testExecuteWithException()
 {
     $this->requestMock->expects($this->once())->method('getParam')->with('item_id', null)->willReturn('1');
     $exception = new \Exception('Error message!');
     $this->sidebarMock->expects($this->once())->method('checkQuoteItem')->with(1)->willThrowException($exception);
     $this->loggerMock->expects($this->once())->method('critical')->with($exception)->willReturn(null);
     $this->sidebarMock->expects($this->once())->method('getResponseData')->with('Error message!')->willReturn(['success' => false, 'error_message' => 'Error message!']);
     $this->jsonHelperMock->expects($this->once())->method('jsonEncode')->with(['success' => false, 'error_message' => 'Error message!'])->willReturn('json encoded');
     $this->responseMock->expects($this->once())->method('representJson')->with('json encoded')->willReturn('json represented');
     $this->assertEquals('json represented', $this->removeItem->executeInternal());
 }
开发者ID:nblair,项目名称:magescotch,代码行数:11,代码来源:RemoveItemTest.php

示例7: testExecute

 /**
  * @return void
  */
 public function testExecute()
 {
     $successMessage = 'All other open sessions for this account were terminated.';
     $this->sessionsManager->expects($this->once())->method('logoutOtherUserSessions');
     $this->messageManager->expects($this->once())->method('addSuccess')->with($successMessage);
     $this->messageManager->expects($this->never())->method('addError');
     $this->messageManager->expects($this->never())->method('addException');
     $this->responseMock->expects($this->once())->method('setRedirect');
     $this->actionFlagMock->expects($this->once())->method('get')->with('', \Magento\Backend\App\AbstractAction::FLAG_IS_URLS_CHECKED);
     $this->backendHelperMock->expects($this->once())->method('getUrl');
     $this->controller->execute();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:LogoutAllTest.php

示例8: testExecute

 public function testExecute()
 {
     $type = 'sampleType';
     $feed = $this->getMockBuilder('Magento\\SampleServiceContractNew\\API\\Data\\FeedInterface')->getMockForAbstractClass();
     $xml = 'xmlDataString';
     $this->request->expects($this->once())->method('getParam')->with('type')->willReturn($type);
     $this->feedRepository->expects($this->once())->method('getById')->with($type)->willReturn($feed);
     $this->response->expects($this->once())->method('setHeader')->with('Content-type', 'text/xml; charset=UTF-8')->willReturnSelf();
     $this->feedTransformer->expects($this->once())->method('toXml')->with($feed)->willReturn($xml);
     $this->response->expects($this->once())->method('setBody')->with($xml)->willReturnSelf();
     $this->controller->execute();
 }
开发者ID:imbrj,项目名称:magento2-samples,代码行数:12,代码来源:ViewTest.php

示例9: testExecute

 public function testExecute()
 {
     $layout = $this->getMock('\\Magento\\Framework\\View\\LayoutInterface');
     $block = $this->getMockBuilder('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Bundle\\Option\\Search\\Grid')->disableOriginalConstructor()->setMethods(['setIndex', 'toHtml'])->getMock();
     $this->response->expects($this->once())->method('setBody')->willReturnSelf();
     $this->request->expects($this->once())->method('getParam')->with('index')->willReturn('index');
     $this->view->expects($this->once())->method('getLayout')->willReturn($layout);
     $layout->expects($this->once())->method('createBlock')->willReturn($block);
     $block->expects($this->once())->method('setIndex')->willReturnSelf();
     $block->expects($this->once())->method('toHtml')->willReturnSelf();
     $this->assertEquals($this->response, $this->controller->execute());
 }
开发者ID:nja78,项目名称:magento2,代码行数:12,代码来源:GridTest.php

示例10: testExecute

 public function testExecute()
 {
     $product = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['_wakeup', 'getId'])->getMock();
     $layout = $this->getMock('\\Magento\\Framework\\View\\LayoutInterface');
     $block = $this->getMockBuilder('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Bundle')->disableOriginalConstructor()->setMethods(['setIndex', 'toHtml'])->getMock();
     $this->productBuilder->expects($this->once())->method('build')->with($this->request)->willReturn($product);
     $this->initializationHelper->expects($this->any())->method('initialize')->willReturn($product);
     $this->response->expects($this->once())->method('setBody')->willReturnSelf();
     $this->view->expects($this->once())->method('getLayout')->willReturn($layout);
     $layout->expects($this->once())->method('createBlock')->willReturn($block);
     $block->expects($this->once())->method('toHtml')->willReturnSelf();
     $this->controller->execute();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:FormTest.php

示例11: testExecute

 public function testExecute()
 {
     $firstElement = 'firstElement';
     $symbolsDataArray = [$firstElement];
     $redirectUrl = 'redirectUrl';
     $this->requestMock->expects($this->once())->method('getParam')->with('custom_currency_symbol')->willReturn($symbolsDataArray);
     $this->helperMock->expects($this->once())->method('getUrl')->with('*');
     $this->redirectMock->expects($this->once())->method('getRedirectUrl')->willReturn($redirectUrl);
     $this->currencySymbolMock->expects($this->once())->method('setCurrencySymbolsData')->with($symbolsDataArray);
     $this->responseMock->expects($this->once())->method('setRedirect');
     $this->filterManagerMock->expects($this->once())->method('stripTags')->with($firstElement)->willReturn($firstElement);
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\CurrencySymbol\\Model\\System\\Currencysymbol')->willReturn($this->currencySymbolMock);
     $this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Framework\\Filter\\FilterManager')->willReturn($this->filterManagerMock);
     $this->messageManagerMock->expects($this->once())->method('addSuccess')->with(__('You applied the custom currency symbols.'));
     $this->action->execute();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:SaveTest.php

示例12: testExecute

 /**
  * @param array $indexerIds
  * @param \Exception $exception
  * @param array $expectsExceptionValues
  * @dataProvider executeDataProvider
  */
 public function testExecute($indexerIds, $exception, $expectsExceptionValues)
 {
     $this->model = new \Magento\Indexer\Controller\Adminhtml\Indexer\MassChangelog($this->contextMock);
     $this->request->expects($this->any())->method('getParam')->with('indexer_ids')->will($this->returnValue($indexerIds));
     if (!is_array($indexerIds)) {
         $this->messageManager->expects($this->once())->method('addError')->with(__('Please select indexers.'))->will($this->returnValue(1));
     } else {
         $this->objectManager->expects($this->any())->method('get')->with('Magento\\Framework\\Indexer\\IndexerRegistry')->will($this->returnValue($this->indexReg));
         $indexerInterface = $this->getMockForAbstractClass('Magento\\Framework\\Indexer\\IndexerInterface', ['setScheduled'], '', false);
         $this->indexReg->expects($this->any())->method('get')->with(1)->will($this->returnValue($indexerInterface));
         if ($exception !== null) {
             $indexerInterface->expects($this->any())->method('setScheduled')->with(true)->will($this->throwException($exception));
         } else {
             $indexerInterface->expects($this->any())->method('setScheduled')->with(true)->will($this->returnValue(1));
         }
         $this->messageManager->expects($this->any())->method('addSuccess')->will($this->returnValue(1));
         if ($exception !== null) {
             $this->messageManager->expects($this->exactly($expectsExceptionValues[2]))->method('addError')->with($exception->getMessage());
             $this->messageManager->expects($this->exactly($expectsExceptionValues[1]))->method('addException')->with($exception, "We couldn't change indexer(s)' mode because of an error.");
         }
     }
     $this->helper->expects($this->any())->method("getUrl")->willReturn("magento.com");
     $this->response->expects($this->any())->method("setRedirect")->willReturn(1);
     $this->model->executeInternal();
 }
开发者ID:nblair,项目名称:magescotch,代码行数:31,代码来源:MassChangelogTest.php

示例13: prepareRedirect

 /**
  * @param string $path
  * @param array $arguments
  * @param int $index
  */
 protected function prepareRedirect($path, $arguments, $index)
 {
     $this->actionFlag->expects($this->any())->method('get')->with('', 'check_url_settings')->will($this->returnValue(true));
     $this->session->expects($this->any())->method('setIsUrlNotice')->with(true);
     $url = $path . '/' . (!empty($arguments) ? $arguments['shipment_id'] : '');
     $this->helper->expects($this->at($index))->method('getUrl')->with($path, $arguments)->will($this->returnValue($url));
     $this->response->expects($this->at($index))->method('setRedirect')->with($url);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:EmailTest.php

示例14: testAfterGetOutput

 /**
  * @param $cacheState
  * @param $layoutIsCacheable
  * @param $expectedTags
  * @param $configCacheType
  * @param $ttl
  * @dataProvider afterGetOutputDataProvider
  */
 public function testAfterGetOutput($cacheState, $layoutIsCacheable, $expectedTags, $configCacheType, $ttl)
 {
     $html = 'html';
     $this->configMock->expects($this->any())->method('isEnabled')->will($this->returnValue($cacheState));
     $blockStub = $this->getMock('Magento\\PageCache\\Test\\Unit\\Block\\Controller\\StubBlock', null, [], '', false);
     $blockStub->setTtl($ttl);
     $this->layoutMock->expects($this->once())->method('isCacheable')->will($this->returnValue($layoutIsCacheable));
     $this->layoutMock->expects($this->any())->method('getAllBlocks')->will($this->returnValue([$blockStub]));
     $this->configMock->expects($this->any())->method('getType')->will($this->returnValue($configCacheType));
     if ($layoutIsCacheable && $cacheState) {
         $this->responseMock->expects($this->once())->method('setHeader')->with('X-Magento-Tags', $expectedTags);
     } else {
         $this->responseMock->expects($this->never())->method('setHeader');
     }
     $output = $this->model->afterGetOutput($this->layoutMock, $html);
     $this->assertSame($output, $html);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:LayoutPluginTest.php

示例15: testRequestAction

 /**
  * Test the basic Request action.
  */
 public function testRequestAction()
 {
     $this->request->expects($this->any())->method('getMethod')->willReturn('GET');
     $this->helperMock->expects($this->once())->method('getRequestUrl');
     $this->helperMock->expects($this->once())->method('prepareRequest');
     $this->frameworkOauthSvcMock->expects($this->once())->method('getRequestToken')->willReturn(['response']);
     $this->response->expects($this->once())->method('setBody');
     $this->requestAction->execute();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:RequestTest.php


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