9 use AspectMock\Test as AspectMock;
27 $operationType1 =
"create";
28 $operationType2 =
"update";
41 "testOperationName" => [
66 $this->setMockParserOutput($mockData);
70 $operations = $operationDefinitionManager->getAllObjects();
71 $this->assertArrayHasKey($operationType1 . $dataType1,
$operations);
72 $this->assertArrayHasKey($operationType2 . $dataType1,
$operations);
78 $testDataTypeName1 =
"type1";
80 $testUrl =
"V1/dataType";
81 $testOperationType =
"create";
83 $testSuccessRegex =
"/messages-message-success/";
84 $testContentType =
"application/json";
85 $testHeaderParam =
"testParameter";
86 $testHeaderValue =
"testHeader";
88 $nestedObjectKey =
"objectKey";
89 $nestedObjectType =
"objectType";
90 $nestedEntryKey1 =
"id";
91 $nestedEntryValue1 =
"integer";
92 $nestedEntryKey2 =
"name";
93 $nestedEntryValue2 =
"string";
94 $nestedEntryRequired2 =
"true";
95 $nestedEntryKey3 =
"active";
96 $nestedEntryValue3 =
"boolean";
115 "testOperationName" => [
124 "value" => $testContentType
163 $expectedNestedField =
new OperationElement($nestedEntryKey1, $nestedEntryValue1, $field,
false, [],
null);
168 $nestedEntryRequired2,
172 $expectedNestedField3 =
new OperationElement($nestedEntryKey3, $nestedEntryValue3, $field,
false, [],
null);
179 [0 => $expectedNestedField, 1 => $expectedNestedField2, 2 =>$expectedNestedField3]
183 $this->setMockParserOutput($mockData);
187 $operation = $operationDefinitionManager->getOperationDefinition($testOperationType, $testDataTypeName1);
191 [0 =>
"{$testHeaderParam}: {$testHeaderValue}",
193 $operation->getHeaders()
195 $this->assertEquals($testOperationType, $operation->getOperation());
196 $this->assertEquals($testMethod, $operation->getApiMethod());
197 $this->assertEquals($testUrl, $operation->getApiUrl());
198 $this->assertEquals($testDataTypeName1, $operation->getDataType());
199 $this->assertEquals($testContentType, $operation->getContentType());
200 $this->assertEquals($testAuth, $operation->getAuth());
201 $this->assertEquals($testSuccessRegex, $operation->getSuccessRegex());
204 $this->assertEquals($expectedOperation, $operation->getOperationMetadata()[0]);
210 $dataType1 =
"type1";
211 $operationType1 =
"create";
212 $objectArrayKey =
"ObjectArray";
213 $twiceNestedObjectKey =
"nestedObjectKey";
214 $twiceNestedObjectType =
"nestedObjectType";
215 $twiceNestedEntryKey =
"nestedFieldKey";
216 $twiceNestedEntryValue =
"string";
227 "testOperationName" => [
243 $twiceNestedEntryKey,
245 $twiceNestedEntryValue
254 $twiceNestedEntryKey,
255 $twiceNestedEntryValue,
263 $twiceNestedObjectKey,
264 $twiceNestedObjectType,
268 [0 => $twoLevelNestedMetadata]
273 $twiceNestedObjectType,
274 $twiceNestedObjectKey,
276 [$twiceNestedObjectKey => $oneLevelNestedMetadata],
281 $this->setMockParserOutput($mockData);
285 $operation = $operationDefinitionManager->getOperationDefinition($operationType1, $dataType1);
288 $this->assertEquals($expectedOperation, $operation->getOperationMetadata()[0]);
294 $dataType =
"dataType";
295 $operationType =
"create";
297 $entryValue =
"integer";
298 $arrayKey =
"arrayKey";
299 $arrayValue =
"string";
309 "testOperationName" => [
349 $this->setMockParserOutput($mockData);
353 $operation = $operationDefinitionManager->getOperationDefinition($operationType, $dataType);
356 $this->assertEquals($entry, $operation->getOperationMetadata()[0]);
357 $this->assertEquals($array, $operation->getOperationMetadata()[1]);
365 private function setMockParserOutput(
$data)
368 $property = new \ReflectionProperty(
369 OperationDefinitionObjectHandler::class,
372 $property->setAccessible(
true);
373 $property->setValue(
null);
375 $mockOperationParser = AspectMock::double(
376 OperationDefinitionParser::class,
377 [
"readOperationMetadata" =>
$data]
379 $instance = AspectMock::double(ObjectManager::class, [
'create' => $mockOperationParser])->make();
380 AspectMock::double(ObjectManagerFactory::class, [
'getObjectManager' => $instance]);
const ENTITY_OPERATION_ARRAY_KEY
const ENTITY_OPERATION_ENTRY_KEY
testObjectArrayCreation()
const ENTITY_OPERATION_CONTENT_TYPE
const ENTITY_OPERATION_URL
const ENTITY_OPERATION_HEADER_PARAM
const ENTITY_OPERATION_ARRAY_VALUE
const ENTITY_OPERATION_SUCCESS_REGEX
const ENTITY_OPERATION_ROOT_TAG
const ENTITY_OPERATION_OBJECT
const ENTITY_OPERATION_URL_PARAM_VALUE
const ENTITY_OPERATION_URL_PARAM
const ENTITY_OPERATION_OBJECT_KEY
const ENTITY_OPERATION_AUTH
const ENTITY_OPERATION_ARRAY
const ENTITY_OPERATION_METHOD
const ENTITY_OPERATION_DATA_TYPE
const ENTITY_OPERATION_REQUIRED
const ENTITY_OPERATION_URL_PARAM_KEY
const ENTITY_OPERATION_ENTRY_VALUE
const ENTITY_OPERATION_TYPE
const HTTP_CONTENT_TYPE_HEADER
const ENTITY_OPERATION_HEADER
const ENTITY_OPERATION_HEADER_VALUE
const ENTITY_OPERATION_ENTRY