16 use Magento\TestModule1\Service\V1\Entity\ItemFactory;
43 $this->_version =
'V1';
44 $this->_soapService =
'testModule1AllSoapAndRestV1';
45 $this->_restResourcePath =
"/{$this->_version}/testmodule1/";
48 \
Magento\Framework\Api\AttributeValueFactory::class
52 \
Magento\TestModule1\Service\V1\Entity\ItemFactory::class
64 'resourcePath' => $this->_restResourcePath . $itemId,
71 $this->assertEquals(
'testProduct1',
$item[
'name'],
'Item was retrieved unsuccessfully');
80 $this->
_markTestAsRestOnly(
'Test will fail for SOAP because attribute values get converted to strings.');
81 $customerAttributes = [
96 $attributeValue1 = $this->valueFactory->create()
99 $attributeValue2 = $this->valueFactory->create()
102 $attributeValue3 = $this->valueFactory->create()
106 $item = $this->itemFactory->create()
108 ->setName(
'testProductAnyType')
109 ->setCustomAttributes([$attributeValue1, $attributeValue2, $attributeValue3]);
113 'resourcePath' => $this->_restResourcePath .
'itemAnyType',
116 'soap' => [
'service' =>
$this->_soapService,
'operation' => $this->_soapService .
'ItemAnyType'],
122 $attributeValue1->getValue(),
123 $item[
'custom_attributes'][0][
'value'],
124 'Serialized attribute value type does\'t match pre-defined type.' 128 $attributeValue2->getValue(),
129 $item[
'custom_attributes'][1][
'value'],
130 'Serialized attribute value type does\'t match pre-defined type.' 134 $attributeValue3->getValue(),
135 $item[
'custom_attributes'][2][
'value'],
136 'Serialized attribute value type does\'t match pre-defined type.' 145 $itemArr = [[
'item_id' => 1,
'name' =>
'testProduct1'], [
'item_id' => 2,
'name' =>
'testProduct2']];
151 'soap' => [
'service' =>
$this->_soapService,
'operation' => $this->_soapService .
'Items'],
154 $this->assertEquals($itemArr,
$item,
'Items were not retrieved');
162 $createdItemName =
'createdItemName';
168 'soap' => [
'service' =>
$this->_soapService,
'operation' => $this->_soapService .
'Create'],
172 $this->assertEquals($createdItemName,
$item[
'name'],
'Item creation failed');
180 $createdItemName =
'createdItemName';
186 'soap' => [
'service' =>
$this->_soapService,
'operation' => $this->_soapService .
'Create'],
192 OauthHelper::getApiAccessCredentials([]);
195 }
catch (\Exception $e) {
211 'resourcePath' => $this->_restResourcePath . $itemId,
214 'soap' => [
'service' =>
$this->_soapService,
'operation' => $this->_soapService .
'Update'],
216 $requestData = [
'entityItem' => [
'itemId' => $itemId,
'name' =>
'testName']];
218 $this->assertEquals(
'Updated' .
$requestData[
'entityItem'][
'name'],
$item[
'name'],
'Item update failed');
229 'resourcePath' => $this->_restResourcePath . $itemId,
232 'soap' => [
'service' =>
$this->_soapService,
'operation' => $this->_soapService .
'Delete'],
234 $requestData = [
'itemId' => $itemId,
'name' =>
'testName'];
243 'resourcePath' => $this->_restResourcePath .
'overwritten',
248 $this->assertEquals([
'item_id' => -55,
'name' =>
'testProduct1'],
$item);
256 'resourcePath' => $this->_restResourcePath .
'testOptionalParam',
261 $this->assertEquals([
'item_id' => 3,
'name' =>
'Default Name'],
$item);
269 'resourcePath' => $this->_restResourcePath .
'testOptionalParam',
274 $this->assertEquals([
'item_id' => 3,
'name' =>
'Ms. LaGrange'],
$item);
testCreateWithoutResources()
_markTestAsRestOnly($message=null)
_assertNoRouteOrOperationException($serviceInfo, $requestData=null)
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
assertUnauthorizedException($serviceInfo, $requestData=null)
static getObjectManager()
static clearApiAccessCredentials()