@@ -344,8 +344,9 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
344344 foreach ($ stepsObject as $ steps ) {
345345 $ actor = "I " ;
346346 $ actionName = $ steps ->getType ();
347- $ attribute = null ;
347+ $ stepKey = $ steps -> getStepKey () ;
348348 $ customActionAttributes = $ steps ->getCustomActionAttributes ();
349+ $ attribute = null ;
349350 $ selector = null ;
350351 $ selector1 = null ;
351352 $ selector2 = null ;
@@ -377,7 +378,7 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
377378 $ assertDelta = null ;
378379
379380 // Validate action attributes and print notice messages on violation.
380- $ this ->validateXmlAttributesMutuallyExclusive ($ actionName , $ customActionAttributes );
381+ $ this ->validateXmlAttributesMutuallyExclusive ($ stepKey , $ actionName , $ customActionAttributes );
381382
382383 if (isset ($ customActionAttributes ['returnVariable ' ])) {
383384 $ returnVariable = $ customActionAttributes ['returnVariable ' ];
@@ -517,12 +518,11 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
517518 switch ($ actionName ) {
518519 case "createData " :
519520 $ entity = $ customActionAttributes ['entity ' ];
520- $ key = $ steps ->getStepKey ();
521521 //Add an informative statement to help the user debug test runs
522522 $ testSteps .= sprintf (
523523 "\t\t$%s->amGoingTo( \"create entity that has the stepKey: %s \"); \n" ,
524524 $ actor ,
525- $ key
525+ $ stepKey
526526 );
527527 //Get Entity from Static data.
528528 $ testSteps .= sprintf (
@@ -554,17 +554,17 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
554554 }
555555
556556 if ($ hookObject ) {
557- $ createEntityFunctionCall = sprintf ("\t\t\$this->%s->createEntity( " , $ key );
557+ $ createEntityFunctionCall = sprintf ("\t\t\$this->%s->createEntity( " , $ stepKey );
558558 $ dataPersistenceHandlerFunctionCall = sprintf (
559559 "\t\t\$this->%s = new DataPersistenceHandler($%s " ,
560- $ key ,
560+ $ stepKey ,
561561 $ entity
562562 );
563563 } else {
564- $ createEntityFunctionCall = sprintf ("\t\t\$%s->createEntity( " , $ key );
564+ $ createEntityFunctionCall = sprintf ("\t\t\$%s->createEntity( " , $ stepKey );
565565 $ dataPersistenceHandlerFunctionCall = sprintf (
566566 "\t\t$%s = new DataPersistenceHandler($%s " ,
567- $ key ,
567+ $ stepKey ,
568568 $ entity
569569 );
570570 }
@@ -659,12 +659,11 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
659659 break ;
660660 case "getData " :
661661 $ entity = $ customActionAttributes ['entity ' ];
662- $ key = $ steps ->getStepKey ();
663662 //Add an informative statement to help the user debug test runs
664663 $ testSteps .= sprintf (
665664 "\t\t$%s->amGoingTo( \"get entity that has the stepKey: %s \"); \n" ,
666665 $ actor ,
667- $ key
666+ $ stepKey
668667 );
669668 //Get Entity from Static data.
670669 $ testSteps .= sprintf (
@@ -696,17 +695,17 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
696695 }
697696
698697 if ($ hookObject ) {
699- $ getEntityFunctionCall = sprintf ("\t\t\$this->%s->getEntity( " , $ key );
698+ $ getEntityFunctionCall = sprintf ("\t\t\$this->%s->getEntity( " , $ stepKey );
700699 $ dataPersistenceHandlerFunctionCall = sprintf (
701700 "\t\t\$this->%s = new DataPersistenceHandler($%s " ,
702- $ key ,
701+ $ stepKey ,
703702 $ entity
704703 );
705704 } else {
706- $ getEntityFunctionCall = sprintf ("\t\t\$%s->getEntity( " , $ key );
705+ $ getEntityFunctionCall = sprintf ("\t\t\$%s->getEntity( " , $ stepKey );
707706 $ dataPersistenceHandlerFunctionCall = sprintf (
708707 "\t\t$%s = new DataPersistenceHandler($%s " ,
709- $ key ,
708+ $ stepKey ,
710709 $ entity
711710 );
712711 }
@@ -1543,11 +1542,12 @@ private function stripQuotes($inStr)
15431542 /**
15441543 * Validate action attributes are either not set at all or only one is set for a given rule.
15451544 *
1545+ * @param string $key
15461546 * @param string $tagName
15471547 * @param array $attributes
15481548 * @return void
15491549 */
1550- private function validateXmlAttributesMutuallyExclusive ($ tagName , $ attributes )
1550+ private function validateXmlAttributesMutuallyExclusive ($ key , $ tagName , $ attributes )
15511551 {
15521552 $ rules = [
15531553 [ 'attributes ' => [
@@ -1588,34 +1588,27 @@ private function validateXmlAttributesMutuallyExclusive($tagName, $attributes)
15881588 }
15891589 }
15901590 if ($ count > 1 ) {
1591- $ this ->printRuleErrorToConsole ($ tagName , $ rule ['attributes ' ]);
1591+ $ this ->printRuleErrorToConsole ($ key , $ tagName , $ rule ['attributes ' ]);
15921592 }
15931593 }
15941594 }
15951595
15961596 /**
15971597 * Print rule violation message to console.
15981598 *
1599- * @param $tagName
1600- * @param $attributes
1599+ * @param string $key
1600+ * @param string $tagName
1601+ * @param array $attributes
16011602 * @return void
16021603 */
1603- private function printRuleErrorToConsole ($ tagName , $ attributes )
1604+ private function printRuleErrorToConsole ($ key , $ tagName , $ attributes )
16041605 {
16051606 if (empty ($ tagName ) || empty ($ attributes )) {
16061607 return ;
16071608 }
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" ;
16191612 print $ message ;
16201613 }
16211614}
0 commit comments