@@ -20,7 +20,6 @@ functions as: `time()`, `str_contains()`, `rand`, etc.
2020 - [ Tracking calls] ( #tracking-calls )
2121- [ Global namespaced functions] ( #global-namespaced-functions )
2222 - [ Internal functions] ( #internal-functions )
23- - [ Workaround] ( #workaround )
2423 - [ Internal function implementation] ( #internal-function-implementation )
2524- [ Restrictions] ( #restrictions )
2625 - [ Data Providers] ( #data-providers )
@@ -76,6 +75,14 @@ The main idea is pretty simple: register a Listener for PHPUnit and call the Moc
7675
7776Here you have registered extension that will be called every time when you run `./vendor/bin/phpunit`.
7877
78+ By default, all functions will be generated and saved into `/vendor/bin/xepozz/internal-mocker/data/mocks.php` file.
79+
80+ Override the first argument of the `Mocker` constructor to change the path:
81+
82+ ```php
83+ $mocker = new Mocker('/path/to/your/mocks.php');
84+ ```
85+
7986### Register mocks
8087
8188The package supports a few ways to mock functions:
@@ -216,16 +223,22 @@ $traces = MockerState::getTraces('App\Service', 'time');
216223]
217224```
218225
219- ## Global namespaced functions
226+ ### Function signature stubs
220227
221- ### Internal functions
228+ All internal functions are stubbed to be compatible with the original ones.
229+ It makes the functions use referenced arguments (` &$file ` ) as the originals do.
222230
223- Without any additional configuration you can mock only functions that are defined under any not global
224- namespaces: ` App\ ` , ` App\Service\ ` , etc.
225- But you cannot mock functions that are defined under global namespace or defined in a ` use ` statement, e.g. ` use time; `
226- or ` \time(); ` .
231+ They are located in the [ ` src/stubs.php ` ] ( src/stubs.php ) file.
227232
228- #### Workaround
233+ If you need to add a new function signature, override the second argument of the ` Mocker ` constructor:
234+
235+ ``` php
236+ $mocker = new Mocker(stubPath: '/path/to/your/stubs.php');
237+ ```
238+
239+ ## Global namespaced functions
240+
241+ ### Internal functions
229242
230243The way you can mock global functions is to disable them
231244in ` php.ini ` : https://www.php.net/manual/en/ini.core.php#ini.disable-functions
@@ -269,6 +282,9 @@ $mocks[] = [
269282];
270283```
271284
285+ > Keep in mind that leaving a global function without implementation will cause a recourse call of the function,
286+ > that will lead to a fatal error.
287+
272288## Restrictions
273289
274290### Data Providers
0 commit comments