objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); } /** * Test creditmemo get service * * @magentoApiDataFixture Magento/Sales/_files/creditmemo_for_get.php */ public function testCreditmemoGet() { /** @var \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection $creditmemoCollection */ $creditmemoCollection = $this->objectManager->get('Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection'); $creditmemo = $creditmemoCollection->getFirstItem(); $serviceInfo = [ 'rest' => [ 'resourcePath' => self::RESOURCE_PATH . '/' . $creditmemo->getId(), 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, ], 'soap' => [ 'service' => self::SERVICE_READ_NAME, 'serviceVersion' => self::SERVICE_VERSION, 'operation' => self::SERVICE_READ_NAME . 'get', ], ]; $actual = $this->_webApiCall($serviceInfo, ['id' => $creditmemo->getId()]); $expected = $creditmemo->getData(); foreach ($this->requiredFields as $field) { $this->assertArrayHasKey($field, $actual); $this->assertEquals($expected[$field], $actual[$field]); } } }