Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Namespaces | Data Structures | Functions | Variables
Magento\FunctionalTestingFramework\Util Namespace Reference

Namespaces

 Env
 
 Filesystem
 
 Iterator
 
 Logger
 
 Manifest
 
 
 ModuleResolver
 
 Protocol
 
 Sorter
 
 Validation
 

Data Structures

class  ConfigSanitizerUtil
 
class  MagentoTestCase
 
class  ModulePathExtractor
 
class  ModuleResolver
 
class  TestGenerator
 

Functions

 generateStepsPhp ($actionObjects, $generationScope=TestGenerator::TEST_SCOPE, $actor="I")
 

Variables

return $annotationToAppend
 

Detailed Description

Copyright © Magento, Inc. All rights reserved. See COPYING.txt for license details.

Function Documentation

◆ generateStepsPhp()

Magento\FunctionalTestingFramework\Util\generateStepsPhp (   $actionObjects,
  $generationScope = TestGenerator::TEST_SCOPE,
  $actor = "I" 
)

Creates a PHP string for the actions contained withing a <test> block. Since nearly half of all Codeception methods don't share the same signature I had to setup a massive Case statement to handle each unique action. At the bottom of the case statement there is a generic function that can construct the PHP string for nearly half of all Codeception actions.

Parameters
array$actionObjects
string$generationScope
string$actor
Returns
string
Exceptions
TestReferenceException

Definition at line 481 of file TestGenerator.php.

482  {
483  //TODO: Refactor Method according to PHPMD warnings, remove @SuppressWarnings accordingly.
484  $testSteps = "";
485  $this->currentGenerationScope = $generationScope;
486 
487  foreach ($actionObjects as $actionObject) {
488  $stepKey = $actionObject->getStepKey();
489  $customActionAttributes = $actionObject->getCustomActionAttributes();
490  $attribute = null;
491  $selector = null;
492  $selector1 = null;
493  $selector2 = null;
494  $input = null;
495  $parameterArray = null;
496  $returnVariable = null;
497  $x = null;
498  $y = null;
499  $html = null;
500  $url = null;
501  $function = null;
502  $time = null;
503  $locale = null;
504  $username = null;
505  $password = null;
506  $width = null;
507  $height = null;
508  $requiredAction = null;
509  $value = null;
510  $button = null;
511  $parameter = null;
512  $dependentSelector = null;
513  $visible = null;
514  $command = null;
515  $arguments = null;
516  $sortOrder = null;
517  $storeCode = null;
518  $format = null;
519 
520  $assertExpected = null;
521  $assertActual = null;
522  $assertMessage = null;
523  $assertIsStrict = null;
524  $assertDelta = null;
525 
526  // Validate action attributes and print notice messages on violation.
527  $this->validateXmlAttributesMutuallyExclusive($stepKey, $actionObject->getType(), $customActionAttributes);
528 
529  if (isset($customActionAttributes['command'])) {
530  $command = $this->addUniquenessFunctionCall($customActionAttributes['command']);
531  }
532  if (isset($customActionAttributes['arguments'])) {
533  $arguments = $this->addUniquenessFunctionCall($customActionAttributes['arguments']);
534  }
535 
536  if (isset($customActionAttributes['attribute'])) {
537  $attribute = $customActionAttributes['attribute'];
538  }
539 
540  if (isset($customActionAttributes['sortOrder'])) {
541  $sortOrder = $customActionAttributes['sortOrder'];
542  }
543 
544  if (isset($customActionAttributes['userInput']) && isset($customActionAttributes['url'])) {
545  $input = $this->addUniquenessFunctionCall($customActionAttributes['userInput']);
546  $url = $this->addUniquenessFunctionCall($customActionAttributes['url']);
547  } elseif (isset($customActionAttributes['userInput'])) {
548  $input = $this->addUniquenessFunctionCall($customActionAttributes['userInput']);
549  } elseif (isset($customActionAttributes['url'])) {
550  $input = $this->addUniquenessFunctionCall($customActionAttributes['url']);
551  $url = $this->addUniquenessFunctionCall($customActionAttributes['url']);
552  } elseif (isset($customActionAttributes['expectedValue'])) {
553  //For old Assert backwards Compatibility, remove when deprecating
554  $assertExpected = $this->addUniquenessFunctionCall($customActionAttributes['expectedValue']);
555  } elseif (isset($customActionAttributes['regex'])) {
556  $input = $this->addUniquenessFunctionCall($customActionAttributes['regex']);
557  }
558 
559  if (isset($customActionAttributes['date']) && isset($customActionAttributes['format'])) {
560  $input = $this->addUniquenessFunctionCall($customActionAttributes['date']);
561  if ($input === "") {
562  $input = "\"Now\"";
563  }
564  $format = $this->addUniquenessFunctionCall($customActionAttributes['format']);
565  if ($format === "") {
566  $format = "\"r\"";
567  }
568  }
569 
570  if (isset($customActionAttributes['expected'])) {
571  $assertExpected = $this->resolveValueByType(
572  $customActionAttributes['expected'],
573  isset($customActionAttributes['expectedType']) ? $customActionAttributes['expectedType'] : null
574  );
575  }
576  if (isset($customActionAttributes['actual'])) {
577  $assertActual = $this->resolveValueByType(
578  $customActionAttributes['actual'],
579  isset($customActionAttributes['actualType']) ? $customActionAttributes['actualType'] : null
580  );
581  }
582  if (isset($customActionAttributes['message'])) {
583  $assertMessage = $this->addUniquenessFunctionCall($customActionAttributes['message']);
584  }
585  if (isset($customActionAttributes['delta'])) {
586  $assertDelta = $this->resolveValueByType($customActionAttributes['delta'], "float");
587  }
588  if (isset($customActionAttributes['strict'])) {
589  $assertIsStrict = $this->resolveValueByType($customActionAttributes['strict'], "bool");
590  }
591 
592  if (isset($customActionAttributes['time'])) {
593  $time = $customActionAttributes['time'];
594  }
595  if (isset($customActionAttributes['timeout'])) {
596  $time = $customActionAttributes['timeout'];
597  }
598 
599  if (isset($customActionAttributes['parameterArray']) && $actionObject->getType() != 'pressKey') {
600  // validate the param array is in the correct format
601  $this->validateParameterArray($customActionAttributes['parameterArray']);
602 
603  $parameterArray = "[";
604  $parameterArray .= $this->addUniquenessToParamArray($customActionAttributes['parameterArray']);
605  $parameterArray .= "]";
606  }
607 
608  if (isset($customActionAttributes['requiredAction'])) {
609  $requiredAction = $customActionAttributes['requiredAction'];
610  }
611 
612  if (isset($customActionAttributes['selectorArray'])) {
613  $selector = $customActionAttributes['selectorArray'];
614  } elseif (isset($customActionAttributes['selector'])) {
615  $selector = $this->addUniquenessFunctionCall($customActionAttributes['selector']);
616  $selector = $this->resolveLocatorFunctionInAttribute($selector);
617  }
618 
619  if (isset($customActionAttributes['selector1']) || isset($customActionAttributes['filterSelector'])) {
620  $selectorOneValue = $customActionAttributes['selector1'] ?? $customActionAttributes['filterSelector'];
621  $selector1 = $this->addUniquenessFunctionCall($selectorOneValue);
622  $selector1 = $this->resolveLocatorFunctionInAttribute($selector1);
623  }
624 
625  if (isset($customActionAttributes['selector2']) || isset($customActionAttributes['optionSelector'])) {
626  $selectorTwoValue = $customActionAttributes['selector2'] ?? $customActionAttributes['optionSelector'];
627  $selector2 = $this->addUniquenessFunctionCall($selectorTwoValue);
628  $selector2 = $this->resolveLocatorFunctionInAttribute($selector2);
629  }
630 
631  if (isset($customActionAttributes['x'])) {
632  $x = $customActionAttributes['x'];
633  }
634 
635  if (isset($customActionAttributes['y'])) {
636  $y = $customActionAttributes['y'];
637  }
638 
639  if (isset($customActionAttributes['function'])) {
640  $function = $this->addUniquenessFunctionCall($customActionAttributes['function']);
641  if (in_array($actionObject->getType(), ActionObject::FUNCTION_CLOSURE_ACTIONS)) {
642  // Argument must be a closure function, not a string.
643  $function = trim($function, '"');
644  }
645  // turn $javaVariable => \$javaVariable but not {$mftfVariable}
646  if ($actionObject->getType() == "executeJS") {
647  $function = preg_replace('/(?<!{)(\$[A-Za-z._]+)(?![A-z.]*+\$)/', '\\\\$1', $function);
648  }
649  }
650 
651  if (isset($customActionAttributes['html'])) {
652  $html = $customActionAttributes['html'];
653  }
654 
655  if (isset($customActionAttributes['locale'])) {
656  $locale = $this->wrapWithDoubleQuotes($customActionAttributes['locale']);
657  }
658 
659  if (isset($customActionAttributes['username'])) {
660  $username = $this->wrapWithDoubleQuotes($customActionAttributes['username']);
661  }
662 
663  if (isset($customActionAttributes['password'])) {
664  $password = $this->wrapWithDoubleQuotes($customActionAttributes['password']);
665  }
666 
667  if (isset($customActionAttributes['width'])) {
668  $width = $customActionAttributes['width'];
669  }
670 
671  if (isset($customActionAttributes['height'])) {
672  $height = $customActionAttributes['height'];
673  }
674 
675  if (isset($customActionAttributes['value'])) {
676  $value = $this->wrapWithDoubleQuotes($customActionAttributes['value']);
677  }
678 
679  if (isset($customActionAttributes['button'])) {
680  $button = $this->wrapWithDoubleQuotes($customActionAttributes['button']);
681  }
682 
683  if (isset($customActionAttributes['parameter'])) {
684  $parameter = $this->wrapWithDoubleQuotes($customActionAttributes['parameter']);
685  }
686 
687  if (isset($customActionAttributes['dependentSelector'])) {
688  $dependentSelector = $this->addUniquenessFunctionCall($customActionAttributes['dependentSelector']);
689  }
690 
691  if (isset($customActionAttributes['visible'])) {
692  $visible = $customActionAttributes['visible'];
693  }
694 
695  if (isset($customActionAttributes['storeCode'])) {
696  $storeCode = $customActionAttributes['storeCode'];
697  }
698  switch ($actionObject->getType()) {
699  case "createData":
700  $entity = $customActionAttributes['entity'];
701  //Add an informative statement to help the user debug test runs
702  $testSteps .= sprintf(
703  "\t\t$%s->amGoingTo(\"create entity that has the stepKey: %s\");\n",
704  $actor,
705  $stepKey
706  );
707 
708  //TODO refactor entity field override to not be individual actionObjects
709  $customEntityFields =
710  $customActionAttributes[ActionObjectExtractor::ACTION_OBJECT_PERSISTENCE_FIELDS] ?? [];
711 
712  $requiredEntityKeys = [];
713  foreach ($actionObject->getCustomActionAttributes() as $actionAttribute) {
714  if (is_array($actionAttribute) && $actionAttribute['nodeName'] == 'requiredEntity') {
715  //append ActionGroup if provided
716  $requiredEntityActionGroup = $actionAttribute['actionGroup'] ?? null;
717  $requiredEntityKeys[] = $actionAttribute['createDataKey'] . $requiredEntityActionGroup;
718  }
719  }
720  // Build array of requiredEntities
721  $requiredEntityKeysArray = "";
722  if (!empty($requiredEntityKeys)) {
723  $requiredEntityKeysArray = '"' . implode('", "', $requiredEntityKeys) . '"';
724  }
725  //Determine Scope
726  $scope = PersistedObjectHandler::TEST_SCOPE;
727  if ($generationScope == TestGenerator::HOOK_SCOPE) {
728  $scope = PersistedObjectHandler::HOOK_SCOPE;
729  } elseif ($generationScope == TestGenerator::SUITE_SCOPE) {
730  $scope = PersistedObjectHandler::SUITE_SCOPE;
731  }
732 
733  $createEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->createEntity(";
734  $createEntityFunctionCall .= "\n\t\t\t\"{$stepKey}\",";
735  $createEntityFunctionCall .= "\n\t\t\t\"{$scope}\",";
736  $createEntityFunctionCall .= "\n\t\t\t\"{$entity}\"";
737  $createEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]";
738  if (count($customEntityFields) > 1) {
739  $createEntityFunctionCall .= ",\n\t\t\t\${$stepKey}Fields";
740  } else {
741  $createEntityFunctionCall .= ",\n\t\t\tnull";
742  }
743  if ($storeCode !== null) {
744  $createEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\"";
745  }
746  $createEntityFunctionCall .= "\n\t\t);\n";
747  $testSteps .= $createEntityFunctionCall;
748  break;
749  case "deleteData":
750  if (isset($customActionAttributes['createDataKey'])) {
751  $key = $this->resolveStepKeyReferences(
752  $customActionAttributes['createDataKey'],
753  $actionObject->getActionOrigin(),
754  true
755  );
756  $actionGroup = $actionObject->getCustomActionAttributes()['actionGroup'] ?? null;
757  $key .= $actionGroup;
758  //Add an informative statement to help the user debug test runs
759  $contextSetter = sprintf(
760  "\t\t$%s->amGoingTo(\"delete entity that has the createDataKey: %s\");\n",
761  $actor,
762  $key
763  );
764 
765  //Determine Scope
766  $scope = PersistedObjectHandler::TEST_SCOPE;
767  if ($generationScope == TestGenerator::HOOK_SCOPE) {
768  $scope = PersistedObjectHandler::HOOK_SCOPE;
769  } elseif ($generationScope == TestGenerator::SUITE_SCOPE) {
770  $scope = PersistedObjectHandler::SUITE_SCOPE;
771  }
772 
773  $deleteEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->deleteEntity(";
774  $deleteEntityFunctionCall .= "\n\t\t\t\"{$key}\",";
775  $deleteEntityFunctionCall .= "\n\t\t\t\"{$scope}\"";
776  $deleteEntityFunctionCall .= "\n\t\t);\n";
777 
778  $testSteps .= $contextSetter;
779  $testSteps .= $deleteEntityFunctionCall;
780  } else {
781  $url = $this->resolveAllRuntimeReferences([$url])[0];
782  $url = $this->resolveTestVariable([$url], null)[0];
783  $output = sprintf(
784  "\t\t$%s->deleteEntityByUrl(%s);\n",
785  $actor,
786  $url
787  );
788  $testSteps .= $output;
789  }
790  break;
791  case "updateData":
792  $key = $this->resolveStepKeyReferences(
793  $customActionAttributes['createDataKey'],
794  $actionObject->getActionOrigin(),
795  true
796  );
797  $updateEntity = $customActionAttributes['entity'];
798  $actionGroup = $actionObject->getCustomActionAttributes()['actionGroup'] ?? null;
799  $key .= $actionGroup;
800 
801  //Add an informative statement to help the user debug test runs
802  $testSteps .= sprintf(
803  "\t\t$%s->amGoingTo(\"update entity that has the createdDataKey: %s\");\n",
804  $actor,
805  $key
806  );
807 
808  // Build array of requiredEntities
809  $requiredEntityKeys = [];
810  foreach ($actionObject->getCustomActionAttributes() as $actionAttribute) {
811  if (is_array($actionAttribute) && $actionAttribute['nodeName'] == 'requiredEntity') {
812  //append ActionGroup if provided
813  $requiredEntityActionGroup = $actionAttribute['actionGroup'] ?? null;
814  $requiredEntityKeys[] = $actionAttribute['createDataKey'] . $requiredEntityActionGroup;
815  }
816  }
817  $requiredEntityKeysArray = "";
818  if (!empty($requiredEntityKeys)) {
819  $requiredEntityKeysArray = '"' . implode('", "', $requiredEntityKeys) . '"';
820  }
821 
822  $scope = PersistedObjectHandler::TEST_SCOPE;
823  if ($generationScope == TestGenerator::HOOK_SCOPE) {
824  $scope = PersistedObjectHandler::HOOK_SCOPE;
825  } elseif ($generationScope == TestGenerator::SUITE_SCOPE) {
826  $scope = PersistedObjectHandler::SUITE_SCOPE;
827  }
828 
829  $updateEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->updateEntity(";
830  $updateEntityFunctionCall .= "\n\t\t\t\"{$key}\",";
831  $updateEntityFunctionCall .= "\n\t\t\t\"{$scope}\",";
832  $updateEntityFunctionCall .= "\n\t\t\t\"{$updateEntity}\"";
833  $updateEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]";
834  if ($storeCode !== null) {
835  $updateEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\"";
836  }
837  $updateEntityFunctionCall .= "\n\t\t);\n";
838  $testSteps .= $updateEntityFunctionCall;
839 
840  break;
841  case "getData":
842  $entity = $customActionAttributes['entity'];
843  $index = null;
844  if (isset($customActionAttributes['index'])) {
845  $index = (int)$customActionAttributes['index'];
846  }
847  //Add an informative statement to help the user debug test runs
848  $testSteps .= sprintf(
849  "\t\t$%s->amGoingTo(\"get entity that has the stepKey: %s\");\n",
850  $actor,
851  $stepKey
852  );
853 
854  // Build array of requiredEntities
855  $requiredEntityKeys = [];
856  foreach ($actionObject->getCustomActionAttributes() as $actionAttribute) {
857  if (is_array($actionAttribute) && $actionAttribute['nodeName'] == 'requiredEntity') {
858  $requiredEntityActionGroup = $actionAttribute['actionGroup'] ?? null;
859  $requiredEntityKeys[] = $actionAttribute['createDataKey'] . $requiredEntityActionGroup;
860  }
861  }
862  $requiredEntityKeysArray = "";
863  if (!empty($requiredEntityKeys)) {
864  $requiredEntityKeysArray = '"' . implode('", "', $requiredEntityKeys) . '"';
865  }
866 
867  //Determine Scope
868  $scope = PersistedObjectHandler::TEST_SCOPE;
869  if ($generationScope == TestGenerator::HOOK_SCOPE) {
870  $scope = PersistedObjectHandler::HOOK_SCOPE;
871  } elseif ($generationScope == TestGenerator::SUITE_SCOPE) {
872  $scope = PersistedObjectHandler::SUITE_SCOPE;
873  }
874 
875  //Create Function
876  $getEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->getEntity(";
877  $getEntityFunctionCall .= "\n\t\t\t\"{$stepKey}\",";
878  $getEntityFunctionCall .= "\n\t\t\t\"{$scope}\",";
879  $getEntityFunctionCall .= "\n\t\t\t\"{$entity}\"";
880  $getEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]";
881  if ($storeCode !== null) {
882  $getEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\"";
883  } else {
884  $getEntityFunctionCall .= ",\n\t\t\tnull";
885  }
886  if ($index !== null) {
887  $getEntityFunctionCall .= ",\n\t\t\t{$index}";
888  }
889  $getEntityFunctionCall .= "\n\t\t);\n";
890  $testSteps .= $getEntityFunctionCall;
891 
892  break;
893  case "assertArrayIsSorted":
894  $testSteps .= $this->wrapFunctionCall(
895  $actor,
896  $actionObject,
897  $parameterArray,
898  $this->wrapWithDoubleQuotes($sortOrder)
899  );
900  break;
901  case "seeCurrentUrlEquals":
902  case "seeCurrentUrlMatches":
903  case "dontSeeCurrentUrlEquals":
904  case "dontSeeCurrentUrlMatches":
905  case "seeInPopup":
906  case "saveSessionSnapshot":
907  case "seeInTitle":
908  case "seeInCurrentUrl":
909  case "switchToIFrame":
910  case "switchToWindow":
911  case "typeInPopup":
912  case "dontSee":
913  case "see":
914  $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input, $selector);
915  break;
916  case "switchToNextTab":
917  case "switchToPreviousTab":
918  $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input);
919  break;
920  case "clickWithLeftButton":
921  case "clickWithRightButton":
922  case "moveMouseOver":
923  case "scrollTo":
924  if (!$selector) {
925  $selector = 'null';
926  }
927  $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $x, $y);
928  break;
929  case "dontSeeCookie":
930  case "resetCookie":
931  case "seeCookie":
932  $testSteps .= $this->wrapFunctionCall(
933  $actor,
934  $actionObject,
935  $input,
936  $parameterArray
937  );
938  break;
939  case "grabCookie":
940  $testSteps .= $this->wrapFunctionCallWithReturnValue(
941  $stepKey,
942  $actor,
943  $actionObject,
944  $input,
945  $parameterArray
946  );
947  break;
948  case "dontSeeElement":
949  case "dontSeeElementInDOM":
950  case "dontSeeInFormFields":
951  case "seeElement":
952  case "seeElementInDOM":
953  case "seeInFormFields":
954  $testSteps .= $this->wrapFunctionCall(
955  $actor,
956  $actionObject,
957  $selector,
958  $parameterArray
959  );
960  break;
961  case "pressKey":
962  $parameterArray = $customActionAttributes['parameterArray'] ?? null;
963  if ($parameterArray) {
964  $parameterArray = $this->processPressKey($parameterArray);
965  }
966  $testSteps .= $this->wrapFunctionCall(
967  $actor,
968  $actionObject,
969  $selector,
970  $input,
971  $parameterArray
972  );
973  break;
974  case "selectOption":
975  case "unselectOption":
976  $testSteps .= $this->wrapFunctionCall(
977  $actor,
978  $actionObject,
979  $selector,
980  $input,
981  $parameterArray
982  );
983  break;
984  case "submitForm":
985  $testSteps .= $this->wrapFunctionCall(
986  $actor,
987  $actionObject,
988  $selector,
989  $parameterArray,
990  $button
991  );
992  break;
993  case "dragAndDrop":
994  $testSteps .= $this->wrapFunctionCall(
995  $actor,
996  $actionObject,
997  $selector1,
998  $selector2,
999  $x,
1000  $y
1001  );
1002  break;
1003  case "selectMultipleOptions":
1004  $testSteps .= $this->wrapFunctionCall(
1005  $actor,
1006  $actionObject,
1007  $selector1,
1008  $selector2,
1009  $input,
1010  $parameterArray
1011  );
1012  break;
1013  case "executeInSelenium":
1014  $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $function);
1015  break;
1016  case "executeJS":
1017  $testSteps .= $this->wrapFunctionCallWithReturnValue(
1018  $stepKey,
1019  $actor,
1020  $actionObject,
1021  $function
1022  );
1023  break;
1024  case "performOn":
1025  case "waitForElementChange":
1026  $testSteps .= $this->wrapFunctionCall(
1027  $actor,
1028  $actionObject,
1029  $selector,
1030  $function,
1031  $time
1032  );
1033  break;
1034  case "waitForJS":
1035  $testSteps .= $this->wrapFunctionCall(
1036  $actor,
1037  $actionObject,
1038  $function,
1039  $time
1040  );
1041  break;
1042  case "wait":
1043  case "waitForAjaxLoad":
1044  case "waitForElement":
1045  case "waitForElementVisible":
1046  case "waitForElementNotVisible":
1047  $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $time);
1048  break;
1049  case "waitForPageLoad":
1050  case "waitForText":
1051  $testSteps .= $this->wrapFunctionCall(
1052  $actor,
1053  $actionObject,
1054  $input,
1055  $time,
1056  $selector
1057  );
1058  break;
1059  case "formatMoney":
1060  $testSteps .= $this->wrapFunctionCallWithReturnValue(
1061  $stepKey,
1062  $actor,
1063  $actionObject,
1064  $input,
1065  $locale
1066  );
1067  break;
1068  case "mSetLocale":
1069  $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input, $locale);
1070  break;
1071  case "grabAttributeFrom":
1072  case "grabMultiple":
1073  case "grabFromCurrentUrl":
1074  $testSteps .= $this->wrapFunctionCallWithReturnValue(
1075  $stepKey,
1076  $actor,
1077  $actionObject,
1078  $selector,
1079  $input
1080  );
1081  break;
1082  case "grabTextFrom":
1083  case "grabValueFrom":
1084  $testSteps .= $this->wrapFunctionCallWithReturnValue(
1085  $stepKey,
1086  $actor,
1087  $actionObject,
1088  $selector
1089  );
1090  break;
1091  case "grabPageSource":
1092  $testSteps .= $this->wrapFunctionCallWithReturnValue(
1093  $stepKey,
1094  $actor,
1095  $actionObject
1096  );
1097  break;
1098  case "resizeWindow":
1099  $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $width, $height);
1100  break;
1101  case "searchAndMultiSelectOption":
1102  $testSteps .= $this->wrapFunctionCall(
1103  $actor,
1104  $actionObject,
1105  $selector,
1106  $input,
1107  $parameterArray,
1108  $requiredAction
1109  );
1110  break;
1111  case "seeLink":
1112  case "dontSeeLink":
1113  $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input, $url);
1114  break;
1115  case "setCookie":
1116  $testSteps .= $this->wrapFunctionCall(
1117  $actor,
1118  $actionObject,
1119  $selector,
1120  $input,
1121  $value,
1122  $parameterArray
1123  );
1124  break;
1125  case "amOnPage":
1126  case "amOnSubdomain":
1127  case "amOnUrl":
1128  case "appendField":
1129  case "attachFile":
1130  case "click":
1131  case "dontSeeInField":
1132  case "dontSeeInCurrentUrl":
1133  case "dontSeeInTitle":
1134  case "dontSeeInPageSource":
1135  case "dontSeeOptionIsSelected":
1136  case "fillField":
1137  case "loadSessionSnapshot":
1138  case "seeInField":
1139  case "seeOptionIsSelected":
1140  $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $input);
1141  break;
1142  case "seeNumberOfElements":
1143  $testSteps .= $this->wrapFunctionCall(
1144  $actor,
1145  $actionObject,
1146  $selector,
1147  $input,
1148  $parameterArray
1149  );
1150  break;
1151  case "seeInPageSource":
1152  case "seeInSource":
1153  case "dontSeeInSource":
1154  // TODO: Need to fix xml parser to allow parsing html.
1155  $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $html);
1156  break;
1157  case "conditionalClick":
1158  $testSteps .= $this->wrapFunctionCall(
1159  $actor,
1160  $actionObject,
1161  $selector,
1162  $dependentSelector,
1163  $visible
1164  );
1165  break;
1166  case "assertEquals":
1167  case "assertGreaterOrEquals":
1168  case "assertGreaterThan":
1169  case "assertGreaterThanOrEqual":
1170  case "assertInternalType":
1171  case "assertLessOrEquals":
1172  case "assertLessThan":
1173  case "assertLessThanOrEqual":
1174  case "assertNotEquals":
1175  case "assertInstanceOf":
1176  case "assertNotInstanceOf":
1177  case "assertNotRegExp":
1178  case "assertNotSame":
1179  case "assertRegExp":
1180  case "assertSame":
1181  case "assertStringStartsNotWith":
1182  case "assertStringStartsWith":
1183  case "assertArrayHasKey":
1184  case "assertArrayNotHasKey":
1185  case "assertCount":
1186  case "assertContains":
1187  case "assertNotContains":
1188  case "expectException":
1189  $testSteps .= $this->wrapFunctionCall(
1190  $actor,
1191  $actionObject,
1192  $assertExpected,
1193  $assertActual,
1194  $assertMessage,
1195  $assertDelta
1196  );
1197  break;
1198  case "assertElementContainsAttribute":
1199  // If a blank string or null is passed in we need to pass a blank string to the function.
1200  if (empty($assertExpected)) {
1201  $assertExpected = '""';
1202  }
1203 
1204  $testSteps .= $this->wrapFunctionCall(
1205  $actor,
1206  $actionObject,
1207  $selector,
1208  $this->wrapWithDoubleQuotes($attribute),
1209  $assertExpected
1210  );
1211  break;
1212  case "assertEmpty":
1213  case "assertFalse":
1214  case "assertFileExists":
1215  case "assertFileNotExists":
1216  case "assertIsEmpty":
1217  case "assertNotEmpty":
1218  case "assertNotNull":
1219  case "assertNull":
1220  case "assertTrue":
1221  $testSteps .= $this->wrapFunctionCall(
1222  $actor,
1223  $actionObject,
1224  $assertActual,
1225  $assertMessage
1226  );
1227  break;
1228  case "assertArraySubset":
1229  $testSteps .= $this->wrapFunctionCall(
1230  $actor,
1231  $actionObject,
1232  $assertExpected,
1233  $assertActual,
1234  $assertIsStrict,
1235  $assertMessage
1236  );
1237  break;
1238  case "fail":
1239  $testSteps .= $this->wrapFunctionCall(
1240  $actor,
1241  $actionObject,
1242  $assertMessage
1243  );
1244  break;
1245  case "magentoCLI":
1246  $testSteps .= $this->wrapFunctionCallWithReturnValue(
1247  $stepKey,
1248  $actor,
1249  $actionObject,
1250  $command,
1251  $arguments
1252  );
1253  $testSteps .= sprintf(
1254  "\t\t$%s->comment(\$%s);\n",
1255  $actor,
1256  $stepKey
1257  );
1258  break;
1259  case "field":
1260  $fieldKey = $actionObject->getCustomActionAttributes()['key'];
1261  $input = $this->resolveTestVariable(
1262  [$input],
1263  $actionObject->getActionOrigin()
1264  )[0];
1265  $argRef = "\t\t\$";
1266  $argRef .= str_replace(ucfirst($fieldKey), "", $stepKey) . "Fields['{$fieldKey}'] = ${input};\n";
1267  $testSteps .= $argRef;
1268  break;
1269  case "generateDate":
1270  $timezone = getenv("DEFAULT_TIMEZONE");
1271  if (isset($customActionAttributes['timezone'])) {
1272  $timezone = $customActionAttributes['timezone'];
1273  }
1274 
1275  $dateGenerateCode = "\t\t\$date = new \DateTime();\n";
1276  $dateGenerateCode .= "\t\t\$date->setTimestamp(strtotime({$input}));\n";
1277  $dateGenerateCode .= "\t\t\$date->setTimezone(new \DateTimeZone(\"{$timezone}\"));\n";
1278  $dateGenerateCode .= "\t\t\${$stepKey} = \$date->format({$format});\n";
1279 
1280  $testSteps .= $dateGenerateCode;
1281  break;
1282  case "skipReadinessCheck":
1283  $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $customActionAttributes['state']);
1284  break;
1285  default:
1286  $testSteps .= $this->wrapFunctionCall(
1287  $actor,
1288  $actionObject,
1289  $selector,
1290  $input,
1291  $parameter
1292  );
1293  }
1294  }
1295 
1296  return $testSteps;
1297  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$storeCode
Definition: indexer.php:15
$value
Definition: gender.phtml:16
$format
Definition: list.phtml:12
$entity
Definition: element.phtml:22
$arguments
$index
Definition: list.phtml:44

Variable Documentation

◆ $annotationToAppend

return $annotationToAppend

Definition at line 425 of file TestGenerator.php.