8
8
9
9
use FilesystemIterator ;
10
10
use Magento \FunctionalTestingFramework \DataGenerator \Objects \EntityDataObject ;
11
+ use Magento \FunctionalTestingFramework \Exceptions \TestReferenceException ;
11
12
use Magento \FunctionalTestingFramework \Test \Handlers \CestObjectHandler ;
12
13
use Magento \FunctionalTestingFramework \Test \Objects \ActionObject ;
13
14
use Magento \FunctionalTestingFramework \DataGenerator \Handlers \DataObjectHandler ;
@@ -63,7 +64,7 @@ private function rmdirRecursive($directory)
63
64
{
64
65
$ it = new RecursiveDirectoryIterator ($ directory , FilesystemIterator::SKIP_DOTS );
65
66
66
- while ($ it ->valid ()) {
67
+ while ($ it ->valid ()) {
67
68
$ path = $ directory . DIRECTORY_SEPARATOR . $ it ->getFilename ();
68
69
if ($ it ->isDir ()) {
69
70
$ this ->rmDirRecursive ($ path );
@@ -85,7 +86,7 @@ private function rmdirRecursive($directory)
85
86
public static function getInstance ()
86
87
{
87
88
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 " );
89
90
}
90
91
91
92
return self ::$ testGenerator ;
@@ -152,8 +153,12 @@ private function assembleCestPhp($cestObject)
152
153
$ classAnnotationsPhp = $ this ->generateClassAnnotationsPhp ($ cestObject ->getAnnotations ());
153
154
$ className = $ cestObject ->getName ();
154
155
$ 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
+ }
157
162
158
163
$ cestPhp = "<?php \n" ;
159
164
$ cestPhp .= "namespace Magento\AcceptanceTest\Backend; \n\n" ;
@@ -376,7 +381,7 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
376
381
foreach ($ params as $ param ) {
377
382
$ paramsWithUniqueness [] = $ this ->addUniquenessFunctionCall ($ param );
378
383
}
379
- $ parameterArray = '[ ' . implode (', ' , $ paramsWithUniqueness ) .'] ' ;
384
+ $ parameterArray = '[ ' . implode (', ' , $ paramsWithUniqueness ) . '] ' ;
380
385
}
381
386
382
387
if (isset ($ customActionAttributes ['requiredAction ' ])) {
@@ -865,7 +870,15 @@ private function generateHooksPhp($hookObjects)
865
870
}
866
871
}
867
872
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
+ }
869
882
870
883
if ($ type == "after " ) {
871
884
$ hooks .= sprintf ("\tpublic function _after(%s) \n" , $ dependencies );
@@ -988,7 +1001,11 @@ private function generateTestsPhp($testsObject)
988
1001
$ testName = str_replace (' ' , '' , $ testName );
989
1002
$ testAnnotations = $ this ->generateTestAnnotationsPhp ($ test ->getAnnotations ());
990
1003
$ 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
+ }
992
1009
993
1010
$ testPhp .= $ testAnnotations ;
994
1011
$ testPhp .= sprintf ("\tpublic function %s(%s) \n" , $ testName , $ dependencies );
@@ -1014,7 +1031,7 @@ private function addUniquenessFunctionCall($input)
1014
1031
{
1015
1032
$ output = '' ;
1016
1033
1017
- preg_match ('/ ' . EntityDataObject::CEST_UNIQUE_FUNCTION .'\("[\w]+"\)/ ' , $ input , $ matches );
1034
+ preg_match ('/ ' . EntityDataObject::CEST_UNIQUE_FUNCTION . '\("[\w]+"\)/ ' , $ input , $ matches );
1018
1035
if (!empty ($ matches )) {
1019
1036
$ parts = preg_split ('/ ' . EntityDataObject::CEST_UNIQUE_FUNCTION . '\("[\w]+"\)/ ' , $ input , -1 );
1020
1037
for ($ i = 0 ; $ i < count ($ parts ); $ i ++) {
@@ -1082,6 +1099,7 @@ private function addDollarSign($input)
1082
1099
}
1083
1100
1084
1101
// @codingStandardsIgnoreStart
1102
+
1085
1103
/**
1086
1104
* Wrap parameters into a function call.
1087
1105
*
0 commit comments