From be8669e4bf1c104221f1328d962893c5b2f92649 Mon Sep 17 00:00:00 2001 From: Dmitrii Derepko Date: Sat, 24 Feb 2024 15:54:24 +0700 Subject: [PATCH] Add doc --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 22e3c43..55c0c9d 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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