Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InvoiceCreateTest.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
15  const RESOURCE_PATH = '/V1/invoices';
16 
17  const SERVICE_READ_NAME = 'salesInvoiceRepositoryV1';
18 
19  const SERVICE_VERSION = 'V1';
20 
24  protected $objectManager;
25 
26  protected function setUp()
27  {
29  }
30 
34  public function testInvoke()
35  {
37  $order = $this->objectManager->create(\Magento\Sales\Model\Order::class)->loadByIncrementId('100000001');
38  $serviceInfo = [
39  'rest' => [
40  'resourcePath' => self::RESOURCE_PATH,
42  ],
43  'soap' => [
44  'service' => self::SERVICE_READ_NAME,
45  'serviceVersion' => self::SERVICE_VERSION,
46  'operation' => self::SERVICE_READ_NAME . 'save',
47  ],
48  ];
49  $orderItems = $order->getAllItems();
50  $data = [
51  'order_id' => $order->getId(),
52  'base_currency_code' => null,
53  'base_discount_amount' => null,
54  'base_grand_total' => null,
55  'base_discount_tax_compensation_amount' => null,
56  'base_shipping_amount' => null,
57  'base_shipping_discount_tax_compensation_amnt' => null,
58  'base_shipping_incl_tax' => null,
59  'base_shipping_tax_amount' => null,
60  'base_subtotal' => null,
61  'base_subtotal_incl_tax' => null,
62  'base_tax_amount' => null,
63  'base_total_refunded' => null,
64  'base_to_global_rate' => null,
65  'base_to_order_rate' => null,
66  'billing_address_id' => null,
67  'can_void_flag' => null,
68  'created_at' => null,
69  'discount_amount' => null,
70  'discount_description' => null,
71  'email_sent' => null,
72  'entity_id' => null,
73  'global_currency_code' => null,
74  'grand_total' => null,
75  'discount_tax_compensation_amount' => null,
76  'increment_id' => null,
77  'is_used_for_refund' => null,
78  'order_currency_code' => null,
79  'shipping_address_id' => null,
80  'shipping_amount' => null,
81  'shipping_discount_tax_compensation_amount' => null,
82  'shipping_incl_tax' => null,
83  'shipping_tax_amount' => null,
84  'state' => null,
85  'store_currency_code' => null,
86  'store_id' => null,
87  'store_to_base_rate' => null,
88  'store_to_order_rate' => null,
89  'subtotal' => null,
90  'subtotal_incl_tax' => null,
91  'tax_amount' => null,
92  'total_qty' => '1',
93  'transaction_id' => null,
94  'updated_at' => null,
95  'items' => [
96  [
97  'orderItemId' => $orderItems[0]->getId(),
98  'qty' => 2,
99  'additionalData' => null,
100  'baseCost' => null,
101  'baseDiscountAmount' => null,
102  'baseDiscountTaxCompensationAmount' => null,
103  'basePrice' => null,
104  'basePriceInclTax' => null,
105  'baseRowTotal' => null,
106  'baseRowTotalInclTax' => null,
107  'baseTaxAmount' => null,
108  'description' => null,
109  'discountAmount' => null,
110  'discountTaxCompensationAmount' => null,
111  'name' => null,
112  'entity_id' => null,
113  'parentId' => null,
114  'price' => null,
115  'priceInclTax' => null,
116  'productId' => null,
117  'rowTotal' => null,
118  'rowTotalInclTax' => null,
119  'sku' => 'sku' . uniqid(),
120  'taxAmount' => null,
121  ],
122  ],
123  ];
124  $result = $this->_webApiCall($serviceInfo, ['entity' => $data]);
125  $this->assertNotEmpty($result);
126  }
127 }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
$order
Definition: order.php:55