8 use AspectMock\Test as AspectMock;
22 "address" => [
"city" =>
"Hawkins",
"state" =>
"Indiana",
"zip" => 78758],
34 [
"city" =>
"Hawkins",
"state" =>
"Indiana",
"zip" => 78758],
35 [
"city" =>
"Austin",
"state" =>
"Texas",
"zip" => 78701],
61 $testDataObject = $entityObjectBuilder->build();
65 $operationElement = $operationElementBuilder->build();
69 $result = $operationDataArrayResolver->resolveOperationDataArray(
76 $expectedResult = [
"testType" => [
83 $this->assertEquals($expectedResult,
$result);
97 $parentDataObject = $entityDataObjBuilder
98 ->withName(
"parentObject")
99 ->withType(
"parentType")
100 ->withLinkedEntities([
'childObject' =>
'childType'])
103 $childDataObject = $entityDataObjBuilder
104 ->withName(
"childObject")
105 ->withType(
"childType")
106 ->withDataFields([
"city" =>
"Hawkins",
"state" =>
"Indiana",
"zip" =>
"78758"])
110 $mockDOHInstance = AspectMock::double(DataObjectHandler::class, [
'getObject' => $childDataObject])->make();
111 AspectMock::double(DataObjectHandler::class, [
'getInstance' => $mockDOHInstance]);
115 $parentElement = $parentOpElementBuilder
116 ->withKey(
"parentType")
117 ->withType(
"parentType")
118 ->addFields([
"address" =>
"childType"])
122 $childOperationDefinition = $operationDefinitionBuilder
123 ->withName(
"createChildType")
124 ->withOperation(
"create")
125 ->withType(
"childType")
133 $mockDOHInstance = AspectMock::double(
134 OperationDefinitionObjectHandler::class,
135 [
'getObject' => $childOperationDefinition]
137 AspectMock::double(OperationDefinitionObjectHandler::class, [
'getInstance' => $mockDOHInstance]);
141 $result = $operationResolver->resolveOperationDataArray($parentDataObject, [$parentElement],
"create",
false);
144 $this->assertEquals(self::NESTED_METADATA_EXPECTED_RESULT,
$result);
160 $parentDataObject = $entityDataObjectBuilder
161 ->withName(
"parentObject")
162 ->withType(
"parentType")
163 ->withLinkedEntities([
'childObject' =>
'childType'])
166 $childDataObject = $entityDataObjectBuilder
167 ->withName(
"childObject")
168 ->withType(
"childType")
169 ->withDataFields([
"city" =>
"Hawkins",
"state" =>
"Indiana",
"zip" =>
"78758"])
173 $mockDOHInstance = AspectMock::double(DataObjectHandler::class, [
'getObject' => $childDataObject])->make();
174 AspectMock::double(DataObjectHandler::class, [
'getInstance' => $mockDOHInstance]);
178 $childElement = $childOpElementBuilder
180 ->withType(
"childType")
181 ->withFields([
"city" =>
"string",
"state" =>
"string",
"zip" =>
"integer"])
185 $parentElement = $parentOpElementBuilder
186 ->withKey(
"parentType")
187 ->withType(
"parentType")
188 ->addElements([
"address" => $childElement])
193 $result = $operationResolver->resolveOperationDataArray($parentDataObject, [$parentElement],
"create",
false);
196 $this->assertEquals(self::NESTED_METADATA_EXPECTED_RESULT,
$result);
214 $parentDataObject = $entityDataObjectBuilder
215 ->withName(
"parentObject")
216 ->withType(
"parentType")
217 ->withLinkedEntities([
'childObject1' =>
'childType',
'childObject2' =>
'childType'])
221 $mockDOHInstance = AspectMock::double(DataObjectHandler::class, [
"getObject" =>
function (
$name) {
224 if (
$name ==
"childObject1") {
225 return $entityDataObjectBuilder
226 ->withName(
"childObject1")
227 ->withType(
"childType")
228 ->withDataFields([
"city" =>
"Hawkins",
"state" =>
"Indiana",
"zip" =>
"78758"])
232 if (
$name ==
"childObject2") {
233 return $entityDataObjectBuilder
234 ->withName(
"childObject2")
235 ->withType(
"childType")
236 ->withDataFields([
"city" =>
"Austin",
"state" =>
"Texas",
"zip" =>
"78701"])
240 AspectMock::double(DataObjectHandler::class, [
'getInstance' => $mockDOHInstance]);
244 $childElement = $childOpElementBuilder
245 ->withKey(
"childType")
246 ->withType(
"childType")
247 ->withFields([
"city" =>
"string",
"state" =>
"string",
"zip" =>
"integer"])
251 $arrayElement = $arrayOpElementBuilder
253 ->withType(
"childType")
256 ->withNestedElements([
"childType" => $childElement])
260 $parentElement = $parentOpElementBuilder
261 ->withKey(
"parentType")
262 ->withType(
"parentType")
263 ->addElements([
"address" => $arrayElement])
268 $result = $operationResolver->resolveOperationDataArray($parentDataObject, [$parentElement],
"create",
false);
271 $this->assertEquals(self::NESTED_METADATA_ARRAY_RESULT,
$result);
287 $parentDataObject = $entityDataObjectBuilder
288 ->withName(
"parentObject")
289 ->withType(
"parentType")
290 ->withLinkedEntities([
'childObject1' =>
'childType',
'childObject2' =>
'childType'])
294 $mockDOHInstance = AspectMock::double(DataObjectHandler::class, [
"getObject" =>
function (
$name) {
297 if (
$name ==
"childObject1") {
298 return $entityDataObjectBuilder
299 ->withName(
"childObject1")
300 ->withType(
"childType")
301 ->withDataFields([
"city" =>
"Hawkins",
"state" =>
"Indiana",
"zip" =>
"78758"])
305 if (
$name ==
"childObject2") {
306 return $entityDataObjectBuilder
307 ->withName(
"childObject2")
308 ->withType(
"childType")
309 ->withDataFields([
"city" =>
"Austin",
"state" =>
"Texas",
"zip" =>
"78701"])
313 AspectMock::double(DataObjectHandler::class, [
'getInstance' => $mockDOHInstance]);
317 $arrayElement = $arrayOpElementBuilder
319 ->withType(
"childType")
321 ->withNestedElements([])
326 $parentElement = $parentOpElementBuilder
327 ->withKey(
"parentType")
328 ->withType(
"parentType")
329 ->addElements([
"address" => $arrayElement])
333 $childOperationDefinition = $operationDefinitionBuilder
334 ->withName(
"createChildType")
335 ->withOperation(
"create")
336 ->withType(
"childType")
344 $mockDOHInstance = AspectMock::double(
345 OperationDefinitionObjectHandler::class,
346 [
'getObject' => $childOperationDefinition]
348 AspectMock::double(OperationDefinitionObjectHandler::class, [
'getInstance' => $mockDOHInstance]);
352 $result = $operationResolver->resolveOperationDataArray($parentDataObject, [$parentElement],
"create",
false);
355 $this->assertEquals(self::NESTED_METADATA_ARRAY_RESULT,
$result);
testNestedMetadataResolve()
static tearDownAfterClass()
const ENTITY_OPERATION_ARRAY
testNestedMetadataArrayOfValue()
const NESTED_METADATA_EXPECTED_RESULT
testBasicPrimitiveMetadataResolve()
testNestedMetadataArrayOfObjects()
const NESTED_METADATA_ARRAY_RESULT
if(!isset($_GET['name'])) $name