コード例 #1
0
 public function testMap()
 {
     $methods = ['getCustomerId', 'getCustomerEmail', 'getCustomerGroupId', 'getCustomerTaxClassId', 'getCustomerPrefix', 'getCustomerFirstname', 'getCustomerMiddlename', 'getCustomerLastname', 'getCustomerSuffix', 'getCustomerDob', 'getCustomerNote', 'getCustomerNoteNotify', 'getCustomerIsGuest', 'getCustomerGender', 'getCustomerTaxvat', '__wakeUp'];
     $quoteMock = $this->getMock('Magento\\Sales\\Model\\Quote', $methods, [], '', false);
     $expected = [Customer::ID => 10, Customer::EMAIL => '*****@*****.**', Customer::GROUP_ID => '4', Customer::TAX_CLASS_ID => 10, Customer::PREFIX => 'prefix_', Customer::FIRST_NAME => 'First Name', Customer::MIDDLE_NAME => 'Middle Name', Customer::LAST_NAME => 'Last Name', Customer::SUFFIX => 'suffix', Customer::DOB => '1/1/1989', Customer::NOTE => 'customer_note', Customer::NOTE_NOTIFY => 'note_notify', Customer::IS_GUEST => false, Customer::GENDER => 'male', Customer::TAXVAT => 'taxvat'];
     $expectedMethods = ['getCustomerId' => 10, 'getCustomerEmail' => '*****@*****.**', 'getCustomerGroupId' => 4, 'getCustomerTaxClassId' => 10, 'getCustomerPrefix' => 'prefix_', 'getCustomerFirstname' => 'First Name', 'getCustomerMiddlename' => 'Middle Name', 'getCustomerLastname' => 'Last Name', 'getCustomerSuffix' => 'suffix', 'getCustomerDob' => '1/1/1989', 'getCustomerNote' => 'customer_note', 'getCustomerNoteNotify' => 'note_notify', 'getCustomerIsGuest' => false, 'getCustomerGender' => 'male', 'getCustomerTaxvat' => 'taxvat'];
     foreach ($expectedMethods as $method => $value) {
         $quoteMock->expects($this->once())->method($method)->will($this->returnValue($value));
     }
     $this->assertEquals($expected, $this->mapper->map($quoteMock));
 }
コード例 #2
0
ファイル: ReadService.php プロジェクト: aiesh/magento2
 /**
  * Create cart data object based on given quote
  *
  * @param Quote $quote
  * @return Cart
  */
 protected function createCartDataObject(Quote $quote)
 {
     $this->cartBuilder->populateWithArray($this->cartMapper->map($quote));
     $this->customerBuilder->populateWithArray($this->customerMapper->map($quote));
     $this->totalsBuilder->populateWithArray($this->totalsMapper->map($quote));
     $this->totalsBuilder->setItems($this->fetchItemTotalsData($quote));
     $this->cartBuilder->setCustomer($this->customerBuilder->create());
     $this->cartBuilder->setTotals($this->totalsBuilder->create());
     $this->cartBuilder->setCurrency($this->currencyMapper->extractDto($quote));
     return $this->cartBuilder->create();
 }
コード例 #3
0
ファイル: CartMapper.php プロジェクト: zhangjiachao/magento2
 /**
  * Fetch base quote data and map it to DTO fields
  *
  * @param Quote $quote
  * @return array
  */
 public function map(Quote $quote)
 {
     $this->cartBuilder->populateWithArray([Cart::ID => $quote->getId(), Cart::STORE_ID => $quote->getStoreId(), Cart::CREATED_AT => $quote->getCreatedAt(), Cart::UPDATED_AT => $quote->getUpdatedAt(), Cart::CONVERTED_AT => $quote->getConvertedAt(), Cart::IS_ACTIVE => $quote->getIsActive(), Cart::IS_VIRTUAL => $quote->getIsVirtual(), Cart::ITEMS_COUNT => $quote->getItemsCount(), Cart::ITEMS_QUANTITY => $quote->getItemsQty(), Cart::CHECKOUT_METHOD => $quote->getCheckoutMethod(), Cart::RESERVED_ORDER_ID => $quote->getReservedOrderId(), Cart::ORIG_ORDER_ID => $quote->getOrigOrderId()]);
     $this->customerBuilder->populateWithArray($this->customerMapper->map($quote));
     $this->totalsBuilder->populateWithArray($this->totalsMapper->map($quote));
     $items = [];
     foreach ($quote->getAllItems() as $item) {
         $items[] = $this->itemTotalsMapper->extractDto($item);
     }
     $this->totalsBuilder->setItems($items);
     $this->cartBuilder->setCustomer($this->customerBuilder->create());
     $this->cartBuilder->setTotals($this->totalsBuilder->create());
     $this->cartBuilder->setCurrency($this->currencyMapper->extractDto($quote));
     return $this->cartBuilder->create();
 }