本文整理匯總了PHP中Magento\Sales\Model\Order\Payment::setMethod方法的典型用法代碼示例。如果您正苦於以下問題:PHP Payment::setMethod方法的具體用法?PHP Payment::setMethod怎麽用?PHP Payment::setMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Sales\Model\Order\Payment
的用法示例。
在下文中一共展示了Payment::setMethod方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: initPayment
/**
* @param $context
*/
protected function initPayment($context)
{
$this->payment = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\Sales\\Model\\Order\\Payment', ['context' => $context, 'serviceOrderFactory' => $this->serviceOrderFactory, 'paymentData' => $this->helperMock, 'priceCurrency' => $this->priceCurrencyMock, 'transactionFactory' => $this->transactionFactory, 'transactionCollectionFactory' => $this->transactionCollectionFactory]);
$this->payment->setMethod('any');
$this->payment->setOrder($this->orderMock);
$this->transactionId = 100;
}
示例2: setUp
/**
* @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyFields)
*/
protected function setUp()
{
$this->eventManagerMock = $this->getMockBuilder('Magento\\Framework\\Event\\Manager')->disableOriginalConstructor()->getMock();
$this->mockContext = $this->getMockBuilder('Magento\\Framework\\Model\\Context')->disableOriginalConstructor()->getMock();
$this->mockContext->expects($this->atLeastOnce())->method('getEventDispatcher')->will($this->returnValue($this->eventManagerMock));
$this->helperMock = $this->getMockBuilder('Magento\\Payment\\Helper\\Data')->disableOriginalConstructor()->setMethods(['getMethodInstance'])->getMock();
$this->priceCurrencyMock = $this->getMockBuilder('Magento\\Directory\\Model\\PriceCurrency')->disableOriginalConstructor()->setMethods(['format'])->getMock();
$this->currencyMock = $this->getMockBuilder('Magento\\Directory\\Model\\Currency')->disableOriginalConstructor()->setMethods(['formatTxt'])->getMock();
$transaction = 'Magento\\Sales\\Model\\Order\\Payment\\Transaction\\Repository';
$this->transactionRepositoryMock = $this->getMockBuilder($transaction)->disableOriginalConstructor()->setMethods(['get', 'getByTransactionType', 'getByTransactionId'])->getMock();
$this->paymentProcessor = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Processor', [], [], '', false);
$this->orderRepository = $this->getMock('Magento\\Sales\\Model\\OrderRepository', ['get'], [], '', false);
$this->priceCurrencyMock->expects($this->any())->method('format')->willReturnCallback(function ($value) {
return $value;
});
$this->paymentMethodMock = $this->getMockBuilder('Magento\\Payment\\Model\\Method\\AbstractMethod')->disableOriginalConstructor()->setMethods(['canVoid', 'authorize', 'getConfigData', 'getConfigPaymentAction', 'validate', 'setStore', 'acceptPayment', 'denyPayment', 'fetchTransactionInfo', 'canCapture', 'canRefund', 'canOrder', 'order', 'isInitializeNeeded', 'initialize', 'refund'])->getMock();
$this->invoiceMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->setMethods(['getTransactionId', 'load', 'getId', 'pay', 'cancel', 'getGrandTotal', 'getBaseGrandTotal', 'getShippingAmount', 'getBaseShippingAmount', 'getBaseTotalRefunded', 'getItemsCollection', 'getOrder', 'register', 'capture'])->getMock();
$this->helperMock->method('getMethodInstance')->will($this->returnValue($this->paymentMethodMock));
$this->orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['getConfig', 'setState', 'setStatus', 'getStoreId', 'getBaseGrandTotal', 'getBaseCurrency', 'getBaseCurrencyCode', 'getTotalDue', 'getBaseTotalDue', 'getInvoiceCollection', 'addRelatedObject', 'getState', 'getStatus', 'addStatusHistoryComment', 'registerCancellation', 'getCustomerNote', 'prepareInvoice', 'getPaymentsCollection'])->getMock();
$this->transactionCollectionFactory = $this->getMock('Magento\\Sales\\Model\\ResourceModel\\Order\\Payment\\Transaction\\CollectionFactory', ['create'], [], '', false);
$this->creditmemoFactoryMock = $this->getMock('Magento\\Sales\\Model\\Order\\CreditmemoFactory', [], [], '', false);
$this->transactionManagerMock = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction\\Manager', [], [], '', false);
$this->transactionBuilderMock = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction\\Builder', [], [], '', false);
$this->creditMemoMock = $this->getMock('Magento\\Sales\\Model\\Order\\Creditmemo', ['setPaymentRefundDisallowed', 'getItemsCollection', 'getItems', 'setAutomaticallyCreated', 'register', 'addComment', 'save', 'getGrandTotal', 'getBaseGrandTotal', 'getDoTransaction', 'getInvoice'], [], '', false);
$this->payment = $this->initPayment();
$this->payment->setMethod('any');
$this->payment->setOrder($this->orderMock);
$this->transactionId = self::TRANSACTION_ID;
}
示例3: setUp
protected function setUp()
{
$this->eventManagerMock = $this->getMockBuilder('Magento\\Framework\\Event\\Manager')->disableOriginalConstructor()->getMock();
$context = $this->getMockBuilder('Magento\\Framework\\Model\\Context')->disableOriginalConstructor()->getMock();
$context->expects($this->once())->method('getEventDispatcher')->will($this->returnValue($this->eventManagerMock));
$this->helperMock = $this->getMockBuilder('Magento\\Payment\\Helper\\Data')->disableOriginalConstructor()->setMethods(['getMethodInstance'])->getMock();
$this->priceCurrencyMock = $this->getMockBuilder('Magento\\Directory\\Model\\PriceCurrency')->disableOriginalConstructor()->setMethods(['format'])->getMock();
$this->priceCurrencyMock->expects($this->any())->method('format')->willReturnCallback(function ($value) {
return $value;
});
$this->paymentMethodMock = $this->getMockBuilder('Magento\\Payment\\Model\\Method\\AbstractMethod')->disableOriginalConstructor()->setMethods(['canVoid', 'authorize', 'getConfigData', 'getConfigPaymentAction', 'validate'])->getMock();
$this->helperMock->expects($this->once())->method('getMethodInstance')->will($this->returnValue($this->paymentMethodMock));
$this->orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['getConfig', 'setState', 'getStoreId', 'getBaseGrandTotal', 'getBaseCurrency', 'getBaseCurrencyCode', 'getTotalDue', 'getBaseTotalDue'])->getMock();
$this->payment = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\Sales\\Model\\Order\\Payment', ['context' => $context, 'paymentData' => $this->helperMock, 'priceCurrency' => $this->priceCurrencyMock]);
$this->payment->setMethod('any');
$this->payment->setOrder($this->orderMock);
}
示例4: setMethod
/**
* {@inheritdoc}
*/
public function setMethod($method)
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'setMethod');
if (!$pluginInfo) {
return parent::setMethod($method);
} else {
return $this->___callPlugins('setMethod', func_get_args(), $pluginInfo);
}
}