Skip to content

Commit be8669e

Browse files
committed
Add doc
1 parent e3581a9 commit be8669e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ functions as: `time()`, `str_contains()`, `rand`, etc.
1717
- [Pre-defined mock](#pre-defined-mock)
1818
- [Mix of two previous ways](#mix-of-two-previous-ways)
1919
- [State](#state)
20+
- [Tracking calls](#tracking-calls)
2021
- [Global namespaced functions](#global-namespaced-functions)
2122
- [Internal functions](#internal-functions)
2223
- [Workaround](#workaround)
@@ -183,6 +184,27 @@ These methods save "current" state and unload each `Runtime mock` mock that was
183184

184185
Using `MockerState::saveState()` after `Mocker->load($mocks)` saves only **_Pre-defined_** mocks.
185186

187+
### Tracking calls
188+
189+
You may track calls of mocked functions by using `MockerState::getTraces()` method.
190+
191+
```php
192+
$traces = MockerState::getTraces('App\Service', 'time');
193+
```
194+
195+
`$traces` will contain an array of arrays with the following structure:
196+
197+
```php
198+
[
199+
[
200+
'arguments' => [], // arguments of the function
201+
'trace' => [], // the result of debug_backtrace function
202+
'result' => 1708764835, // result of the function
203+
],
204+
// ...
205+
]
206+
```
207+
186208
## Global namespaced functions
187209

188210
### Internal functions

0 commit comments

Comments
 (0)