Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Protected Member Functions
BaseService Class Reference
Inheritance diagram for BaseService:
WebapiAbstract CoreRoutingTest GettersTest NoWebApiXmlTest RequestIdOverrideTest ServiceVersionV1Test ServiceVersionV2Test SubsetTest

Protected Member Functions

 assertUnauthorizedException ($serviceInfo, $requestData=null)
 
 _assertRestUnauthorizedException ($serviceInfo, $requestData=null)
 
 _assertNoRouteOrOperationException ($serviceInfo, $requestData=null)
 
 _assertNoRestRouteException ($serviceInfo, $requestData=null)
 
 _assertSoapException ($serviceInfo, $requestData=null, $expectedMessage='')
 
- 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)
 

Additional Inherited Members

- Public Member Functions inherited from WebapiAbstract
 addModelToDelete ($model, $secure=false)
 
 processRestExceptionResult (\Exception $e)
 
- 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)
 
- Protected Attributes inherited from WebapiAbstract
 $_appCache
 
 $_modelsToDelete = []
 
 $_origConfigValues = []
 
 $_webApiAdapters
 
 $_webApiAdaptersMap
 
- Static Protected Attributes inherited from WebapiAbstract
static $_fixturesNamespace
 
static $_fixtures = []
 
static $_methodLevelFixtures = []
 
static $_classLevelFixtures = []
 

Detailed Description

Base class for all Service based routing tests

Definition at line 14 of file BaseService.php.

Member Function Documentation

◆ _assertNoRestRouteException()

_assertNoRestRouteException (   $serviceInfo,
  $requestData = null 
)
protected

Invoke the REST api and assert for test cases that no such REST route exist

Parameters
array$serviceInfo
array | null$requestData

Definition at line 80 of file BaseService.php.

81  {
82  try {
83  $this->_webApiCall($serviceInfo, $requestData);
84  } catch (\Exception $e) {
85  $error = json_decode($e->getMessage(), true);
86  $this->assertEquals('Request does not match any route.', $error['message']);
87  $this->assertEquals(WebapiException::HTTP_NOT_FOUND, $e->getCode());
88  }
89  }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)

◆ _assertNoRouteOrOperationException()

_assertNoRouteOrOperationException (   $serviceInfo,
  $requestData = null 
)
protected

Check a particular adapter and assert the exception

Parameters
array$serviceInfo
array | null$requestData

Definition at line 65 of file BaseService.php.

66  {
67  if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
68  $this->_assertSoapException($serviceInfo, $requestData);
69  } elseif (TESTS_WEB_API_ADAPTER == self::ADAPTER_REST) {
70  $this->_assertNoRestRouteException($serviceInfo, $requestData);
71  }
72  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
_assertSoapException($serviceInfo, $requestData=null, $expectedMessage='')
Definition: BaseService.php:98
_assertNoRestRouteException($serviceInfo, $requestData=null)
Definition: BaseService.php:80

◆ _assertRestUnauthorizedException()

_assertRestUnauthorizedException (   $serviceInfo,
  $requestData = null 
)
protected

Invoke the REST api and assert access is unauthorized

Parameters
array$serviceInfo
array | null$requestData

Definition at line 41 of file BaseService.php.

42  {
43  try {
44  $this->_webApiCall($serviceInfo, $requestData);
45  } catch (\Exception $e) {
46  $this->assertContains(
47  '{"message":"The consumer isn\'t authorized to access %resources.',
48  $e->getMessage(),
49  sprintf(
50  'REST routing did not fail as expected for the method "%s" of service "%s"',
51  $serviceInfo['rest']['httpMethod'],
52  $serviceInfo['rest']['resourcePath']
53  )
54  );
55  $this->assertEquals(WebapiException::HTTP_UNAUTHORIZED, $e->getCode());
56  }
57  }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)

◆ _assertSoapException()

_assertSoapException (   $serviceInfo,
  $requestData = null,
  $expectedMessage = '' 
)
protected

Invoke the SOAP api and assert for the NoWebApiXmlTestTest test cases that no such SOAP route exists

Parameters
array$serviceInfo
array | null$requestData
string$expectedMessage

Definition at line 98 of file BaseService.php.

99  {
100  try {
101  $this->_webApiCall($serviceInfo, $requestData);
102  } catch (\Exception $e) {
103  if (get_class($e) !== 'SoapFault') {
104  $this->fail(
105  sprintf(
106  'Expected SoapFault exception not generated for Service - "%s" and Operation - "%s"',
107  $serviceInfo['soap']['service'],
108  $serviceInfo['soap']['operation']
109  )
110  );
111  }
112 
113  if ($expectedMessage) {
114  $this->assertContains($expectedMessage, $e->getMessage());
115  }
116  }
117  }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)

◆ assertUnauthorizedException()

assertUnauthorizedException (   $serviceInfo,
  $requestData = null 
)
protected

Check a particular adapter and assert unauthorized access

Parameters
array$serviceInfo
array | null$requestData

Definition at line 22 of file BaseService.php.

23  {
24  if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
25  $this->_assertSoapException(
26  $serviceInfo,
28  "The consumer isn't authorized to access %resources."
29  );
30  } elseif (TESTS_WEB_API_ADAPTER == self::ADAPTER_REST) {
31  $this->_assertRestUnauthorizedException($serviceInfo, $requestData);
32  }
33  }
_assertRestUnauthorizedException($serviceInfo, $requestData=null)
Definition: BaseService.php:41
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
_assertSoapException($serviceInfo, $requestData=null, $expectedMessage='')
Definition: BaseService.php:98

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