File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change 46
46
*/
47
47
class PHPUnit_Framework_TestSuite implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing, IteratorAggregate
48
48
{
49
+ /**
50
+ * Last count of tests in this suite.
51
+ *
52
+ * @var integer|null
53
+ */
54
+ private $ cachedNumTests ;
55
+
49
56
/**
50
57
* Enable or disable the backup and restoration of the $GLOBALS array.
51
58
*
@@ -404,14 +411,19 @@ public function addTestFiles($filenames)
404
411
/**
405
412
* Counts the number of test cases that will be run by this test.
406
413
*
414
+ * @Param boolean $preferCache Indicates if cache is preferred.
407
415
* @return integer
408
416
*/
409
- public function count ()
417
+ public function count ($ preferCache = false )
410
418
{
411
- $ numTests = 0 ;
412
-
413
- foreach ($ this as $ test ) {
414
- $ numTests += count ($ test );
419
+ if ($ preferCache && $ this ->cachedNumTests != null ) {
420
+ $ numTests = $ this ->cachedNumTests ;
421
+ } else {
422
+ $ numTests = 0 ;
423
+ foreach ($ this as $ test ) {
424
+ $ numTests += count ($ test );
425
+ }
426
+ $ this ->cachedNumTests = $ numTests ;
415
427
}
416
428
417
429
return $ numTests ;
You can’t perform that action at this time.
0 commit comments