public function testCreatePaymentDataObjectFromQuote() { /** @var \Magento\Quote\Model\Quote $quoteMock */ $quoteMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->getMock(); /** @var OrderAdapter $orderAdapterMock */ $quoteAdapterMock = $this->getMockBuilder('Magento\\Payment\\Gateway\\Data\\Quote\\QuoteAdapter')->disableOriginalConstructor()->getMock(); /** @var \Magento\Quote\Model\Quote\Payment $paymentInfoMock */ $paymentInfoMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Payment')->disableOriginalConstructor()->getMock(); $paymentInfoMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); $this->quoteAdapterFactoryMock->expects($this->once())->method('create')->with(['quote' => $quoteMock])->willReturn($quoteAdapterMock); $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Payment\\Gateway\\Data\\PaymentDataObject', ['order' => $quoteAdapterMock, 'payment' => $paymentInfoMock])->willReturn($this->paymentDataObjectMock); $this->assertSame($this->paymentDataObjectMock, $this->model->create($paymentInfoMock)); }
/** * Performs command * * @param string $commandCode * @param InfoInterface $payment * @param array $arguments * @return void * @throws NotFoundException * @throws \Exception */ private function executeCommand($commandCode, InfoInterface $payment, array $arguments = []) { if ($this->canPerformCommand($commandCode)) { try { $command = $this->commandPool->get($commandCode); $arguments['payment'] = $this->paymentDataObjectFactory->create($payment); $command->execute($arguments); } catch (NotFoundException $e) { throw $e; } } }
/** * {inheritdoc} */ public function getConfigData($field, $storeId = null) { if ($storeId === null) { return $this->getConfiguredValue($field); } $subject = ['field' => $field]; if ($this->getInfoInstance()) { $subject['payment'] = $this->paymentDataObjectFactory->create($this->getInfoInstance()); } $handler = $this->valueHandlerPool->get($field); return $handler->handle($subject, (int) $storeId); }
/** * Performs command * * @param string $commandCode * @param InfoInterface $payment * @param array $arguments * @return void * @throws NotFoundException * @throws \Exception * @throws \DomainException */ private function executeCommand($commandCode, InfoInterface $payment, array $arguments = []) { if ($this->canPerformCommand($commandCode)) { if ($this->commandPool === null) { throw new \DomainException('Command pool is not configured for use.'); } try { $command = $this->commandPool->get($commandCode); $arguments['payment'] = $this->paymentDataObjectFactory->create($payment); $command->execute($arguments); } catch (NotFoundException $e) { throw $e; } } }
/** * @inheritdoc */ private function executeCommand($commandCode, array $arguments = []) { if (!$this->canPerformCommand($commandCode)) { return null; } if (isset($arguments['payment'])) { $arguments['payment'] = $this->paymentDataObjectFactory->create($arguments['payment']); } if ($this->commandExecutor !== null) { return $this->commandExecutor->executeByCode($commandCode, $arguments); } if ($this->commandPool === null) { throw new \DomainException('Command pool is not configured for use.'); } $command = $this->commandPool->get($commandCode); return $command->execute($arguments); }
/** * @inheritdoc */ public function executeCommand($commandCode, array $arguments = []) { if ($this->canPerformCommand($commandCode)) { if ($this->commandPool === null) { throw new \DomainException('Command pool is not configured for use.'); } try { $command = $this->commandPool->get($commandCode); if (isset($arguments['payment'])) { $arguments['payment'] = $this->paymentDataObjectFactory->create($arguments['payment']); } return $command->execute($arguments); } catch (NotFoundException $e) { throw $e; } } return null; }