當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Observer::addAdditionalFieldsToResponseFrontend方法代碼示例

本文整理匯總了PHP中Observer::addAdditionalFieldsToResponseFrontend方法的典型用法代碼示例。如果您正苦於以下問題:PHP Observer::addAdditionalFieldsToResponseFrontend方法的具體用法?PHP Observer::addAdditionalFieldsToResponseFrontend怎麽用?PHP Observer::addAdditionalFieldsToResponseFrontend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Observer的用法示例。


在下文中一共展示了Observer::addAdditionalFieldsToResponseFrontend方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testAddAdditionalFieldsToResponseFrontend

 public function testAddAdditionalFieldsToResponseFrontend()
 {
     $directpostRequest = $this->getMock('Magento\\Authorizenet\\Model\\Directpost\\Request', array());
     $order = $this->getMock('Magento\\Sales\\Model\\Order', array(), array(), '', false);
     $methodInstance = $this->getMock('Magento\\Authorizenet\\Model\\Directpost', array(), array(), '', false);
     $methodInstance->expects($this->once())->method('generateRequestFromOrder')->with($this->identicalTo($order))->will($this->returnValue($directpostRequest));
     $payment = $this->getMock('Magento\\Sales\\Model\\Order\\Payment', array('getMethodInstance', '__wakeup'), array(), '', false);
     $payment->expects($this->once())->method('getMethodInstance')->will($this->returnValue($methodInstance));
     $payment->setMethod('authorizenet_directpost');
     $order->expects($this->once())->method('getId')->will($this->returnValue(1));
     $order->expects($this->atLeastOnce())->method('getPayment')->will($this->returnValue($payment));
     $this->coreRegistry->expects($this->once())->method('registry')->with('directpost_order')->will($this->returnValue($order));
     $request = new \Magento\Framework\Object();
     $response = $this->getMock('Magento\\Framework\\App\\Response\\Http', array(), array(), '', false);
     $controller = $this->getMock('Magento\\Checkout\\Controller\\Action', array('getRequest', 'getResponse'), array(), '', false);
     $controller->expects($this->once())->method('getRequest')->will($this->returnValue($request));
     $controller->expects($this->once())->method('getResponse')->will($this->returnValue($response));
     $observer = new \Magento\Framework\Event\Observer(array('event' => new \Magento\Framework\Object(array('controller_action' => $controller))));
     $this->coreData->expects($this->once())->method('jsonEncode')->with(self::logicalNot(self::isEmpty()))->will($this->returnValue('encoded response'));
     $response->expects($this->once())->method('clearHeader')->with('Location');
     $response->expects($this->once())->method('representJson')->with('encoded response');
     $this->model->addAdditionalFieldsToResponseFrontend($observer);
 }
開發者ID:buskamuza,項目名稱:magento2-skeleton,代碼行數:23,代碼來源:ObserverTest.php


注:本文中的Observer::addAdditionalFieldsToResponseFrontend方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。