Skip to content

Commit f5b1839

Browse files
committed
docs: add TOC and so on
1 parent 62f2aa7 commit f5b1839

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@ This provides four monkey patchers.
99
- `MethodPatcher`: Patches Methods in User-defined Classes
1010
- `ConstantPatcher`: Changes Constant Values
1111

12+
## Table of Contents
13+
14+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
15+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
16+
17+
- [Requirements](#requirements)
18+
- [Installation](#installation)
19+
- [Usage](#usage)
20+
- [Configure](#configure)
21+
- [Convert `exit()` to Exception](#convert-exit-to-exception)
22+
- [Patch Functions](#patch-functions)
23+
- [Change Return Value](#change-return-value)
24+
- [Patch Other Functions](#patch-other-functions)
25+
- [Patch Methods in User-defined Classes](#patch-methods-in-user-defined-classes)
26+
- [Patch Constants](#patch-constants)
27+
- [Class Reference](#class-reference)
28+
- [License](#license)
29+
30+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
31+
1232
## Requirements
1333

1434
- PHP 7.3 or later
@@ -84,11 +104,9 @@ So by default we can replace only a dozen pre-defined functions in [FunctionPatc
84104

85105
[MonkeyPatch::patchFunction()]() replaces PHP native function `mt_rand()` in `Welcome::index` method, and it will return `100` in the test method.
86106

87-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v3.0.0/application/tests/controllers/Patching_on_function_test.php).
88-
89107
**Note:** If you call `MonkeyPatch::patchFunction()` without 3rd argument, all the functions (located in `include_paths` and not in `exclude_paths`) called in the test method will be replaced. So, for example, a function in CodeIgniter code might be replaced and it results in unexpected outcome.
90108

91-
**Change Return Value**
109+
#### Change Return Value
92110

93111
You could change return value of patched function using PHP closure:
94112

@@ -117,9 +135,7 @@ You could change return value of patched function using PHP closure:
117135
);
118136
~~~
119137

120-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v3.0.0/application/tests/controllers/Patching_on_function_test.php#L59-L80).
121-
122-
**Patch Other Functions**
138+
#### Patch Other Functions
123139

124140
If you want to patch other functions, you can add them to [functions_to_patch](https://github.com/kenjis/ci-phpunit-test/blob/a4f8ceb4b96650529565be23a77f5dfcda8d4cce/application/tests/Bootstrap.php#L369-L371) in `MonkeyPatchManager::init()`.
125141

0 commit comments

Comments
 (0)