You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/testing/overview.rst
+17-10Lines changed: 17 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,24 +60,31 @@ Testing Your Application
60
60
PHPUnit Configuration
61
61
=====================
62
62
63
-
The framework has a ``phpunit.xml.dist`` file in the project root. This controls unit
64
-
testing of the framework itself. If you provide your own ``phpunit.xml``, it will
65
-
over-ride this.
63
+
In your CodeIgniter project root, there is the ``phpunit.xml.dist`` file. This
64
+
controls unit testing of your application. If you provide your own ``phpunit.xml``,
65
+
it will over-ride this.
66
66
67
-
Your ``phpunit.xml`` should exclude the ``system`` folder, as well as any ``vendor`` or
68
-
``ThirdParty`` folders, if you are unit testing your application.
67
+
By default, test files are placed under the **tests** directory in the project root.
69
68
70
69
The Test Class
71
70
==============
72
71
73
-
In order to take advantage of the additional tools provided, your tests must extend ``CIUnitTestCase``. All tests
74
-
are expected to be located in the **tests/app** directory by default.
72
+
In order to take advantage of the additional tools provided, your tests must extend
73
+
``CodeIgniter\Test\CIUnitTestCase``.
75
74
76
-
To test a new library, **Foo**, you would create a new file at **tests/app/Libraries/FooTest.php**:
75
+
There are no rules for how test files must be placed. However, we recommend that
76
+
you establish placement rules in advance so that you can quickly understand where
77
+
the test files are located.
78
+
79
+
In this document, we will place the test files corresponding to the classes in
80
+
the **app** directory in the **tests/app** directory. To test a new library,
81
+
**app/Libraries/Foo.php**, you would create a new file at
82
+
**tests/app/Libraries/FooTest.php**:
77
83
78
84
.. literalinclude:: overview/001.php
79
85
80
-
To test one of your models, you might end up with something like this in **tests/app/Models/OneOfMyModelsTest.php**:
86
+
To test one of your models, **app/Models/UserMode.php**, you might end up with
87
+
something like this in **tests/app/Models/UserModelTest.php**:
81
88
82
89
.. literalinclude:: overview/002.php
83
90
@@ -104,7 +111,7 @@ to help with staging and clean up::
104
111
The static methods ``setUpBeforeClass()`` and ``tearDownAfterClass()`` run before and after the entire test case, whereas the protected methods ``setUp()`` and ``tearDown()`` run
105
112
between each test.
106
113
107
-
If you implement any of these special functions make sure you run their
114
+
If you implement any of these special functions, make sure you run their
108
115
parent as well so extended test cases do not interfere with staging:
0 commit comments