/**
  * Creates Payment Data Object
  *
  * @param InfoInterface $paymentInfo
  * @return PaymentDataObjectInterface
  */
 public function create(InfoInterface $paymentInfo)
 {
     if ($paymentInfo instanceof Payment) {
         $data['order'] = $this->orderAdapterFactory->create(['order' => $paymentInfo->getOrder()]);
     } elseif ($paymentInfo instanceof \Magento\Quote\Model\Quote\Payment) {
         $data['order'] = $this->quoteAdapterFactory->create(['quote' => $paymentInfo->getQuote()]);
     }
     $data['payment'] = $paymentInfo;
     return $this->objectManager->create('Magento\\Payment\\Gateway\\Data\\PaymentDataObject', $data);
 }
 public function testCreatePaymentDataObjectFromOrder()
 {
     /** @var Order $orderMock */
     $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     /** @var OrderAdapter $orderAdapterMock */
     $orderAdapterMock = $this->getMockBuilder('Magento\\Payment\\Gateway\\Data\\Order\\OrderAdapter')->disableOriginalConstructor()->getMock();
     /** @var \Magento\Sales\Model\Order\Payment $paymentInfoMock */
     $paymentInfoMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment')->disableOriginalConstructor()->getMock();
     $paymentInfoMock->expects($this->once())->method('getOrder')->willReturn($orderMock);
     $this->orderAdapterFactoryMock->expects($this->once())->method('create')->with(['order' => $orderMock])->willReturn($orderAdapterMock);
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Payment\\Gateway\\Data\\PaymentDataObject', ['order' => $orderAdapterMock, 'payment' => $paymentInfoMock])->willReturn($this->paymentDataObjectMock);
     $this->assertSame($this->paymentDataObjectMock, $this->model->create($paymentInfoMock));
 }