Skip to content

Commit 2f8a020

Browse files
the text has been added to the readme for number of mocked function calls sections in the readme
1 parent 8011568 commit 2f8a020

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,4 +477,30 @@ $dateInstance->getDate(12, 2015);
477477

478478
echo $mockMethod->getCallCount('getDate');//2
479479

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
480506
```

0 commit comments

Comments
 (0)