Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CreditmemoGetTest.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
18  const RESOURCE_PATH = '/V1/creditmemo';
19 
23  const SERVICE_READ_NAME = 'salesCreditmemoRepositoryV1';
24 
28  const SERVICE_VERSION = 'V1';
29 
33  const CREDITMEMO_INCREMENT_ID = '100000001';
34 
38  protected $objectManager;
39 
45  protected $requiredFields = [
46  'entity_id',
47  'store_id',
48  'base_shipping_tax_amount',
49  'base_discount_amount',
50  'grand_total',
51  'base_subtotal_incl_tax',
52  'shipping_amount',
53  'subtotal_incl_tax',
54  'base_shipping_amount',
55  'base_adjustment',
56  'base_subtotal',
57  'discount_amount',
58  'subtotal',
59  'adjustment',
60  'base_grand_total',
61  'base_tax_amount',
62  'shipping_tax_amount',
63  'tax_amount',
64  'order_id',
65  'state',
66  'increment_id',
67  ];
68 
72  protected function setUp()
73  {
75  }
76 
82  public function testCreditmemoGet()
83  {
85  $creditmemoCollection =
86  $this->objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection::class);
87  $creditmemo = $creditmemoCollection->getFirstItem();
88 
89  $serviceInfo = [
90  'rest' => [
91  'resourcePath' => self::RESOURCE_PATH . '/' . $creditmemo->getId(),
93  ],
94  'soap' => [
95  'service' => self::SERVICE_READ_NAME,
96  'serviceVersion' => self::SERVICE_VERSION,
97  'operation' => self::SERVICE_READ_NAME . 'get',
98  ],
99  ];
100 
101  $actual = $this->_webApiCall($serviceInfo, ['id' => $creditmemo->getId()]);
102  $expected = $creditmemo->getData();
103 
104  foreach ($this->requiredFields as $field) {
105  $this->assertArrayHasKey($field, $actual);
106  $this->assertEquals($expected[$field], $actual[$field]);
107  }
108 
109  //check that nullable fields were marked as optional and were not sent
110  foreach ($actual as $value) {
111  $this->assertNotNull($value);
112  }
113  }
114 }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
$value
Definition: gender.phtml:16