当前位置: 首页>>代码示例>>PHP>>正文


PHP Invoice::getData方法代码示例

本文整理汇总了PHP中Magento\Sales\Model\Order\Invoice::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP Invoice::getData方法的具体用法?PHP Invoice::getData怎么用?PHP Invoice::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Sales\Model\Order\Invoice的用法示例。


在下文中一共展示了Invoice::getData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCollect

 /**
  * @param array $orderData
  * @param array $invoiceData
  * @param array $expectedResults
  * @dataProvider collectDataProvider
  */
 public function testCollect($orderData, $invoiceData, $expectedResults)
 {
     $roundingDelta = [];
     $this->setupOrder($orderData);
     //Set up weeeData mock
     $this->weeeData->expects($this->once())->method('includeInSubtotal')->will($this->returnValue($invoiceData['include_in_subtotal']));
     //Set up invoice mock
     /** @var \Magento\Sales\Model\Order\Invoice\Item[] $invoiceItems */
     $invoiceItems = [];
     foreach ($invoiceData['items'] as $itemKey => $invoiceItemData) {
         $invoiceItems[$itemKey] = $this->getInvoiceItem($invoiceItemData);
     }
     $this->invoice->expects($this->once())->method('getAllItems')->will($this->returnValue($invoiceItems));
     $this->invoice->expects($this->once())->method('isLast')->will($this->returnValue($invoiceData['is_last']));
     foreach ($invoiceData['data_fields'] as $key => $value) {
         $this->invoice->setData($key, $value);
     }
     $this->invoice->expects($this->any())->method('roundPrice')->will($this->returnCallback(function ($price, $type) use(&$roundingDelta) {
         if (!isset($roundingDelta[$type])) {
             $roundingDelta[$type] = 0;
         }
         $roundedPrice = round($price + $roundingDelta[$type], 2);
         $roundingDelta[$type] = $price - $roundedPrice;
         return $roundedPrice;
     }));
     $this->model->collect($this->invoice);
     //verify invoice data
     foreach ($expectedResults['invoice_data'] as $key => $value) {
         $this->assertEquals($value, $this->invoice->getData($key), 'Invoice data field ' . $key . ' is incorrect');
     }
     //verify invoice item data
     foreach ($expectedResults['invoice_items'] as $itemKey => $itemData) {
         $invoiceItem = $invoiceItems[$itemKey];
         foreach ($itemData as $key => $value) {
             if ($key == 'tax_ratio') {
                 $taxRatio = unserialize($invoiceItem->getData($key));
                 $expectedTaxRatio = unserialize($itemData[$key]);
                 $this->assertEquals($expectedTaxRatio['weee'], $taxRatio['weee'], "Tax ratio is incorrect");
             } else {
                 $this->assertEquals($value, $invoiceItem->getData($key), 'Invoice item field ' . $key . ' is incorrect');
             }
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:50,代码来源:WeeeTest.php

示例2: extractDto

 /**
  * @param \Magento\Sales\Model\Order\Invoice $object
  * @return \Magento\Framework\Service\Data\AbstractExtensibleObject
  */
 public function extractDto(\Magento\Sales\Model\Order\Invoice $object)
 {
     $this->invoiceBuilder->populateWithArray($object->getData());
     $this->invoiceBuilder->setItems($this->getItems($object));
     return $this->invoiceBuilder->create();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:10,代码来源:InvoiceMapper.php


注:本文中的Magento\Sales\Model\Order\Invoice::getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。