@@ -54,11 +54,11 @@ class BaseGenerateCommand extends Command
54
54
private $ testsOutputDir = null ;
55
55
56
56
/**
57
- * File handle for 'failed_all' file
57
+ * String contains all 'failed' tests
58
58
*
59
- * @var resource
59
+ * @var string
60
60
*/
61
- private $ fhFailedAll ;
61
+ private $ allFailed ;
62
62
63
63
/**
64
64
* Console output style
@@ -314,20 +314,7 @@ protected function getTestsOutputDir()
314
314
}
315
315
316
316
/**
317
- * Initialize 'failed_all' file
318
- *
319
- * @return void
320
- * @throws TestFrameworkException
321
- */
322
- protected function initializeFailedAllFile ()
323
- {
324
- // Initialize 'failed_all' file
325
- $ allFailedFile = $ this ->getTestsOutputDir () . self ::FAILED_ALL_FILE ;
326
- $ this ->fhFailedAll = fopen ($ allFailedFile , 'w+ ' );
327
- }
328
-
329
- /**
330
- * Appends content of file 'failed' to file 'failed_all'
317
+ * Save 'failed' tests
331
318
*
332
319
* @return void
333
320
*/
@@ -339,46 +326,41 @@ protected function appendRunFailed()
339
326
}
340
327
341
328
if (file_exists ($ this ->testsFailedFile )) {
342
- // Append 'failed' into 'failed_all'
329
+ // Save 'failed' tests
343
330
$ contents = file_get_contents ($ this ->testsFailedFile );
344
331
if ($ contents !== false && !empty ($ contents )) {
345
- fwrite ( $ this ->fhFailedAll , trim ($ contents ) . PHP_EOL ) ;
332
+ $ this ->allFailed .= trim ($ contents ) . PHP_EOL ;
346
333
}
347
334
}
348
335
} catch (TestFrameworkException $ e ) {
349
336
}
350
337
}
351
338
352
339
/**
353
- * Replace content of file 'failed' with content in file 'failed_all'
340
+ * Apply 'allFailed' in 'failed' file
354
341
*
355
342
* @return void
356
343
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
357
344
*/
358
- protected function updateRunFailedWithFailedAll ()
345
+ protected function applyAllFailed ()
359
346
{
360
347
try {
361
348
if (!$ this ->testsFailedFile ) {
362
349
$ this ->testsFailedFile = $ this ->getTestsOutputDir () . self ::FAILED_FILE ;
363
350
}
364
351
365
- if (file_exists ($ this ->getTestsOutputDir () . self :: FAILED_ALL_FILE )) {
352
+ if (! empty ($ this ->allFailed )) {
366
353
// Update 'failed' with content from 'failed_all'
367
- $ contents = file_get_contents ($ this ->getTestsOutputDir () . self ::FAILED_ALL_FILE );
368
- if ($ contents !== false && !empty ($ contents )) {
369
- if (file_exists ($ this ->testsFailedFile )) {
370
- rename ($ this ->testsFailedFile , $ this ->testsFailedFile . '.copy ' );
371
- }
372
- if (file_put_contents ($ this ->testsFailedFile , $ contents ) === false
373
- && file_exists ($ this ->testsFailedFile . '.copy ' )) {
374
- rename ($ this ->testsFailedFile . '.copy ' , $ this ->testsFailedFile );
375
- }
376
- if (file_exists ($ this ->testsFailedFile . '.copy ' )) {
377
- unlink ($ this ->testsFailedFile . '.copy ' );
378
- }
354
+ if (file_exists ($ this ->testsFailedFile )) {
355
+ rename ($ this ->testsFailedFile , $ this ->testsFailedFile . '.copy ' );
356
+ }
357
+ if (file_put_contents ($ this ->testsFailedFile , $ this ->allFailed ) === false
358
+ && file_exists ($ this ->testsFailedFile . '.copy ' )) {
359
+ rename ($ this ->testsFailedFile . '.copy ' , $ this ->testsFailedFile );
360
+ }
361
+ if (file_exists ($ this ->testsFailedFile . '.copy ' )) {
362
+ unlink ($ this ->testsFailedFile . '.copy ' );
379
363
}
380
- fclose ($ this ->fhFailedAll );
381
- unlink ($ this ->getTestsOutputDir () . self ::FAILED_ALL_FILE );
382
364
}
383
365
} catch (TestFrameworkException $ e ) {
384
366
}
0 commit comments