@@ -344,8 +344,9 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
344
344
foreach ($ stepsObject as $ steps ) {
345
345
$ actor = "I " ;
346
346
$ actionName = $ steps ->getType ();
347
- $ attribute = null ;
347
+ $ stepKey = $ steps -> getStepKey () ;
348
348
$ customActionAttributes = $ steps ->getCustomActionAttributes ();
349
+ $ attribute = null ;
349
350
$ selector = null ;
350
351
$ selector1 = null ;
351
352
$ selector2 = null ;
@@ -377,7 +378,7 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
377
378
$ assertDelta = null ;
378
379
379
380
// Validate action attributes and print notice messages on violation.
380
- $ this ->validateXmlAttributesMutuallyExclusive ($ actionName , $ customActionAttributes );
381
+ $ this ->validateXmlAttributesMutuallyExclusive ($ stepKey , $ actionName , $ customActionAttributes );
381
382
382
383
if (isset ($ customActionAttributes ['returnVariable ' ])) {
383
384
$ returnVariable = $ customActionAttributes ['returnVariable ' ];
@@ -517,12 +518,11 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
517
518
switch ($ actionName ) {
518
519
case "createData " :
519
520
$ entity = $ customActionAttributes ['entity ' ];
520
- $ key = $ steps ->getStepKey ();
521
521
//Add an informative statement to help the user debug test runs
522
522
$ testSteps .= sprintf (
523
523
"\t\t$%s->amGoingTo( \"create entity that has the stepKey: %s \"); \n" ,
524
524
$ actor ,
525
- $ key
525
+ $ stepKey
526
526
);
527
527
//Get Entity from Static data.
528
528
$ testSteps .= sprintf (
@@ -554,17 +554,17 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
554
554
}
555
555
556
556
if ($ hookObject ) {
557
- $ createEntityFunctionCall = sprintf ("\t\t\$this->%s->createEntity( " , $ key );
557
+ $ createEntityFunctionCall = sprintf ("\t\t\$this->%s->createEntity( " , $ stepKey );
558
558
$ dataPersistenceHandlerFunctionCall = sprintf (
559
559
"\t\t\$this->%s = new DataPersistenceHandler($%s " ,
560
- $ key ,
560
+ $ stepKey ,
561
561
$ entity
562
562
);
563
563
} else {
564
- $ createEntityFunctionCall = sprintf ("\t\t\$%s->createEntity( " , $ key );
564
+ $ createEntityFunctionCall = sprintf ("\t\t\$%s->createEntity( " , $ stepKey );
565
565
$ dataPersistenceHandlerFunctionCall = sprintf (
566
566
"\t\t$%s = new DataPersistenceHandler($%s " ,
567
- $ key ,
567
+ $ stepKey ,
568
568
$ entity
569
569
);
570
570
}
@@ -659,12 +659,11 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
659
659
break ;
660
660
case "getData " :
661
661
$ entity = $ customActionAttributes ['entity ' ];
662
- $ key = $ steps ->getStepKey ();
663
662
//Add an informative statement to help the user debug test runs
664
663
$ testSteps .= sprintf (
665
664
"\t\t$%s->amGoingTo( \"get entity that has the stepKey: %s \"); \n" ,
666
665
$ actor ,
667
- $ key
666
+ $ stepKey
668
667
);
669
668
//Get Entity from Static data.
670
669
$ testSteps .= sprintf (
@@ -696,17 +695,17 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
696
695
}
697
696
698
697
if ($ hookObject ) {
699
- $ getEntityFunctionCall = sprintf ("\t\t\$this->%s->getEntity( " , $ key );
698
+ $ getEntityFunctionCall = sprintf ("\t\t\$this->%s->getEntity( " , $ stepKey );
700
699
$ dataPersistenceHandlerFunctionCall = sprintf (
701
700
"\t\t\$this->%s = new DataPersistenceHandler($%s " ,
702
- $ key ,
701
+ $ stepKey ,
703
702
$ entity
704
703
);
705
704
} else {
706
- $ getEntityFunctionCall = sprintf ("\t\t\$%s->getEntity( " , $ key );
705
+ $ getEntityFunctionCall = sprintf ("\t\t\$%s->getEntity( " , $ stepKey );
707
706
$ dataPersistenceHandlerFunctionCall = sprintf (
708
707
"\t\t$%s = new DataPersistenceHandler($%s " ,
709
- $ key ,
708
+ $ stepKey ,
710
709
$ entity
711
710
);
712
711
}
@@ -1543,11 +1542,12 @@ private function stripQuotes($inStr)
1543
1542
/**
1544
1543
* Validate action attributes are either not set at all or only one is set for a given rule.
1545
1544
*
1545
+ * @param string $key
1546
1546
* @param string $tagName
1547
1547
* @param array $attributes
1548
1548
* @return void
1549
1549
*/
1550
- private function validateXmlAttributesMutuallyExclusive ($ tagName , $ attributes )
1550
+ private function validateXmlAttributesMutuallyExclusive ($ key , $ tagName , $ attributes )
1551
1551
{
1552
1552
$ rules = [
1553
1553
[ 'attributes ' => [
@@ -1588,34 +1588,27 @@ private function validateXmlAttributesMutuallyExclusive($tagName, $attributes)
1588
1588
}
1589
1589
}
1590
1590
if ($ count > 1 ) {
1591
- $ this ->printRuleErrorToConsole ($ tagName , $ rule ['attributes ' ]);
1591
+ $ this ->printRuleErrorToConsole ($ key , $ tagName , $ rule ['attributes ' ]);
1592
1592
}
1593
1593
}
1594
1594
}
1595
1595
1596
1596
/**
1597
1597
* Print rule violation message to console.
1598
1598
*
1599
- * @param $tagName
1600
- * @param $attributes
1599
+ * @param string $key
1600
+ * @param string $tagName
1601
+ * @param array $attributes
1601
1602
* @return void
1602
1603
*/
1603
- private function printRuleErrorToConsole ($ tagName , $ attributes )
1604
+ private function printRuleErrorToConsole ($ key , $ tagName , $ attributes )
1604
1605
{
1605
1606
if (empty ($ tagName ) || empty ($ attributes )) {
1606
1607
return ;
1607
1608
}
1608
- $ message = "Only one of the attributes: " ;
1609
- $ first = true ;
1610
- foreach ($ attributes as $ attribute ) {
1611
- if ($ first ) {
1612
- $ message .= '" ' . $ attribute . '" ' ;
1613
- $ first = false ;
1614
- } else {
1615
- $ message .= ', " ' . $ attribute . '" ' ;
1616
- }
1617
- }
1618
- $ message .= ' can be use for action: " ' . $ tagName . "\"\n" ;
1609
+ $ message = 'On step with stepKey " ' . $ key . '", only one of the attributes: " ' ;
1610
+ $ message .= implode ('", " ' , $ attributes );
1611
+ $ message .= '" can be use for action " ' . $ tagName . "\". \n" ;
1619
1612
print $ message ;
1620
1613
}
1621
1614
}
0 commit comments