1212use const PHP_EOL ;
1313use function array_keys ;
1414use function array_merge ;
15- use function array_shift ;
15+ use function array_pop ;
16+ use function array_reverse ;
1617use function assert ;
1718use function call_user_func ;
1819use function class_exists ;
@@ -128,7 +129,7 @@ public static function fromClassReflector(ReflectionClass $class, array $groups
128129 $ testSuite ->addTestMethod ($ class , $ method , $ groups );
129130 }
130131
131- if (count ( $ testSuite) === 0 ) {
132+ if ($ testSuite-> isEmpty () ) {
132133 Event \Facade::emitter ()->testRunnerTriggeredWarning (
133134 sprintf (
134135 'No tests found in class "%s". ' ,
@@ -297,7 +298,13 @@ public function count(): int
297298
298299 public function isEmpty (): bool
299300 {
300- return empty ($ this ->tests );
301+ foreach ($ this as $ test ) {
302+ if (count ($ test ) !== 0 ) {
303+ return false ;
304+ }
305+ }
306+
307+ return true ;
301308 }
302309
303310 /**
@@ -366,7 +373,7 @@ public function run(): void
366373
367374 $ this ->wasRun = true ;
368375
369- if (count ( $ this ) === 0 ) {
376+ if ($ this -> isEmpty () ) {
370377 return ;
371378 }
372379
@@ -386,10 +393,12 @@ public function run(): void
386393 $ tests [] = $ test ;
387394 }
388395
396+ $ tests = array_reverse ($ tests );
397+
389398 $ this ->tests = [];
390399 $ this ->groups = [];
391400
392- while ($ test = array_shift ($ tests )) {
401+ while (( $ test = array_pop ($ tests )) !== null ) {
393402 if (TestResultFacade::shouldStop ()) {
394403 $ emitter ->testRunnerExecutionAborted ();
395404
0 commit comments