Example #1
0
 /**
  * @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;
 }
 /**
  * @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;
 }
Example #3
0
 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);
 }
 /**
  * {@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);
     }
 }