コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function getResponse()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getResponse');
     if (!$pluginInfo) {
         return parent::getResponse();
     } else {
         return $this->___callPlugins('getResponse', func_get_args(), $pluginInfo);
     }
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'dispatch');
     if (!$pluginInfo) {
         return parent::dispatch($request);
     } else {
         return $this->___callPlugins('dispatch', func_get_args(), $pluginInfo);
     }
 }
コード例 #3
0
 public function testExecuteLinkTypeFile()
 {
     $sampleMock = $this->getMockBuilder('Magento\\Downloadable\\Model\\Sample')->disableOriginalConstructor()->setMethods(['getId', 'load', 'getSampleType', 'getSampleUrl', 'getBaseSamplePath'])->getMock();
     $fileHelperMock = $this->getMockBuilder('Magento\\Downloadable\\Helper\\File')->disableOriginalConstructor()->setMethods(['getFilePath'])->getMock();
     $this->request->expects($this->once())->method('getParam')->with('sample_id', 0)->willReturn('some_sample_id');
     $this->objectManager->expects($this->at(0))->method('create')->with('Magento\\Downloadable\\Model\\Sample')->willReturn($sampleMock);
     $sampleMock->expects($this->once())->method('load')->with('some_sample_id')->willReturnSelf();
     $sampleMock->expects($this->once())->method('getId')->willReturn('some_sample_id');
     $sampleMock->expects($this->any())->method('getSampleType')->willReturn(\Magento\Downloadable\Helper\Download::LINK_TYPE_FILE);
     $this->objectManager->expects($this->at(1))->method('get')->with('Magento\\Downloadable\\Helper\\File')->willReturn($fileHelperMock);
     $fileHelperMock->expects($this->once())->method('getFilePath')->willReturn('file_path');
     $this->objectManager->expects($this->at(2))->method('get')->with('Magento\\Downloadable\\Helper\\Download')->willReturn($this->downloadHelper);
     $this->response->expects($this->once())->method('setHttpResponseCode')->with(200)->willReturnSelf();
     $this->response->expects($this->any())->method('setHeader')->willReturnSelf();
     $this->downloadHelper->expects($this->once())->method('output')->willThrowException(new \Exception());
     $this->messageManager->expects($this->once())->method('addError')->with('Sorry, there was an error getting requested content. Please contact the store owner.')->willReturnSelf();
     $this->redirect->expects($this->once())->method('getRedirectUrl')->willReturn('redirect_url');
     $this->response->expects($this->once())->method('setRedirect')->with('redirect_url')->willReturnSelf();
     $this->assertEquals($this->response, $this->sample->execute());
 }