Esempio n. 1
0
 /**
  * Set proper value of X-Magento-Vary cookie.
  *
  * @param \Magento\Framework\App\Response\Http $subject
  * @return void
  */
 public function beforeSendResponse(\Magento\Framework\App\Response\Http $subject)
 {
     if ($subject instanceof \Magento\Framework\App\PageCache\NotCacheableInterface) {
         return;
     }
     $subject->sendVary();
 }
Esempio n. 2
0
 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();
 }
Esempio n. 3
0
 /**
  * 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());
 }
 /**
  * Perform action and generate response
  *
  * @param RequestInterface $request
  * @return ResponseInterface|\Magento\Framework\Controller\ResultInterface
  * @throws \LogicException
  */
 public function dispatch(RequestInterface $request)
 {
     \Magento\Framework\Profiler::start('routers_match');
     $routingCycleCounter = 0;
     $result = null;
     while (!$request->isDispatched() && $routingCycleCounter++ < 100) {
         /** @var \Magento\Framework\App\RouterInterface $router */
         foreach ($this->_routerList as $router) {
             try {
                 $actionInstance = $router->match($request);
                 if ($actionInstance) {
                     $request->setDispatched(true);
                     $this->response->setNoCacheHeaders();
                     if ($actionInstance instanceof \Magento\Framework\App\Action\AbstractAction) {
                         $result = $actionInstance->dispatch($request);
                     } else {
                         $result = $actionInstance->execute();
                     }
                     break;
                 }
             } catch (\Magento\Framework\Exception\NotFoundException $e) {
                 $request->initForward();
                 $request->setActionName('noroute');
                 $request->setDispatched(false);
                 break;
             }
         }
     }
     \Magento\Framework\Profiler::stop('routers_match');
     if ($routingCycleCounter > 100) {
         throw new \LogicException('Front controller reached 100 router match iterations');
     }
     return $result;
 }
 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);
 }
 /**
  * @param \Magento\Framework\App\Response\Http $subject
  * @return void
  * @codeCoverageIgnore
  */
 public function beforeSendResponse(\Magento\Framework\App\Response\Http $subject)
 {
     foreach ($this->headerProviders as $provider) {
         if ($provider->canApply()) {
             $subject->setHeader($provider->getName(), $provider->getValue());
         }
     }
 }
 /**
  * @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);
 }
Esempio n. 8
0
 public function testExecute()
 {
     $this->_getTreeBlock();
     $testHtml = '<div>Some test html</div>';
     $this->chooserBlockMock->expects($this->once())->method('toHtml')->will($this->returnValue($testHtml));
     $this->responseMock->expects($this->once())->method('setBody')->with($this->equalTo($testHtml));
     $this->controller->execute();
 }
Esempio n. 9
0
 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();
 }
Esempio n. 10
0
 /**
  * @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $resultCollection
  * @param \Magento\Catalog\Block\Product\ListProduct $subject
  * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection $resultCollection
  */
 public function afterGetLoadedProductCollection(\Magento\Catalog\Block\Product\ListProduct $subject, $resultCollection)
 {
     if ($resultCollection->count() == 1) {
         /** @var \Magento\Catalog\Model\Product $product */
         $product = $resultCollection->getFirstItem();
         $this->response->setRedirect($product->getProductUrl());
     }
     return $resultCollection;
 }
Esempio n. 11
0
 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());
 }
Esempio n. 12
0
 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();
 }
Esempio n. 13
0
 /**
  * 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());
 }
 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));
 }
Esempio n. 15
0
 /**
  * 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());
 }
Esempio n. 16
0
 /**
  * Test setting body in JSON format
  */
 public function testRepresentJson()
 {
     $this->_model->setHeader('Content-Type', 'text/javascript');
     $this->_model->representJson('json_string');
     $this->assertEquals('application/json', $this->_model->getHeader('Content-Type')['value']);
     $this->assertEquals('json_string', $this->_model->getBody('default'));
 }
Esempio n. 17
0
 /**
  * Run test execute method (fail generate label)
  */
 public function testExecuteLabelGenerateFail()
 {
     $this->shipmentLoaderMock->expects($this->once())->method('load')->will($this->returnValue($this->shipmentMock));
     $this->labelGenerator->expects($this->once())->method('create')->with($this->shipmentMock, $this->requestMock)->will($this->throwException(new \Magento\Framework\Model\Exception()));
     $this->responseMock->expects($this->once())->method('representJson');
     $this->assertNull($this->controller->execute());
 }
Esempio n. 18
0
 /**
  * Call method around dispatch frontend action
  *
  * @param FrontControllerInterface $subject
  * @param \Closure                 $proceed
  * @param RequestInterface         $request
  * @return $this
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @SuppressWarnings(PHPMD)
  */
 public function aroundDispatch(FrontControllerInterface $subject, \Closure $proceed, RequestInterface $request)
 {
     $startTime = microtime(true);
     if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
         $startTime = $_SERVER['REQUEST_TIME_FLOAT'];
     }
     /** @var \Magento\Framework\App\Request\Http $request */
     if (strpos($request->getOriginalPathInfo(), 'searchautocomplete/ajax/suggest') !== false) {
         $this->result->init();
         $proceed($request);
         #require for init translations
         $request->setControllerModule('Magento_CatalogSearch');
         $request->setDispatched(true);
         $identifier = 'QUERY_' . $this->storeManager->getStore()->getId() . '_' . md5($request->getParam('q'));
         if ($result = $this->cache->load($identifier)) {
             $result = \Zend_Json::decode($result);
             $result['time'] = round(microtime(true) - $startTime, 4);
             $result['cache'] = true;
             $data = \Zend_Json::encode($result);
         } else {
             // mirasvit core event
             $this->eventManager->dispatch('core_register_urlrewrite');
             $result = $this->result->toArray();
             $result['success'] = true;
             $result['time'] = round(microtime(true) - $startTime, 4);
             $result['cache'] = false;
             $data = \Zend_Json::encode($result);
             $this->cache->save($data, $identifier, [\Magento\PageCache\Model\Cache\Type::CACHE_TAG]);
         }
         $this->response->setPublicHeaders(3600);
         return $this->response->representJson($data);
     } else {
         return $proceed($request);
     }
 }
 /**
  * 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');
 }
 /**
  * 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());
 }
Esempio n. 21
0
 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();
 }
Esempio n. 22
0
 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();
 }
Esempio n. 23
0
 /**
  * Send response
  *
  * @return void
  */
 public function sendResponse()
 {
     if ($this->_filePath && $this->getHttpResponseCode() == 200) {
         $this->_transferAdapter->send($this->_filePath);
     } else {
         parent::sendResponse();
     }
 }
Esempio n. 24
0
 /**
  * Test for the magic method __wakeup
  *
  * @covers \Magento\Framework\App\Response\Http::__wakeup
  */
 public function testWakeUpWith()
 {
     $objectManagerMock = $this->getMock('Magento\\Framework\\App\\ObjectManager', [], [], '', false);
     $objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\Stdlib\\CookieManager')->will($this->returnValue($this->cookieManagerMock));
     $objectManagerMock->expects($this->once())->method('get')->with('Magento\\Framework\\Stdlib\\Cookie\\CookieMetadataFactory')->will($this->returnValue($this->cookieMetadataFactoryMock));
     \Magento\Framework\App\ObjectManager::setInstance($objectManagerMock);
     $this->model->__wakeup();
 }
Esempio n. 25
0
 /**
  * Handler for session errors
  *
  * @param \Exception $exception
  * @return bool
  */
 private function handleSessionException(\Exception $exception)
 {
     if ($exception instanceof \Magento\Framework\Exception\SessionException) {
         $this->_response->setRedirect($this->_request->getDistroBaseUrl());
         $this->_response->sendHeaders();
         return true;
     }
     return false;
 }
Esempio n. 26
0
 /**
  * {@inheritdoc}
  */
 public function sendResponse()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'sendResponse');
     if (!$pluginInfo) {
         return parent::sendResponse();
     } else {
         return $this->___callPlugins('sendResponse', func_get_args(), $pluginInfo);
     }
 }
Esempio n. 27
0
 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();
 }
Esempio n. 28
0
 /**
  * Handler for session errors
  *
  * @param Bootstrap $bootstrap
  * @param \Exception $exception
  * @return bool
  */
 private function handleSessionException(Bootstrap $bootstrap, \Exception $exception)
 {
     if ($exception instanceof \Magento\Framework\Session\Exception) {
         $path = $this->getBaseUrlPath($bootstrap->getParams());
         $this->_response->setRedirect($path);
         $this->_response->sendHeaders();
         return true;
     }
     return false;
 }
Esempio n. 29
0
 /**
  * Run fall-back correction
  *
  * @return bool
  */
 public function doFallbackCorrection()
 {
     $queryText = $this->queryHelper->getQueryText();
     $fallbackText = $this->queryHelper->fallback($queryText);
     if ($fallbackText && $fallbackText != $queryText && $fallbackText != $this->queryHelper->getFallbackText()) {
         $url = $this->queryHelper->getFallbackUrl($queryText, $fallbackText);
         $this->response->setRedirect($url);
         return true;
     }
     return false;
 }
Esempio n. 30
0
 /**
  * @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);
 }