Example #1
0
 /**
  * @param array $data
  * @param array $convertedData
  * @param array $dataToAssign
  * @param array $checks
  * @dataProvider importDataPositiveCheckDataProvider
  */
 public function testImportDataPositiveCheck(array $data, array $convertedData, array $dataToAssign, array $checks)
 {
     $quoteId = 1;
     $storeId = 1;
     $paymentMethod = $this->getMock(MethodInterface::class);
     $quote = $this->getMockBuilder(Quote::class)->disableOriginalConstructor()->getMock();
     $methodSpecification = $this->getMockBuilder(Composite::class)->disableOriginalConstructor()->getMock();
     $quote->expects(static::once())->method('getId')->willReturn($quoteId);
     $this->model->setQuote($quote);
     $this->model->setMethodInstance($paymentMethod);
     $this->eventManager->expects(static::once())->method('dispatch')->with('sales_quote_payment_import_data_before', ['payment' => $this->model, 'input' => new DataObject($convertedData)]);
     $quote->expects(static::once())->method('getStoreId')->willReturn($storeId);
     $quote->expects(static::once())->method('collectTotals');
     $this->specificationFactory->expects(static::once())->method('create')->with($checks)->willReturn($methodSpecification);
     $paymentMethod->expects(static::once())->method('isAvailable')->with($quote)->willReturn(true);
     $methodSpecification->expects(static::once())->method('isApplicable')->with($paymentMethod, $quote)->willReturn(true);
     $paymentMethod->expects(static::once())->method('assignData')->with(new DataObject($dataToAssign));
     $paymentMethod->expects(static::once())->method('validate');
     $this->model->importData($data);
 }
Example #2
0
 /**
  * @param \Magento\Quote\Model\Quote\Payment $payment
  * @return $this
  */
 public function addPayment(\Magento\Quote\Model\Quote\Payment $payment)
 {
     $payment->setQuote($this);
     if (!$payment->getId()) {
         $this->getPaymentsCollection()->addItem($payment);
     }
     return $this;
 }