當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Creditmemo::getData方法代碼示例

本文整理匯總了PHP中Magento\Sales\Model\Order\Creditmemo::getData方法的典型用法代碼示例。如果您正苦於以下問題:PHP Creditmemo::getData方法的具體用法?PHP Creditmemo::getData怎麽用?PHP Creditmemo::getData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Sales\Model\Order\Creditmemo的用法示例。


在下文中一共展示了Creditmemo::getData方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testCollect

 /**
  * @param array $creditmemoData
  * @param array $expectedResults
  * @dataProvider collectDataProvider
  */
 public function testCollect($creditmemoData, $expectedResults)
 {
     $roundingDelta = [];
     //Set up weeeData mock
     $this->weeeData->expects($this->once())->method('includeInSubtotal')->will($this->returnValue($creditmemoData['include_in_subtotal']));
     //Set up invoice mock
     /** @var \Magento\Sales\Model\Order\Invoice\Item[] $creditmemoItems */
     $creditmemoItems = [];
     foreach ($creditmemoData['items'] as $itemKey => $creditmemoItemData) {
         $creditmemoItems[$itemKey] = $this->getInvoiceItem($creditmemoItemData);
     }
     $this->creditmemo->expects($this->once())->method('getAllItems')->will($this->returnValue($creditmemoItems));
     foreach ($creditmemoData['data_fields'] as $key => $value) {
         $this->creditmemo->setData($key, $value);
     }
     $this->creditmemo->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->creditmemo);
     //verify invoice data
     foreach ($expectedResults['creditmemo_data'] as $key => $value) {
         $this->assertEquals($value, $this->creditmemo->getData($key), 'Creditmemo data field ' . $key . ' is incorrect');
     }
     //verify invoice item data
     foreach ($expectedResults['creditmemo_items'] as $itemKey => $itemData) {
         $creditmemoItem = $creditmemoItems[$itemKey];
         foreach ($itemData as $key => $value) {
             if ($key == 'tax_ratio') {
                 $taxRatio = unserialize($creditmemoItem->getData($key));
                 $expectedTaxRatio = unserialize($itemData[$key]);
                 $this->assertEquals($expectedTaxRatio['weee'], $taxRatio['weee'], "Tax ratio is incorrect");
             } else {
                 $this->assertEquals($value, $creditmemoItem->getData($key), 'Creditmemo item field ' . $key . ' is incorrect');
             }
         }
     }
 }
開發者ID:,項目名稱:,代碼行數:47,代碼來源:

示例2: testCollect

 /**
  * @param array $orderData
  * @param array $creditmemoData
  * @param array $expectedResults
  * @dataProvider collectDataProvider
  */
 public function testCollect($orderData, $creditmemoData, $expectedResults)
 {
     $roundingDelta = [];
     //Set up order mock
     foreach ($orderData['data_fields'] as $key => $value) {
         $this->order->setData($key, $value);
     }
     //Set up creditmemo mock
     /** @var \Magento\Sales\Model\Order\Creditmemo\Item[] $creditmemoItems */
     $creditmemoItems = [];
     foreach ($creditmemoData['items'] as $itemKey => $creditmemoItemData) {
         $creditmemoItems[$itemKey] = $this->getCreditmemoItem($creditmemoItemData);
     }
     $this->creditmemo->expects($this->once())->method('getAllItems')->will($this->returnValue($creditmemoItems));
     $this->creditmemo->expects($this->any())->method('isLast')->will($this->returnValue($creditmemoData['is_last']));
     foreach ($creditmemoData['data_fields'] as $key => $value) {
         $this->creditmemo->setData($key, $value);
     }
     $this->creditmemo->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->creditmemo);
     //verify invoice data
     foreach ($expectedResults['creditmemo_data'] as $key => $value) {
         $this->assertEquals($value, $this->creditmemo->getData($key));
     }
     //verify invoice item data
     foreach ($expectedResults['creditmemo_items'] as $itemKey => $itemData) {
         $creditmemoItem = $creditmemoItems[$itemKey];
         foreach ($itemData as $key => $value) {
             $this->assertEquals($value, $creditmemoItem->getData($key));
         }
     }
 }
開發者ID:tingyeeh,項目名稱:magento2,代碼行數:45,代碼來源:TaxTest.php

示例3: extractDto

 /**
  * @param \Magento\Sales\Model\Order\Creditmemo $creditmemo
  * @return \Magento\Framework\Service\Data\AbstractExtensibleObject
  */
 public function extractDto(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
 {
     $this->creditmemoBuilder->populateWithArray($creditmemo->getData());
     $this->creditmemoBuilder->setItems($this->getItems($creditmemo));
     return $this->creditmemoBuilder->create();
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:10,代碼來源:CreditmemoMapper.php


注:本文中的Magento\Sales\Model\Order\Creditmemo::getData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。