Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
DeserializationTest Class Reference
Inheritance diagram for DeserializationTest:
WebapiAbstract

Public Member Functions

 testPostRequestWithEmptyBody ()
 
 testPutRequestWithEmptyBody ()
 
- Public Member Functions inherited from WebapiAbstract
 addModelToDelete ($model, $secure=false)
 
 processRestExceptionResult (\Exception $e)
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from WebapiAbstract
 tearDown ()
 
 _webApiCall ( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
 
 _markTestAsSoapOnly ($message=null)
 
 _markTestAsRestOnly ($message=null)
 
 _getWebApiAdapter ($webApiAdapterCode)
 
 _assertMessagesEqual ($expectedMessages, $receivedMessages)
 
 _cleanAppConfigCache ()
 
 _restoreAppConfig ()
 
 checkSoapFault ( $soapFault, $expectedMessage, $expectedFaultCode, $expectedErrorParams=[], $expectedWrappedErrors=[], $traceString=null)
 
 _checkFaultParams ($expectedErrorParams, $errorDetails)
 
 _checkWrappedErrors ($expectedWrappedErrors, $errorDetails)
 

Protected Attributes

 $_version
 
 $_restResourcePath
 
- Protected Attributes inherited from WebapiAbstract
 $_appCache
 
 $_modelsToDelete = []
 
 $_origConfigValues = []
 
 $_webApiAdapters
 
 $_webApiAdaptersMap
 

Additional Inherited Members

- Static Public Member Functions inherited from WebapiAbstract
static setUpBeforeClass ()
 
static tearDownAfterClass ()
 
static setFixture ($key, $fixture, $tearDown=self::AUTO_TEAR_DOWN_AFTER_METHOD)
 
static getFixture ($key)
 
static callModelDelete ($model, $secure=false)
 
static deleteFixture ($key, $secure=false)
 
- Data Fields inherited from WebapiAbstract
const AUTO_TEAR_DOWN_DISABLED = 0
 
const AUTO_TEAR_DOWN_AFTER_METHOD = 1
 
const AUTO_TEAR_DOWN_AFTER_CLASS = 2
 
const ADAPTER_SOAP = 'soap'
 
const ADAPTER_REST = 'rest'
 
- Static Protected Member Functions inherited from WebapiAbstract
static _setFixtureNamespace ()
 
static _unsetFixtureNamespace ()
 
static _getFixtureNamespace ()
 
static _deleteFixtures ($fixtures)
 
- Static Protected Attributes inherited from WebapiAbstract
static $_fixturesNamespace
 
static $_fixtures = []
 
static $_methodLevelFixtures = []
 
static $_classLevelFixtures = []
 

Detailed Description

Definition at line 11 of file DeserializationTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 23 of file DeserializationTest.php.

24  {
25  $this->_version = 'V1';
26  $this->_restResourcePath = "/{$this->_version}/TestModule5/";
27  }

◆ testPostRequestWithEmptyBody()

testPostRequestWithEmptyBody ( )

Test POST request with empty body

Definition at line 32 of file DeserializationTest.php.

33  {
34  $this->_markTestAsRestOnly();
35  $serviceInfo = [
36  'rest' => [
37  'resourcePath' => $this->_restResourcePath,
39  ],
40  ];
41  $expectedMessage =
42  '{"message":"\"%fieldName\" is required. Enter and try again.","parameters":{"fieldName":"item"}}';
43  try {
44  $this->_webApiCall($serviceInfo, RestClient::EMPTY_REQUEST_BODY);
45  } catch (\Exception $e) {
46  $this->assertEquals(\Magento\Framework\Webapi\Exception::HTTP_BAD_REQUEST, $e->getCode());
47  $this->assertContains(
48  $expectedMessage,
49  $e->getMessage(),
50  "Response does not contain expected message."
51  );
52  }
53  }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)

◆ testPutRequestWithEmptyBody()

testPutRequestWithEmptyBody ( )

Test PUT request with empty body

Definition at line 58 of file DeserializationTest.php.

59  {
60  $this->_markTestAsRestOnly();
61  $itemId = 1;
62  $serviceInfo = [
63  'rest' => [
64  'resourcePath' => $this->_restResourcePath . $itemId,
66  ],
67  ];
68  $expectedMessage =
69  '{"message":"\"%fieldName\" is required. Enter and try again.","parameters":{"fieldName":"entityItem"}}';
70  try {
71  $this->_webApiCall($serviceInfo, RestClient::EMPTY_REQUEST_BODY);
72  } catch (\Exception $e) {
73  $this->assertEquals(\Magento\Framework\Webapi\Exception::HTTP_BAD_REQUEST, $e->getCode());
74  $this->assertContains(
75  $expectedMessage,
76  $e->getMessage(),
77  "Response does not contain expected message."
78  );
79  }
80  }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)

Field Documentation

◆ $_restResourcePath

$_restResourcePath
protected

Definition at line 21 of file DeserializationTest.php.

◆ $_version

$_version
protected

Definition at line 16 of file DeserializationTest.php.


The documentation for this class was generated from the following file: