@@ -31,7 +31,8 @@ class UpdateAssertionSchema implements UpgradeInterface
31
31
private $ errors = [];
32
32
33
33
/**
34
- * Upgrades all test xml files, changing <assert> actions to be nested
34
+ * Upgrades all test xml files, changing as many <assert> actions to be nested as possible
35
+ * WILL NOT CATCH cases where style is a mix of old and new
35
36
*
36
37
* @param InputInterface $input
37
38
* @return string
@@ -45,12 +46,9 @@ public function execute(InputInterface $input)
45
46
$ fileSystem = new Filesystem ();
46
47
$ testsUpdated = 0 ;
47
48
foreach ($ finder ->files () as $ file ) {
48
- // if (!$this->detectOldAttributes($file)) {
49
- // continue;
50
- // }
51
49
$ this ->currentFile = $ file ->getFilename ();
52
50
$ contents = $ file ->getContents ();
53
- // Isolate <assert ... /> but not <assert> ... </assert>
51
+ // Isolate <assert ... /> but never <assert> ... </assert>
54
52
preg_match_all ('/<assert[^>]*\/>/ ' , $ contents , $ potentialAssertions );
55
53
$ newAssertions = [];
56
54
$ index = 0 ;
@@ -98,7 +96,6 @@ private function convertOldAssertionToNew($assertion)
98
96
{
99
97
// <assertSomething => assertSomething
100
98
$ assertType = ltrim (explode (' ' , $ assertion )[0 ], '< ' );
101
- $ stepKey = "" ;
102
99
103
100
// regex to grab values
104
101
$ grabValueRegex = '/(stepKey|actual|actualType|expected|expectedType|delta|message|selector|attribute|expectedValue|before|after|remove)=( \'[^ \']* \'|"[^"]*")/ ' ;
@@ -130,9 +127,6 @@ private function convertOldAssertionToNew($assertion)
130
127
}
131
128
$ trimmedParts [$ type ] = $ value ;
132
129
if (in_array ($ type , ["stepKey " , "delta " , "message " , "before " , "after " , "remove " ])) {
133
- if ($ type == "stepKey " ) {
134
- $ stepKey = $ value ;
135
- }
136
130
$ newString .= " $ type= \"$ value \"" ;
137
131
continue ;
138
132
}
@@ -154,7 +148,7 @@ private function convertOldAssertionToNew($assertion)
154
148
if (isset ($ subElements ["expected " ]['value ' ]) && !isset ($ subElements ["expected " ]['type ' ])) {
155
149
$ subElements ["expected " ]['type ' ] = "const " ;
156
150
}
157
- // Massage subElements with data for edge cases
151
+ // Massage subElements with data for edge case
158
152
if ($ assertType == 'assertElementContainsAttribute ' ) {
159
153
// Assert type is very edge-cased, completely different schema
160
154
$ value = $ subElements ['expected ' ]['value ' ] ?? "" ;
@@ -174,12 +168,4 @@ private function convertOldAssertionToNew($assertion)
174
168
$ newString .= " </ $ assertType> " ;
175
169
return $ newString ;
176
170
}
177
-
178
- private function guessValueType ($ string ) {
179
- preg_match ('/\$[a-zA-Z0-9]*/ ' , $ string , $ matches );
180
- if (isset ($ matches [0 ]) && $ matches [0 ] == $ string ) {
181
- return "variable " ;
182
- }
183
- return "string " ;
184
- }
185
171
}
0 commit comments