Definition at line 10 of file Api.php.
◆ callWithException()
static callWithException |
( |
\PHPUnit\Framework\TestCase |
$testCase, |
|
|
|
$path, |
|
|
|
$params = [] , |
|
|
|
$expectedMessage = '' |
|
) |
| |
|
static |
Call API method via API handler that raises SoapFault exception
- Parameters
-
\PHPUnit\Framework\TestCase | $testCase | Active test case |
string | $path | |
array | $params | Order of items matters as they are passed to call_user_func_array |
string | $expectedMessage | exception message |
- Returns
- \SoapFault
Definition at line 74 of file Api.php.
83 $testCase->fail(
'Expected error exception was not raised.');
84 }
catch (\SoapFault $exception) {
86 if ($expectedMessage) {
87 $testCase->assertEquals($expectedMessage, $exception->getMessage());
static restoreErrorHandler()
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ checkEntityFields()
static checkEntityFields |
( |
\PHPUnit\Framework\TestCase |
$testCase, |
|
|
array |
$expectedData, |
|
|
array |
$actualData, |
|
|
array |
$fieldsToCompare = [] |
|
) |
| |
|
static |
Check specific fields value in some entity data.
- Parameters
-
\PHPUnit\Framework\TestCase | $testCase | |
array | $expectedData | |
array | $actualData | |
array | $fieldsToCompare | To be able to compare fields from loaded model with fields from API response this parameter provides fields mapping. Array can store model field name $entityField mapped on field name in API response. $fieldsToCompare format is: $fieldsToCompare = array($modelFieldName => $apiResponseFieldName); Example: $fieldsToCompare = array( 'entity_id' => 'product_id', 'sku', 'attribute_set_id' => 'set', 'type_id' => 'type', 'category_ids', ); |
Definition at line 190 of file Api.php.
196 $fieldsToCompare = !empty($fieldsToCompare) ? $fieldsToCompare : array_keys($expectedData);
197 foreach ($fieldsToCompare as $entityField => $field) {
198 $testCase->assertEquals(
199 $expectedData[is_numeric($entityField) ? $field : $entityField],
201 sprintf(
'"%s" filed has invalid value.', $field)
◆ restoreErrorHandler()
static restoreErrorHandler |
( |
| ) |
|
|
static |
Restore previously used error handler
Definition at line 96 of file Api.php.
98 set_error_handler(self::$_previousHandler);
◆ simpleXmlToArray()
static simpleXmlToArray |
( |
|
$xml, |
|
|
|
$keyTrimmer = null |
|
) |
| |
|
static |
Convert Simple XML to array
- Parameters
-
\SimpleXMLObject | $xml | |
String | $keyTrimmer | |
- Returns
- object
In XML notation we can't have nodes with digital names in other words fallowing XML will be not valid: <24> Default category </24>
But this one will not cause any problems: <qwe_24> Default category </qwe_24>
So when we want to obtain an array with key 24 we will pass the correct XML from above and $keyTrimmer = 'qwe_'; As a result we will obtain an array with digital key node.
In the other case just don't pass the $keyTrimmer.
Definition at line 135 of file Api.php.
140 if (
null !== $keyTrimmer) {
144 if (is_object($xml)) {
145 foreach (get_object_vars($xml->children()) as $key => $node) {
148 $arrKey = str_replace($keyTrimmer,
'', $key);
150 if (is_numeric($arrKey)) {
151 $arrKey =
'Obj' . $arrKey;
153 if (is_object($node)) {
155 }
elseif (is_array($node)) {
157 foreach ($node as $nodeValue) {
161 $result[$arrKey] = (string)$node;
elseif(isset( $params[ 'redirect_parent']))
static simpleXmlToArray($xml, $keyTrimmer=null)
◆ soapAdapterFaultCallback()
static soapAdapterFaultCallback |
( |
|
$exceptionCode, |
|
|
|
$exceptionMessage |
|
) |
| |
|
static |
Throw SoapFault exception. Callback for 'fault' method of API.
- Parameters
-
string | $exceptionCode | |
string | $exceptionMessage | |
- Exceptions
-
Definition at line 108 of file Api.php.
110 throw new \SoapFault($exceptionCode, $exceptionMessage);
◆ $_previousHandler
The documentation for this class was generated from the following file:
- vendor/magento/magento2-base/dev/tests/integration/framework/Magento/TestFramework/Helper/Api.php