Skip to content

Commit

Permalink
Add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
xepozz committed Feb 24, 2024
1 parent e3581a9 commit be8669e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ functions as: `time()`, `str_contains()`, `rand`, etc.
- [Pre-defined mock](#pre-defined-mock)
- [Mix of two previous ways](#mix-of-two-previous-ways)
- [State](#state)
- [Tracking calls](#tracking-calls)
- [Global namespaced functions](#global-namespaced-functions)
- [Internal functions](#internal-functions)
- [Workaround](#workaround)
Expand Down Expand Up @@ -183,6 +184,27 @@ These methods save "current" state and unload each `Runtime mock` mock that was

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

### Tracking calls

You may track calls of mocked functions by using `MockerState::getTraces()` method.

```php
$traces = MockerState::getTraces('App\Service', 'time');
```

`$traces` will contain an array of arrays with the following structure:

```php
[
[
'arguments' => [], // arguments of the function
'trace' => [], // the result of debug_backtrace function
'result' => 1708764835, // result of the function
],
// ...
]
```

## Global namespaced functions

### Internal functions
Expand Down

0 comments on commit be8669e

Please sign in to comment.