6
6
7
7
namespace Magento \FunctionalTestingFramework \StaticCheck ;
8
8
9
- use Magento \FunctionalTestingFramework \Config \Data ;
10
9
use Magento \FunctionalTestingFramework \Config \MftfApplicationConfig ;
11
10
use Magento \FunctionalTestingFramework \DataGenerator \Handlers \DataObjectHandler ;
11
+ use Magento \FunctionalTestingFramework \Exceptions \TestReferenceException ;
12
+ use Magento \FunctionalTestingFramework \Exceptions \XmlException ;
12
13
use Magento \FunctionalTestingFramework \Page \Handlers \PageObjectHandler ;
13
14
use Magento \FunctionalTestingFramework \Page \Handlers \SectionObjectHandler ;
14
- use Magento \FunctionalTestingFramework \Page \Objects \SectionObject ;
15
15
use Magento \FunctionalTestingFramework \Test \Handlers \ActionGroupObjectHandler ;
16
16
use Magento \FunctionalTestingFramework \Test \Handlers \TestObjectHandler ;
17
17
use Magento \FunctionalTestingFramework \Test \Objects \ActionObject ;
18
18
use Magento \FunctionalTestingFramework \Util \ModuleResolver ;
19
19
use Magento \FunctionalTestingFramework \Util \TestGenerator ;
20
20
use Symfony \Component \Console \Input \InputInterface ;
21
- use Symfony \Component \Filesystem \Filesystem ;
22
21
use Symfony \Component \Finder \Finder ;
22
+ use Exception ;
23
23
24
24
/**
25
25
* Class TestDependencyCheck
@@ -68,11 +68,18 @@ class TestDependencyCheck implements StaticCheckInterface
68
68
*/
69
69
private $ errors ;
70
70
71
+ /**
72
+ * String representing the output summary found after running the execute() function.
73
+ * @var string
74
+ */
75
+ private $ output ;
76
+
71
77
/**
72
78
* Checks test dependencies, determined by references in tests versus the dependencies listed in the Magento module
73
79
*
74
80
* @param InputInterface $input
75
81
* @return string
82
+ * @throws Exception;
76
83
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
77
84
*/
78
85
public function execute (InputInterface $ input )
@@ -109,8 +116,8 @@ public function execute(InputInterface $input)
109
116
$ this ->errors += $ this ->findErrorsInFileSet ($ actionGroupXmlFiles );
110
117
$ this ->errors += $ this ->findErrorsInFileSet ($ dataXmlFiles );
111
118
112
- //print all errors to file
113
- return $ this ->printErrorsToFile ( $ this ->getErrors () );
119
+ // hold on to the output and print any errors to a file
120
+ $ this ->output = $ this ->printErrorsToFile ( );
114
121
}
115
122
116
123
/**
@@ -122,12 +129,17 @@ public function getErrors()
122
129
return $ this ->errors ;
123
130
}
124
131
132
+ public function getOutput ()
133
+ {
134
+ return $ this ->output ;
135
+ }
136
+
125
137
/**
126
138
* Finds all reference errors in given set of files
127
139
* @param Finder $files
128
140
* @return array
129
- * @throws \Magento\FunctionalTestingFramework\Exceptions\ TestReferenceException
130
- * @throws \Magento\FunctionalTestingFramework\Exceptions\ XmlException
141
+ * @throws TestReferenceException
142
+ * @throws XmlException
131
143
*/
132
144
private function findErrorsInFileSet ($ files )
133
145
{
@@ -348,8 +360,7 @@ private function buildFileList($modulePaths, $path)
348
360
* Attempts to find any MFTF entity by its name. Returns null if none are found.
349
361
* @param string $name
350
362
* @return mixed
351
- * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
352
- * @throws \Magento\FunctionalTestingFramework\Exceptions\XmlException
363
+ * @throws XmlException
353
364
*/
354
365
private function findEntity ($ name )
355
366
{
@@ -378,24 +389,29 @@ private function findEntity($name)
378
389
379
390
/**
380
391
* Prints out given errors to file, and returns summary result string
381
- * @param array $errors
382
392
* @return string
383
393
*/
384
- private function printErrorsToFile ($ errors )
394
+ private function printErrorsToFile ()
385
395
{
396
+ $ errors = $ this ->getErrors ();
397
+
386
398
if (empty ($ errors )) {
387
399
return "No Dependency errors found. " ;
388
400
}
401
+
389
402
$ outputPath = getcwd () . DIRECTORY_SEPARATOR . "mftf-dependency-checks.txt " ;
390
403
$ fileResource = fopen ($ outputPath , 'w ' );
391
404
$ header = "MFTF File Dependency Check: \n" ;
392
405
fwrite ($ fileResource , $ header );
406
+
393
407
foreach ($ errors as $ test => $ error ) {
394
408
fwrite ($ fileResource , $ error [0 ] . PHP_EOL );
395
409
}
410
+
396
411
fclose ($ fileResource );
397
412
$ errorCount = count ($ errors );
398
413
$ output = "Dependency errors found across {$ errorCount } file(s). Error details output to {$ outputPath }" ;
414
+
399
415
return $ output ;
400
416
}
401
417
}
0 commit comments