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

Public Member Functions

 testCustomerWithEmailFilter ()
 
 testCustomerWithEmailAndAddressFilter ()
 
 testCustomerWithNestedAddressFilter ()
 
 testCustomerInvalidFilter ()
 
 testFilterForCustomerApiWithSimpleResponse ()
 
- Public Member Functions inherited from WebapiAbstract
 addModelToDelete ($model, $secure=false)
 
 processRestExceptionResult (\Exception $e)
 

Protected Member Functions

 setUp ()
 
 _getCustomerWithFilter ($filter, $customerId, $path='')
 
- 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

 $customerHelper
 
 $customerData
 
- 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 13 of file PartialResponseTest.php.

Member Function Documentation

◆ _getCustomerWithFilter()

_getCustomerWithFilter (   $filter,
  $customerId,
  $path = '' 
)
protected

Definition at line 80 of file PartialResponseTest.php.

81  {
82  $resourcePath = sprintf(
83  '%s/%d%s?fields=%s',
86  $path,
87  $filter
88  );
89 
90  $serviceInfo = [
91  'rest' => [
92  'resourcePath' => $resourcePath,
94  ],
95  ];
96 
97  return $this->_webApiCall($serviceInfo);
98  }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)

◆ setUp()

setUp ( )
protected

Definition at line 21 of file PartialResponseTest.php.

22  {
23  $this->_markTestAsRestOnly('Partial response functionality available in REST mode only.');
24 
25  $this->customerHelper = Bootstrap::getObjectManager()
26  ->get(\Magento\TestFramework\Helper\Customer::class);
27 
28  $this->customerData = $this->customerHelper->createSampleCustomer();
29  }

◆ testCustomerInvalidFilter()

testCustomerInvalidFilter ( )

Definition at line 66 of file PartialResponseTest.php.

67  {
68  // Invalid filter should return an empty result
69  $result = $this->_getCustomerWithFilter('invalid', $this->customerData['id']);
70  $this->assertEmpty($result);
71  }
_getCustomerWithFilter($filter, $customerId, $path='')

◆ testCustomerWithEmailAndAddressFilter()

testCustomerWithEmailAndAddressFilter ( )

Definition at line 39 of file PartialResponseTest.php.

40  {
41  $filter = 'email,addresses[city]';
42  $expected = [
43  'email' => $this->customerData['email'],
44  'addresses' => [
45  ['city' => CustomerHelper::ADDRESS_CITY1],
46  ['city' => CustomerHelper::ADDRESS_CITY2],
47  ],
48  ];
49  $result = $this->_getCustomerWithFilter($filter, $this->customerData['id']);
50  $this->assertEquals($expected, $result);
51  }
_getCustomerWithFilter($filter, $customerId, $path='')

◆ testCustomerWithEmailFilter()

testCustomerWithEmailFilter ( )

Definition at line 31 of file PartialResponseTest.php.

32  {
33  $filter = 'email';
34  $expected = ['email' => $this->customerData['email']];
35  $result = $this->_getCustomerWithFilter($filter, $this->customerData['id']);
36  $this->assertEquals($expected, $result);
37  }
_getCustomerWithFilter($filter, $customerId, $path='')

◆ testCustomerWithNestedAddressFilter()

testCustomerWithNestedAddressFilter ( )

Definition at line 53 of file PartialResponseTest.php.

54  {
55  $filter = 'addresses[region[region_code]]';
56  $expected = [
57  'addresses' => [
58  ['region' => ['region_code' => CustomerHelper::ADDRESS_REGION_CODE1]],
59  ['region' => ['region_code' => CustomerHelper::ADDRESS_REGION_CODE2]],
60  ],
61  ];
62  $result = $this->_getCustomerWithFilter($filter, $this->customerData['id']);
63  $this->assertEquals($expected, $result);
64  }
_getCustomerWithFilter($filter, $customerId, $path='')

◆ testFilterForCustomerApiWithSimpleResponse()

testFilterForCustomerApiWithSimpleResponse ( )

Definition at line 73 of file PartialResponseTest.php.

74  {
75  $result = $this->_getCustomerWithFilter('customers', $this->customerData['id'], '/permissions/readonly');
76  // assert if filter is ignored and a normal response is returned
77  $this->assertFalse($result);
78  }
_getCustomerWithFilter($filter, $customerId, $path='')

Field Documentation

◆ $customerData

$customerData
protected

Definition at line 19 of file PartialResponseTest.php.

◆ $customerHelper

$customerHelper
protected

Definition at line 16 of file PartialResponseTest.php.


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