@@ -149,58 +149,76 @@ public function generateSuite($suiteName)
149
149
*/
150
150
public function generateTestgroupmembership ($ testManifest )
151
151
{
152
- // Get suits and subsuites data array
153
- $ suites = $ testManifest ->getSuiteConfig ();
154
-
155
- // Add subsuites array[2nd dimension] to main array[1st dimension] to access it directly later
156
- if (!empty ($ suites )) {
157
- foreach ($ suites as $ subSuites ) {
158
- if (!empty ($ subSuites )) {
159
- foreach ($ subSuites as $ subSuiteName => $ suiteTestNames ) {
160
- if (!is_numeric ($ subSuiteName )) {
161
- $ suites [$ subSuiteName ] = $ suiteTestNames ;
162
- } else {
163
- continue ;
164
- }
152
+ // Get suits and subsuites data array
153
+ $ suites = $ testManifest ->getSuiteConfig ();
154
+
155
+ // Add subsuites array[2nd dimension] to main array[1st dimension] to access it directly later
156
+ if (!empty ($ suites )) {
157
+ foreach ($ suites as $ subSuites ) {
158
+ if (!empty ($ subSuites )) {
159
+ foreach ($ subSuites as $ subSuiteName => $ suiteTestNames ) {
160
+ if (!is_numeric ($ subSuiteName )) {
161
+ $ suites [$ subSuiteName ] = $ suiteTestNames ;
162
+ } else {
163
+ continue ;
165
164
}
166
165
}
167
166
}
168
167
}
168
+ }
169
169
170
- // Path to groups folder
171
- $ baseDir = FilePathFormatter::format (TESTS_MODULE_PATH );
172
- $ path = $ baseDir .'_generated/groups ' ;
170
+ // Path to groups folder
171
+ $ baseDir = FilePathFormatter::format (TESTS_MODULE_PATH );
172
+ $ path = $ baseDir .'_generated/groups ' ;
173
173
174
- // Read all group files
175
- if (is_dir ($ path )) {
176
- $ groupFiles = glob ("$ path/group*.txt " );
177
- if ($ groupFiles === false ) {
178
- throw new RuntimeException ("glob(): error with ' $ path' " );
179
- }
180
- sort ($ groupFiles , SORT_NATURAL );
174
+ // Read all group files
175
+ if (is_dir ($ path )) {
176
+ $ groupFiles = glob ("$ path/group*.txt " );
177
+ if ($ groupFiles === false ) {
178
+ throw new RuntimeException ("glob(): error with ' $ path' " );
181
179
}
180
+ sort ($ groupFiles , SORT_NATURAL );
181
+ }
182
182
183
- // Read each file in the reverse order and form an array with groupId as key
184
- $ groupNumber = 0 ;
185
- while (!empty ($ groupFiles )){
186
- $ group = array_pop ($ groupFiles );
187
- $ allGroupsContent [$ groupNumber ] = file ($ group );
188
- $ groupNumber ++;
189
- }
190
-
191
- // Output file path
192
- $ memberShipFilePath = $ baseDir .'_generated/testgroupmembership.txt ' ;
193
-
183
+ // Read each file in the reverse order and form an array with groupId as key
184
+ $ groupNumber = 0 ;
185
+ $ allGroupsContent = array ();
186
+ while (!empty ($ groupFiles )){
187
+ $ group = array_pop ($ groupFiles );
188
+ $ allGroupsContent [$ groupNumber ] = file ($ group );
189
+ $ groupNumber ++;
190
+ }
194
191
195
- if (!empty ($ allGroupsContent )) {
196
- foreach ($ allGroupsContent as $ groupId => $ groupInfo ) {
197
- foreach ($ groupInfo as $ testName ) {
198
- file_put_contents ($ memberShipFilePath , $ testName . PHP_EOL , FILE_APPEND );
192
+ // Output file path
193
+ $ memberShipFilePath = $ baseDir .'_generated/testgroupmembership.txt ' ;
194
+ $ testCaseNumber = 0 ;
195
+ echo "groups array-><pre> " ;
196
+ print_r ($ allGroupsContent );
197
+ if (!empty ($ allGroupsContent )) {
198
+ foreach ($ allGroupsContent as $ groupId => $ groupInfo ) {
199
+ foreach ($ groupInfo as $ testName ) {
200
+ // If file has -g then it is test suite
201
+ if (str_contains ($ testName , '-g ' )) {
202
+ $ suitename = explode (" " , $ testName );
203
+ $ suitename [1 ] = trim ($ suitename [1 ]);
204
+ if (!empty ($ suites [$ suitename [1 ]])) {
205
+ foreach ($ suites [$ suitename [1 ]] as $ key => $ test ) {
206
+ $ suiteTest = sprintf ('%s:%s:%s:%s ' , $ groupId , $ key , $ suitename [1 ], $ test );
207
+ file_put_contents ($ memberShipFilePath , $ suiteTest . PHP_EOL , FILE_APPEND );
208
+ }
209
+ }
210
+ }
211
+ // It is default test group
212
+ else {
213
+ $ defaultSuiteTest = sprintf ('%s:%s:%s ' , $ groupId , $ testCaseNumber , $ testName );
214
+ file_put_contents ($ memberShipFilePath , $ defaultSuiteTest . PHP_EOL , FILE_APPEND );
199
215
}
216
+ $ testCaseNumber ++;
200
217
}
218
+ $ testCaseNumber = 0 ;
201
219
}
202
-
203
220
}
221
+ }
204
222
205
223
/**
206
224
* Function which takes a suite name and a set of test names. The function then generates all relevant supporting
0 commit comments