InvoiceCreateTest.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Service\V1;
  7. use Magento\TestFramework\TestCase\WebapiAbstract;
  8. /**
  9. * Class InvoiceCreateTest
  10. */
  11. class InvoiceCreateTest extends WebapiAbstract
  12. {
  13. const RESOURCE_PATH = '/V1/invoices';
  14. const SERVICE_READ_NAME = 'salesInvoiceRepositoryV1';
  15. const SERVICE_VERSION = 'V1';
  16. /**
  17. * @var \Magento\Framework\ObjectManagerInterface
  18. */
  19. protected $objectManager;
  20. protected function setUp()
  21. {
  22. $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  23. }
  24. /**
  25. * @magentoApiDataFixture Magento/Sales/_files/order.php
  26. */
  27. public function testInvoke()
  28. {
  29. /** @var \Magento\Sales\Model\Order $order */
  30. $order = $this->objectManager->create(\Magento\Sales\Model\Order::class)->loadByIncrementId('100000001');
  31. $serviceInfo = [
  32. 'rest' => [
  33. 'resourcePath' => self::RESOURCE_PATH,
  34. 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
  35. ],
  36. 'soap' => [
  37. 'service' => self::SERVICE_READ_NAME,
  38. 'serviceVersion' => self::SERVICE_VERSION,
  39. 'operation' => self::SERVICE_READ_NAME . 'save',
  40. ],
  41. ];
  42. $orderItems = $order->getAllItems();
  43. $data = [
  44. 'order_id' => $order->getId(),
  45. 'base_currency_code' => null,
  46. 'base_discount_amount' => null,
  47. 'base_grand_total' => null,
  48. 'base_discount_tax_compensation_amount' => null,
  49. 'base_shipping_amount' => null,
  50. 'base_shipping_discount_tax_compensation_amnt' => null,
  51. 'base_shipping_incl_tax' => null,
  52. 'base_shipping_tax_amount' => null,
  53. 'base_subtotal' => null,
  54. 'base_subtotal_incl_tax' => null,
  55. 'base_tax_amount' => null,
  56. 'base_total_refunded' => null,
  57. 'base_to_global_rate' => null,
  58. 'base_to_order_rate' => null,
  59. 'billing_address_id' => null,
  60. 'can_void_flag' => null,
  61. 'created_at' => null,
  62. 'discount_amount' => null,
  63. 'discount_description' => null,
  64. 'email_sent' => null,
  65. 'entity_id' => null,
  66. 'global_currency_code' => null,
  67. 'grand_total' => null,
  68. 'discount_tax_compensation_amount' => null,
  69. 'increment_id' => null,
  70. 'is_used_for_refund' => null,
  71. 'order_currency_code' => null,
  72. 'shipping_address_id' => null,
  73. 'shipping_amount' => null,
  74. 'shipping_discount_tax_compensation_amount' => null,
  75. 'shipping_incl_tax' => null,
  76. 'shipping_tax_amount' => null,
  77. 'state' => null,
  78. 'store_currency_code' => null,
  79. 'store_id' => null,
  80. 'store_to_base_rate' => null,
  81. 'store_to_order_rate' => null,
  82. 'subtotal' => null,
  83. 'subtotal_incl_tax' => null,
  84. 'tax_amount' => null,
  85. 'total_qty' => '1',
  86. 'transaction_id' => null,
  87. 'updated_at' => null,
  88. 'items' => [
  89. [
  90. 'orderItemId' => $orderItems[0]->getId(),
  91. 'qty' => 2,
  92. 'additionalData' => null,
  93. 'baseCost' => null,
  94. 'baseDiscountAmount' => null,
  95. 'baseDiscountTaxCompensationAmount' => null,
  96. 'basePrice' => null,
  97. 'basePriceInclTax' => null,
  98. 'baseRowTotal' => null,
  99. 'baseRowTotalInclTax' => null,
  100. 'baseTaxAmount' => null,
  101. 'description' => null,
  102. 'discountAmount' => null,
  103. 'discountTaxCompensationAmount' => null,
  104. 'name' => null,
  105. 'entity_id' => null,
  106. 'parentId' => null,
  107. 'price' => null,
  108. 'priceInclTax' => null,
  109. 'productId' => null,
  110. 'rowTotal' => null,
  111. 'rowTotalInclTax' => null,
  112. 'sku' => 'sku' . uniqid(),
  113. 'taxAmount' => null,
  114. ],
  115. ],
  116. ];
  117. $result = $this->_webApiCall($serviceInfo, ['entity' => $data]);
  118. $this->assertNotEmpty($result);
  119. }
  120. }