File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -477,4 +477,30 @@ $dateInstance->getDate(12, 2015);
477
477
478
478
echo $mockMethod->getCallCount('getDate');//2
479
479
480
+ ```
481
+ ### number of mocked function calls
482
+ We can get how many times the mocked function was called, inside the scope, outside the scope and in total.
483
+ ``` php
484
+ $mockFunction = new MockFunction();
485
+
486
+ $mockFunction->add('time', function () {
487
+ return 100;
488
+ });
489
+
490
+ $mockFunction->scope();
491
+ time(); //100
492
+ time(); //100
493
+ $mockFunction->getCalledCountInScope('time'); //2
494
+ $mockFunction->getCalledCountOutScope('time');//0
495
+
496
+ $mockFunction->endScope();
497
+
498
+ time(); //it returns real time not the 100
499
+ time(); //it returns real time not the 100
500
+ time(); //it returns real time not the 100
501
+
502
+
503
+ $mockFunction->getCalledCountOutScope('time'); //3
504
+
505
+ $mockFunction->getTotalCount('time'); //5
480
506
```
You can’t perform that action at this time.
0 commit comments