@@ -3,12 +3,12 @@ Testing
33#######
44
55CodeIgniter has been built to make testing both the framework and your application as simple as possible.
6- Support for `` PHPUnit `` is built in, and the framework provides a number of convenient
6+ Support for `PHPUnit < https://phpunit.de/ >`__ is built in, and the framework provides a number of convenient
77helper methods to make testing every aspect of your application as painless as possible.
88
99.. contents ::
1010 :local:
11- :depth: 2
11+ :depth: 3
1212
1313*************
1414System Set Up
@@ -35,7 +35,11 @@ application and system directories) type the following from the command line::
3535This will install the correct version for your current PHP version. Once that is done, you can run all of the
3636tests for this project by typing::
3737
38- > ./vendor/bin/phpunit
38+ > vendor/bin/phpunit
39+
40+ If you are using Windows, use the following command::
41+
42+ > vendor\bin\phpunit
3943
4044Phar
4145----
@@ -144,8 +148,8 @@ Ensure that a header or cookie was actually emitted:
144148
145149.. literalinclude :: overview/009.php
146150
147- Note : the test case with this should be `run as a separate process
148- in PHPunit <https://phpunit.readthedocs.io/en/9.5/annotations.html#runinseparateprocess> `_.
151+ .. note : : the test case with this should be `run as a separate process
152+ in PHPunit <https://phpunit.readthedocs.io/en/9.5/annotations.html#runinseparateprocess>`_.
149153
150154assertHeaderNotEmitted($header, $ignoreCase = false)
151155^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -154,8 +158,8 @@ Ensure that a header or cookie was not emitted:
154158
155159.. literalinclude :: overview/010.php
156160
157- Note : the test case with this should be `run as a separate process
158- in PHPunit <https://phpunit.readthedocs.io/en/9.5/annotations.html#runinseparateprocess> `_.
161+ .. note : : the test case with this should be `run as a separate process
162+ in PHPunit <https://phpunit.readthedocs.io/en/9.5/annotations.html#runinseparateprocess>`_.
159163
160164assertCloseEnough($expected, $actual, $message = '', $tolerance = 1)
161165^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -215,8 +219,8 @@ your tests to only the code in question, while simulating various responses from
215219true when testing controllers and other integration testing. The **Services ** class provides the following methods
216220to simplify this.
217221
218- injectMock()
219- ------------
222+ Services:: injectMock()
223+ ----------------------
220224
221225This method allows you to define the exact instance that will be returned by the Services class. You can use this to
222226set properties of a service so that it behaves in a certain way, or replace a service with a mocked class.
@@ -226,13 +230,15 @@ set properties of a service so that it behaves in a certain way, or replace a se
226230The first parameter is the service that you are replacing. The name must match the function name in the Services
227231class exactly. The second parameter is the instance to replace it with.
228232
229- reset()
230- -------
233+ Services:: reset()
234+ -----------------
231235
232236Removes all mocked classes from the Services class, bringing it back to its original state.
233237
234- resetSingle(string $name)
235- -------------------------
238+ You can also use the ``$this->resetServices() `` method that ``CIUnitTestCase `` provides.
239+
240+ Services::resetSingle(string $name)
241+ -----------------------------------
236242
237243Removes any mock and shared instances for a single service, by its name.
238244
@@ -242,7 +248,7 @@ Mocking Factory Instances
242248=========================
243249
244250Similar to Services, you may find yourself needing to supply a pre-configured class instance
245- during testing that will be used with ``Factories ``. Use the same ``injectMock() `` and ``reset() ``
251+ during testing that will be used with ``Factories ``. Use the same ``Factories:: injectMock() `` and ``Factories:: reset() ``
246252static methods like **Services **, but they take an additional preceding parameter for the
247253component name:
248254
0 commit comments