@@ -54,11 +54,11 @@ class BaseGenerateCommand extends Command
5454 private $ testsOutputDir = null ;
5555
5656 /**
57- * File handle for 'failed_all' file
57+ * String contains all 'failed' tests
5858 *
59- * @var resource
59+ * @var string
6060 */
61- private $ fhFailedAll ;
61+ private $ allFailed ;
6262
6363 /**
6464 * Console output style
@@ -314,20 +314,7 @@ protected function getTestsOutputDir()
314314 }
315315
316316 /**
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
331318 *
332319 * @return void
333320 */
@@ -339,46 +326,41 @@ protected function appendRunFailed()
339326 }
340327
341328 if (file_exists ($ this ->testsFailedFile )) {
342- // Append 'failed' into 'failed_all'
329+ // Save 'failed' tests
343330 $ contents = file_get_contents ($ this ->testsFailedFile );
344331 if ($ contents !== false && !empty ($ contents )) {
345- fwrite ( $ this ->fhFailedAll , trim ($ contents ) . PHP_EOL ) ;
332+ $ this ->allFailed .= trim ($ contents ) . PHP_EOL ;
346333 }
347334 }
348335 } catch (TestFrameworkException $ e ) {
349336 }
350337 }
351338
352339 /**
353- * Replace content of file 'failed' with content in file 'failed_all'
340+ * Apply 'allFailed' in 'failed' file
354341 *
355342 * @return void
356343 * @SuppressWarnings(PHPMD.CyclomaticComplexity)
357344 */
358- protected function updateRunFailedWithFailedAll ()
345+ protected function applyAllFailed ()
359346 {
360347 try {
361348 if (!$ this ->testsFailedFile ) {
362349 $ this ->testsFailedFile = $ this ->getTestsOutputDir () . self ::FAILED_FILE ;
363350 }
364351
365- if (file_exists ($ this ->getTestsOutputDir () . self :: FAILED_ALL_FILE )) {
352+ if (! empty ($ this ->allFailed )) {
366353 // 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 ' );
379363 }
380- fclose ($ this ->fhFailedAll );
381- unlink ($ this ->getTestsOutputDir () . self ::FAILED_ALL_FILE );
382364 }
383365 } catch (TestFrameworkException $ e ) {
384366 }
0 commit comments