Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CreditmemoCreateTest.php
Go to the documentation of this file.
1 <?php
8 
10 
15 {
16  const RESOURCE_PATH = '/V1/creditmemo';
17 
18  const SERVICE_READ_NAME = 'salesCreditmemoRepositoryV1';
19 
20  const SERVICE_VERSION = 'V1';
21 
25  protected $objectManager;
26 
27  protected function setUp()
28  {
30  }
31 
35  public function testInvoke()
36  {
38  $orderCollection = $this->objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Collection::class);
39  $order = $orderCollection->getFirstItem();
40 
42  $orderItem = current($order->getAllItems());
43  $items = [
44  $orderItem->getId() => ['order_item_id' => $orderItem->getId(), 'qty' => $orderItem->getQtyInvoiced()],
45  ];
46  $serviceInfo = [
47  'rest' => [
48  'resourcePath' => self::RESOURCE_PATH,
50  ],
51  'soap' => [
52  'service' => self::SERVICE_READ_NAME,
53  'serviceVersion' => self::SERVICE_VERSION,
54  'operation' => self::SERVICE_READ_NAME . 'save',
55  ],
56  ];
57  $data = [
58  'adjustment' => null,
59  'adjustment_negative' => null,
60  'adjustment_positive' => null,
61  'base_adjustment' => null,
62  'base_adjustment_negative' => null,
63  'base_adjustment_positive' => null,
64  'base_currency_code' => null,
65  'base_discount_amount' => null,
66  'base_grand_total' => null,
67  'base_discount_tax_compensation_amount' => null,
68  'base_shipping_amount' => null,
69  'base_shipping_discount_tax_compensation_amnt' => null,
70  'base_shipping_incl_tax' => null,
71  'base_shipping_tax_amount' => null,
72  'base_subtotal' => null,
73  'base_subtotal_incl_tax' => null,
74  'base_tax_amount' => null,
75  'base_to_global_rate' => null,
76  'base_to_order_rate' => null,
77  'billing_address_id' => null,
78  'created_at' => null,
79  'creditmemo_status' => null,
80  'discount_amount' => null,
81  'discount_description' => null,
82  'email_sent' => null,
83  'entity_id' => null,
84  'global_currency_code' => null,
85  'grand_total' => null,
86  'discount_tax_compensation_amount' => null,
87  'increment_id' => null,
88  'invoice_id' => null,
89  'order_currency_code' => null,
90  'order_id' => $order->getId(),
91  'shipping_address_id' => null,
92  'shipping_amount' => null,
93  'shipping_discount_tax_compensation_amount' => null,
94  'shipping_incl_tax' => null,
95  'shipping_tax_amount' => null,
96  'state' => null,
97  'store_currency_code' => null,
98  'store_id' => null,
99  'store_to_base_rate' => null,
100  'store_to_order_rate' => null,
101  'subtotal' => null,
102  'subtotal_incl_tax' => null,
103  'tax_amount' => null,
104  'transaction_id' => null,
105  'updated_at' => null,
106  'items' => $items,
107  ];
108  $result = $this->_webApiCall($serviceInfo, ['entity' => $data]);
109  $this->assertNotEmpty($result);
110  }
111 }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
$orderItem
Definition: order.php:30
$order
Definition: order.php:55
$items