6
6
7
7
namespace Magento \FunctionalTestingFramework \Upgrade ;
8
8
9
+ use Magento \FunctionalTestingFramework \Util \Script \ScriptUtil ;
9
10
use Symfony \Component \Console \Input \InputInterface ;
10
11
use Symfony \Component \Console \Output \OutputInterface ;
11
12
use Symfony \Component \Filesystem \Filesystem ;
@@ -27,33 +28,39 @@ class UpdateAssertionSchema implements UpgradeInterface
27
28
*/
28
29
public function execute (InputInterface $ input , OutputInterface $ output )
29
30
{
30
- $ testsPath = $ input ->getArgument ('path ' );
31
- $ finder = new Finder ();
32
- $ finder ->files ()->in ($ testsPath )->name ("*.xml " );
31
+ $ testPaths [] = $ input ->getArgument ('path ' );
32
+ if (empty ($ testPaths [0 ])) {
33
+ $ testPaths = ScriptUtil::getAllModulePaths ();
34
+ }
33
35
34
- $ fileSystem = new Filesystem ();
35
36
$ testsUpdated = 0 ;
36
- foreach ($ finder ->files () as $ file ) {
37
- $ contents = $ file ->getContents ();
38
- // Isolate <assert ... /> but never <assert> ... </assert>, stops after finding first />
39
- preg_match_all ('/<assert.*\/>/ ' , $ contents , $ potentialAssertions );
40
- $ newAssertions = [];
41
- $ index = 0 ;
42
- if (empty ($ potentialAssertions [0 ])) {
43
- continue ;
44
- }
45
- foreach ($ potentialAssertions [0 ] as $ potentialAssertion ) {
46
- $ newAssertions [$ index ] = $ this ->convertOldAssertionToNew ($ potentialAssertion );
47
- $ index ++;
48
- }
49
- foreach ($ newAssertions as $ currentIndex => $ replacements ) {
50
- $ contents = str_replace ($ potentialAssertions [0 ][$ currentIndex ], $ replacements , $ contents );
37
+ foreach ($ testPaths as $ testsPath ) {
38
+ $ finder = new Finder ();
39
+ $ finder ->files ()->in ($ testsPath )->name ("*.xml " );
40
+
41
+ $ fileSystem = new Filesystem ();
42
+ foreach ($ finder ->files () as $ file ) {
43
+ $ contents = $ file ->getContents ();
44
+ // Isolate <assert ... /> but never <assert> ... </assert>, stops after finding first />
45
+ preg_match_all ('/<assert.*\/>/ ' , $ contents , $ potentialAssertions );
46
+ $ newAssertions = [];
47
+ $ index = 0 ;
48
+ if (empty ($ potentialAssertions [0 ])) {
49
+ continue ;
50
+ }
51
+ foreach ($ potentialAssertions [0 ] as $ potentialAssertion ) {
52
+ $ newAssertions [$ index ] = $ this ->convertOldAssertionToNew ($ potentialAssertion );
53
+ $ index ++;
54
+ }
55
+ foreach ($ newAssertions as $ currentIndex => $ replacements ) {
56
+ $ contents = str_replace ($ potentialAssertions [0 ][$ currentIndex ], $ replacements , $ contents );
57
+ }
58
+ $ fileSystem ->dumpFile ($ file ->getRealPath (), $ contents );
59
+ $ testsUpdated ++;
51
60
}
52
- $ fileSystem ->dumpFile ($ file ->getRealPath (), $ contents );
53
- $ testsUpdated ++;
54
61
}
55
62
56
- return ("Assertion Syntax updated in {$ testsUpdated } file(s). \n " );
63
+ return ("Assertion Syntax updated in {$ testsUpdated } file(s). " );
57
64
}
58
65
59
66
/**
0 commit comments