16 use Mustache_Loader_FilesystemLoader;
41 private $mustacheEngine;
50 return dirname(dirname(
__DIR__)) . DIRECTORY_SEPARATOR . self::GROUP_DIR_NAME . DIRECTORY_SEPARATOR;
58 $this->mustacheEngine =
new Mustache_Engine([
59 'loader' =>
new Mustache_Loader_FilesystemLoader(dirname(
__DIR__) . DIRECTORY_SEPARATOR .
"views"),
60 'partials_loader' =>
new Mustache_Loader_FilesystemLoader(
61 dirname(
__DIR__) . DIRECTORY_SEPARATOR .
"views" . DIRECTORY_SEPARATOR .
"partials" 76 $classContent = $this->createClassContent($suiteObject);
77 $configEntry = self::GROUP_DIR_NAME . DIRECTORY_SEPARATOR . $suiteObject->getName();
81 return str_replace(DIRECTORY_SEPARATOR,
"\\", $configEntry);
91 private function createClassContent($suiteObject)
100 $mustacheData[self::BEFORE_MUSTACHE_KEY],
101 $mustacheData[self::AFTER_MUSTACHE_KEY]
104 return $this->mustacheEngine->render(self::MUSTACHE_TEMPLATE_NAME, $mustacheData);
115 private function extractClassVar($beforeArray, $afterArray)
120 return array_merge($beforeVar, $afterVar);
130 private function buildHookMustacheArray($hookObj)
133 $mustacheHookArray[
'actions'][] = [
'webDriverInit' =>
true];
135 foreach ($hookObj->getActions() as $action) {
139 if ($action->getType() !==
"createData" 141 $actions = $this->buildWebDriverActionsMustacheArray($action, $actions,
$index);
146 if ($action->getType() ==
'createData') {
152 $entityArray[$action->getType()] = $action->getStepKey();
154 $entityArray = $this->buildPersistenceMustacheArray($action, $entityArray);
155 $actions[
$index] = $entityArray;
157 $mustacheHookArray[
'actions'] = array_merge($mustacheHookArray[
'actions'], $actions);
158 $mustacheHookArray[
'actions'][] = [
'webDriverReset' =>
true];
160 return $mustacheHookArray;
172 private function buildWebDriverActionsMustacheArray($action, $actionEntries)
175 $rawPhp = str_replace([
"\t",
"\n"],
"", $step);
176 $multipleCommands = explode(
";", $rawPhp, -1);
177 foreach ($multipleCommands as $command) {
178 $actionEntries = $this->replaceReservedTesterFunctions($command .
";", $actionEntries,
'webDriver');
181 return $actionEntries;
193 private function replaceReservedTesterFunctions($formattedStep, $actionEntries, $actor)
195 foreach (self::REPLACEMENT_ACTIONS as $testAction =>
$replacement) {
196 $testActionCall =
"\${$actor}->{$testAction}";
197 if (substr($formattedStep, 0, strlen($testActionCall)) == $testActionCall) {
198 $resultingStep = str_replace($testActionCall,
$replacement, $formattedStep);
199 $actionEntries[] = [
'action' => $resultingStep];
201 $actionEntries[] = [
'action' => $formattedStep];
205 return $actionEntries;
215 private function buildPersistenceMustacheArray($action, $entityArray)
218 $action->getCustomActionAttributes()[
'entity'] ??
222 if (array_key_exists(
'requiredEntities', $action->getCustomActionAttributes())) {
224 $this->buildReqEntitiesMustacheArray($action->getCustomActionAttributes());
228 if (array_key_exists(
'customFields', $action->getCustomActionAttributes())) {
229 $entityArray[
'customFields'] = $action->getStepKey() .
'Fields';
244 private function buildReqEntitiesMustacheArray($customAttributes)
246 $requiredEntities = [];
260 return $requiredEntities;
generateGroupClass($suiteObject)
const REQUIRED_ENTITY_REFERENCE
defined('TESTS_BP')||define('TESTS_BP' __DIR__
const REPLACEMENT_ACTIONS
const MUSTACHE_TEMPLATE_NAME
const BEFORE_MUSTACHE_KEY
const MAGENTO_CLI_COMMAND_COMMAND
static getInstance($dir=null, $tests=[], $debug=false)
const LAST_REQUIRED_ENTITY_TAG
const REQUIRED_ENTITY_KEY