Skip to content

Commit 73c4371

Browse files
committed
Added the ability to use entity properties in metadata
1 parent bf24553 commit 73c4371

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/Magento/FunctionalTestingFramework/DataGenerator/Persist/OperationDataArrayResolver.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ public function resolveOperationDataArray($entityObject, $operationMetadata, $op
134134
));
135135
}
136136
} else {
137+
138+
$operationElementProperty = null;
139+
if(strpos($operationElementType, '.') !== false){
140+
$operationElementComponents = explode('.',$operationElementType);
141+
$operationElementType = $operationElementComponents[0];
142+
$operationElementProperty = $operationElementComponents[1];
143+
}
144+
137145
$entityNamesOfType = $entityObject->getLinkedEntitiesOfType($operationElementType);
138146

139147
// If an element is required by metadata, but was not provided in the entity, throw an exception
@@ -146,12 +154,23 @@ public function resolveOperationDataArray($entityObject, $operationMetadata, $op
146154
));
147155
}
148156
foreach ($entityNamesOfType as $entityName) {
149-
$operationDataSubArray = $this->resolveNonPrimitiveElement(
150-
$entityName,
151-
$operationElement,
152-
$operation,
153-
$fromArray
154-
);
157+
158+
if($operationElementProperty === null) {
159+
$operationDataSubArray = $this->resolveNonPrimitiveElement(
160+
$entityName,
161+
$operationElement,
162+
$operation,
163+
$fromArray
164+
);
165+
}else {
166+
$linkedEntityObj = $this->resolveLinkedEntityObject($entityName);
167+
$operationDataSubArray = $linkedEntityObj->getDataByName($operationElementProperty,0);
168+
169+
if($operationDataSubArray === null)
170+
throw new \Exception(
171+
sprintf('Property %s not found in entity %s \n', $operationElementProperty, $entityName)
172+
);
173+
}
155174

156175
if ($operationElement->getType() == OperationDefinitionObjectHandler::ENTITY_OPERATION_ARRAY) {
157176
$operationDataArray[$operationElement->getKey()][] = $operationDataSubArray;

0 commit comments

Comments
 (0)