88
99use FilesystemIterator ;
1010use Magento \FunctionalTestingFramework \DataGenerator \Objects \EntityDataObject ;
11+ use Magento \FunctionalTestingFramework \Exceptions \TestReferenceException ;
1112use Magento \FunctionalTestingFramework \Test \Handlers \CestObjectHandler ;
1213use Magento \FunctionalTestingFramework \Test \Objects \ActionObject ;
1314use Magento \FunctionalTestingFramework \DataGenerator \Handlers \DataObjectHandler ;
@@ -63,7 +64,7 @@ private function rmdirRecursive($directory)
6364 {
6465 $ it = new RecursiveDirectoryIterator ($ directory , FilesystemIterator::SKIP_DOTS );
6566
66- while ($ it ->valid ()) {
67+ while ($ it ->valid ()) {
6768 $ path = $ directory . DIRECTORY_SEPARATOR . $ it ->getFilename ();
6869 if ($ it ->isDir ()) {
6970 $ this ->rmDirRecursive ($ path );
@@ -85,7 +86,7 @@ private function rmdirRecursive($directory)
8586 public static function getInstance ()
8687 {
8788 if (!self ::$ testGenerator ) {
88- self ::$ testGenerator = new TestGenerator (TESTS_MODULE_PATH . DIRECTORY_SEPARATOR . "_generated " );
89+ self ::$ testGenerator = new TestGenerator (TESTS_MODULE_PATH . DIRECTORY_SEPARATOR . "_generated " );
8990 }
9091
9192 return self ::$ testGenerator ;
@@ -152,8 +153,12 @@ private function assembleCestPhp($cestObject)
152153 $ classAnnotationsPhp = $ this ->generateClassAnnotationsPhp ($ cestObject ->getAnnotations ());
153154 $ className = $ cestObject ->getName ();
154155 $ className = str_replace (' ' , '' , $ className );
155- $ hookPhp = $ this ->generateHooksPhp ($ cestObject ->getHooks ());
156- $ testsPhp = $ this ->generateTestsPhp ($ cestObject ->getTests ());
156+ try {
157+ $ hookPhp = $ this ->generateHooksPhp ($ cestObject ->getHooks ());
158+ $ testsPhp = $ this ->generateTestsPhp ($ cestObject ->getTests ());
159+ } catch (TestReferenceException $ e ) {
160+ throw new TestReferenceException ($ e ->getMessage (). " in Cest \"" . $ cestObject ->getName () . "\"" );
161+ }
157162
158163 $ cestPhp = "<?php \n" ;
159164 $ cestPhp .= "namespace Magento\AcceptanceTest\Backend; \n\n" ;
@@ -376,7 +381,7 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
376381 foreach ($ params as $ param ) {
377382 $ paramsWithUniqueness [] = $ this ->addUniquenessFunctionCall ($ param );
378383 }
379- $ parameterArray = '[ ' . implode (', ' , $ paramsWithUniqueness ) .'] ' ;
384+ $ parameterArray = '[ ' . implode (', ' , $ paramsWithUniqueness ) . '] ' ;
380385 }
381386
382387 if (isset ($ customActionAttributes ['requiredAction ' ])) {
@@ -865,7 +870,15 @@ private function generateHooksPhp($hookObjects)
865870 }
866871 }
867872
868- $ steps = $ this ->generateStepsPhp ($ hookObject ->getActions (), $ hookObject ->getCustomData (), $ createData );
873+ try {
874+ $ steps = $ this ->generateStepsPhp (
875+ $ hookObject ->getActions (),
876+ $ hookObject ->getCustomData (),
877+ $ createData
878+ );
879+ } catch (TestReferenceException $ e ) {
880+ throw new TestReferenceException ($ e ->getMessage () . " in Element \"" . $ type . "\"" );
881+ }
869882
870883 if ($ type == "after " ) {
871884 $ hooks .= sprintf ("\tpublic function _after(%s) \n" , $ dependencies );
@@ -988,7 +1001,11 @@ private function generateTestsPhp($testsObject)
9881001 $ testName = str_replace (' ' , '' , $ testName );
9891002 $ testAnnotations = $ this ->generateTestAnnotationsPhp ($ test ->getAnnotations ());
9901003 $ dependencies = 'AcceptanceTester $I ' ;
991- $ steps = $ this ->generateStepsPhp ($ test ->getOrderedActions (), $ test ->getCustomData ());
1004+ try {
1005+ $ steps = $ this ->generateStepsPhp ($ test ->getOrderedActions (), $ test ->getCustomData ());
1006+ } catch (TestReferenceException $ e ) {
1007+ throw new TestReferenceException ($ e ->getMessage () . " in Test \"" . $ test ->getName () . "\"" );
1008+ }
9921009
9931010 $ testPhp .= $ testAnnotations ;
9941011 $ testPhp .= sprintf ("\tpublic function %s(%s) \n" , $ testName , $ dependencies );
@@ -1014,7 +1031,7 @@ private function addUniquenessFunctionCall($input)
10141031 {
10151032 $ output = '' ;
10161033
1017- preg_match ('/ ' . EntityDataObject::CEST_UNIQUE_FUNCTION .'\("[\w]+"\)/ ' , $ input , $ matches );
1034+ preg_match ('/ ' . EntityDataObject::CEST_UNIQUE_FUNCTION . '\("[\w]+"\)/ ' , $ input , $ matches );
10181035 if (!empty ($ matches )) {
10191036 $ parts = preg_split ('/ ' . EntityDataObject::CEST_UNIQUE_FUNCTION . '\("[\w]+"\)/ ' , $ input , -1 );
10201037 for ($ i = 0 ; $ i < count ($ parts ); $ i ++) {
@@ -1082,6 +1099,7 @@ private function addDollarSign($input)
10821099 }
10831100
10841101 // @codingStandardsIgnoreStart
1102+
10851103 /**
10861104 * Wrap parameters into a function call.
10871105 *
0 commit comments