@@ -806,7 +806,7 @@ private function resolveTestVariable($inputString, $quoteBreak = false)
806
806
$ replaced = false ;
807
807
808
808
// Check for Cest-scope variables first, stricter regex match.
809
- preg_match_all ("/ \\$ \\$[\w.]+ \\$ \\$/ " , $ outputString , $ matches );
809
+ preg_match_all ("/ \\$ \\$[\w.\[\] ]+ \\$ \\$/ " , $ outputString , $ matches );
810
810
foreach ($ matches [0 ] as $ match ) {
811
811
$ replacement = null ;
812
812
$ variable = $ this ->stripAndSplitReference ($ match , '$$ ' );
@@ -816,7 +816,19 @@ private function resolveTestVariable($inputString, $quoteBreak = false)
816
816
". Hook persisted entity references must follow \$\$entityMergeKey.field \$\$ format. "
817
817
);
818
818
}
819
- $ replacement = sprintf ("\$this->%s->getCreatedDataByName('%s') " , $ variable [0 ], $ variable [1 ]);
819
+ preg_match_all ("/\[[\w.]+\]/ " , $ variable [1 ], $ arrayMatch );
820
+ if (!empty ($ arrayMatch [0 ])) {
821
+ $ variable [1 ] = str_replace ($ arrayMatch [0 ][0 ], "" , $ variable [1 ]);
822
+ $ arrayMatch [0 ][0 ] = trim ($ arrayMatch [0 ][0 ], "[] " );
823
+ $ replacement = sprintf (
824
+ "\$this->%s->getCreatedDataByName('%s')['%s'] " ,
825
+ $ variable [0 ],
826
+ $ variable [1 ],
827
+ $ arrayMatch [0 ][0 ]
828
+ );
829
+ } else {
830
+ $ replacement = sprintf ("\$this->%s->getCreatedDataByName('%s') " , $ variable [0 ], $ variable [1 ]);
831
+ }
820
832
if ($ quoteBreak ) {
821
833
$ replacement = '" . ' . $ replacement . ' . " ' ;
822
834
}
@@ -825,7 +837,7 @@ private function resolveTestVariable($inputString, $quoteBreak = false)
825
837
}
826
838
827
839
// Check Test-scope variables
828
- preg_match_all ("/ \\$[\w.]+ \\$/ " , $ outputString , $ matches );
840
+ preg_match_all ("/ \\$[\w.\[\] ]+ \\$/ " , $ outputString , $ matches );
829
841
foreach ($ matches [0 ] as $ match ) {
830
842
$ replacement = null ;
831
843
$ variable = $ this ->stripAndSplitReference ($ match , '$ ' );
@@ -835,7 +847,19 @@ private function resolveTestVariable($inputString, $quoteBreak = false)
835
847
". Test persisted entity references must follow \$entityMergeKey.field \$ format. "
836
848
);
837
849
}
838
- $ replacement = sprintf ("$%s->getCreatedDataByName('%s') " , $ variable [0 ], $ variable [1 ]);
850
+ preg_match_all ("/\[[\w.]+\]/ " , $ variable [1 ], $ arrayMatch );
851
+ if (!empty ($ arrayMatch [0 ])) {
852
+ $ variable [1 ] = str_replace ($ arrayMatch [0 ][0 ], "" , $ variable [1 ]);
853
+ $ arrayMatch [0 ][0 ] = trim ($ arrayMatch [0 ][0 ], "[] " );
854
+ $ replacement = sprintf (
855
+ "$%s->getCreatedDataByName('%s')['%s'] " ,
856
+ $ variable [0 ],
857
+ $ variable [1 ],
858
+ $ arrayMatch [0 ][0 ]
859
+ );
860
+ } else {
861
+ $ replacement = sprintf ("$%s->getCreatedDataByName('%s') " , $ variable [0 ], $ variable [1 ]);
862
+ }
839
863
if ($ quoteBreak ) {
840
864
$ replacement = '" . ' . $ replacement . ' . " ' ;
841
865
}
0 commit comments