InvoiceCaptureTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 InvoiceCaptureTest
  10. */
  11. class InvoiceCaptureTest extends WebapiAbstract
  12. {
  13. const SERVICE_VERSION = 'V1';
  14. const SERVICE_NAME = 'salesInvoiceManagementV1';
  15. /**
  16. * @magentoApiDataFixture Magento/Sales/_files/invoice.php
  17. * @expectedException \Exception
  18. */
  19. public function testInvoiceCapture()
  20. {
  21. $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  22. /** @var \Magento\Sales\Model\Order\Invoice $invoice */
  23. $invoice = $objectManager->get(\Magento\Sales\Model\Order\Invoice::class)->loadByIncrementId('100000001');
  24. $serviceInfo = [
  25. 'rest' => [
  26. 'resourcePath' => '/V1/invoices/' . $invoice->getId() . '/capture',
  27. 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
  28. ],
  29. 'soap' => [
  30. 'service' => self::SERVICE_NAME,
  31. 'serviceVersion' => self::SERVICE_VERSION,
  32. 'operation' => self::SERVICE_NAME . 'setCapture',
  33. ],
  34. ];
  35. $requestData = ['id' => $invoice->getId()];
  36. $this->_webApiCall($serviceInfo, $requestData);
  37. }
  38. }