Esempio n. 1
0
 /**
  * @inheritdoc
  */
 public function getDataForOrderCreate(\Magento\Sales\Model\Order $order)
 {
     $data = ['products' => $this->dataGetter->getProductsData($order)];
     $shippingData = $this->dataGetter->getShippingData($order);
     if ($shippingData) {
         $data['products'][] = $shippingData;
     }
     $buyerData = $this->dataGetter->getBuyerData($order);
     if ($buyerData) {
         $data['buyer'] = $buyerData;
     }
     $basicData = $this->dataGetter->getBasicData($order);
     return array_merge($basicData, $data);
 }
 public function testGetBuyerData()
 {
     $email = '*****@*****.**';
     $phone = '500 123 456';
     $firstname = 'Jan';
     $lastname = 'Kowalski';
     $order = $this->getMockBuilder(\Magento\Sales\Model\Order::class)->disableOriginalConstructor()->getMock();
     $orderAddress = $this->getMockBuilder(\Magento\Sales\Api\Data\OrderAddressInterface::class)->getMockForAbstractClass();
     $orderAddress->expects($this->once())->method('getEmail')->willReturn($email);
     $orderAddress->expects($this->once())->method('getTelephone')->willReturn($phone);
     $orderAddress->expects($this->once())->method('getFirstname')->willReturn($firstname);
     $orderAddress->expects($this->once())->method('getLastname')->willReturn($lastname);
     $order->expects($this->once())->method('getBillingAddress')->willReturn($orderAddress);
     $this->assertEquals(['email' => $email, 'phone' => $phone, 'firstName' => $firstname, 'lastName' => $lastname], $this->model->getBuyerData($order));
 }