Skip to content

Commit 2bdc905

Browse files
authored
Merge pull request #89 from magento-borg/resolve-array-data
- Add ability to use array entities as arguments.
2 parents 8d6eadf + 9bce276 commit 2bdc905

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionObjectTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,36 @@ public function testResolveDataInUserInput()
255255
$this->assertEquals($expected, $actionObject->getCustomActionAttributes());
256256
}
257257

258+
/**
259+
* {{EntityDataObject.values}} should be replaced with ["value1","value2"]
260+
*/
261+
public function testResolveArrayData()
262+
{
263+
// Set up mocks
264+
$actionObject = new ActionObject('merge123', 'fillField', [
265+
'selector' => '#selector',
266+
'userInput' => '{{EntityDataObject.values}}'
267+
]);
268+
$entityDataObject = new EntityDataObject('EntityDataObject', 'test', [
269+
'values' => [
270+
'value1',
271+
'value2',
272+
'"My" Value'
273+
]
274+
], [], '', '');
275+
$this->mockDataHandlerWithData($entityDataObject);
276+
277+
// Call the method under test
278+
$actionObject->resolveReferences();
279+
280+
// Verify
281+
$expected = [
282+
'selector' => '#selector',
283+
'userInput' => '["value1","value2","\"My\" Value"]'
284+
];
285+
$this->assertEquals($expected, $actionObject->getCustomActionAttributes());
286+
}
287+
258288
/**
259289
* Action object should throw an exception if a reference to a parameterized selector has too few given args.
260290
*/

src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php

+4
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,10 @@ private function findAndReplaceReferences($objectHandler, $inputString)
495495
$this->setTimeout($obj->getElement($objField)->getTimeout());
496496
} elseif (get_class($obj) == EntityDataObject::class) {
497497
$replacement = $this->resolveEntityDataObjectReference($obj, $match);
498+
499+
if (is_array($replacement)) {
500+
$replacement = '["' . implode('","', array_map('addSlashes', $replacement)) . '"]';
501+
}
498502
}
499503

500504
if ($replacement === null) {

0 commit comments

Comments
 (0)