Skip to content

Commit 00b21e3

Browse files
committed
Added ability to use array entities as arguments.
1 parent 2fe0d2a commit 00b21e3

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

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

+29
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,35 @@ 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+
]
273+
], [], '', '');
274+
$this->mockDataHandlerWithData($entityDataObject);
275+
276+
// Call the method under test
277+
$actionObject->resolveReferences();
278+
279+
// Verify
280+
$expected = [
281+
'selector' => '#selector',
282+
'userInput' => '["value1","value2"]'
283+
];
284+
$this->assertEquals($expected, $actionObject->getCustomActionAttributes());
285+
}
286+
258287
/**
259288
* Action object should throw an exception if a reference to a parameterized selector has too few given args.
260289
*/

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

+4
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,10 @@ private function findAndReplaceReferences($objectHandler, $inputString)
496496

497497
$replacement = $this->resolveParameterization($parameterized, $replacement, $match, $obj);
498498

499+
if (is_array($replacement)) {
500+
$replacement = '["' . implode('","', $replacement) . '"]';
501+
}
502+
499503
$outputString = str_replace($match, $replacement, $outputString);
500504
}
501505
return $outputString;

0 commit comments

Comments
 (0)