@@ -47,6 +47,13 @@ class RemoveModuleFileInSuiteFiles implements UpgradeInterface
47
47
*/
48
48
private $ testsUpdated = 0 ;
49
49
50
+ /**
51
+ * Indicate if a match and replace has happened
52
+ *
53
+ * @var boolean
54
+ */
55
+ private $ replaced = false ;
56
+
50
57
/**
51
58
* Scan all suite xml files, remove <module file="".../> node, and print update message
52
59
*
@@ -82,7 +89,12 @@ private function processXmlFiles($xmlFiles)
82
89
foreach ($ xmlFiles as $ file ) {
83
90
$ contents = $ file ->getContents ();
84
91
$ filePath = $ file ->getRealPath ();
85
- file_put_contents ($ filePath , $ this ->removeModuleFileAttributeInSuite ($ contents , $ filePath ));
92
+ $ this ->replaced = false ;
93
+ $ contents = $ this ->removeModuleFileAttributeInSuite ($ contents , $ filePath );
94
+ if ($ this ->replaced ) {
95
+ file_put_contents ($ filePath , $ contents );
96
+ $ this ->testsUpdated ++;
97
+ }
86
98
}
87
99
}
88
100
@@ -112,9 +124,9 @@ function ($matches) use ($file) {
112
124
. '" ' . trim ($ matches [0 ]) . '" ' . PHP_EOL
113
125
. 'is commented out from file: ' . $ file . PHP_EOL
114
126
);
115
- $ this ->testsUpdated += 1 ;
116
127
$ result = str_replace ('<module ' , '<!--module ' , $ matches [0 ]);
117
128
$ result = str_replace ('> ' , '--> <!-- Please replace with <test name="" --> ' , $ result );
129
+ $ this ->replaced = true ;
118
130
return $ result ;
119
131
},
120
132
$ contents
0 commit comments