本文整理汇总了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);
}