Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InvoiceGetTest.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  public function testInvoiceGet()
25  {
28  $invoiceCollection = $objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Invoice\Collection::class);
29  $invoice = $invoiceCollection->getFirstItem();
30  $expectedInvoiceData = [
31  'grand_total' => '100.0000',
32  'subtotal' => '100.0000',
33  'increment_id' => $invoice->getIncrementId(),
34  ];
35  $serviceInfo = [
36  'rest' => [
37  'resourcePath' => self::RESOURCE_PATH . '/' . $invoice->getId(),
39  ],
40  'soap' => [
41  'service' => self::SERVICE_READ_NAME,
42  'serviceVersion' => self::SERVICE_VERSION,
43  'operation' => self::SERVICE_READ_NAME . 'get',
44  ],
45  ];
46  $result = $this->_webApiCall($serviceInfo, ['id' => $invoice->getId()]);
47  foreach ($expectedInvoiceData as $field => $value) {
48  $this->assertArrayHasKey($field, $result);
49  $this->assertEquals($value, $result[$field]);
50  }
51 
52  //check that nullable fields were marked as optional and were not sent
53  foreach ($result as $value) {
54  $this->assertNotNull($value);
55  }
56  }
57 }
$objectManager
Definition: bootstrap.php:17
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
$value
Definition: gender.phtml:16
$invoice