@@ -10,22 +10,33 @@ framework without being integrated into a specific project.
10
10
For more on Testing in CodeIgniter 4 visit the
11
11
[ User Guide] ( https://codeigniter4.github.io/CodeIgniter4/testing/ ) .
12
12
13
- ## Install
13
+ ## Installation
14
14
15
- 1 . Clone this repo and merge the ** tests** folder and ** phpunit.xml.dist** and
16
- ** composer.json** <sup >1</sup > files from ** src/** into the root of your module.
15
+ ### New Projects
16
+
17
+ 1 . Clone this repo and merge the all files from ** src/** into the root of your module.
17
18
2 . From your package root run ` composer install ` to install all the required support packages.
18
- 3 . Run ` composer test ` to initiate the tests.
19
+ 3 . Start your module code in ** src/** and add your namespace to ** composer.json** 's ` autoload `
20
+ 4 . Run ` composer test ` to initiate the tests.
21
+
22
+ ### Existing Projects
19
23
20
- < sup >1</ sup > Note: Unless you are starting fresh you likely will already have your own version of
21
- ** composer.json ** , in which case you will need to be sure to merge the following settings
22
- for ** CIModuleTests** :
24
+ Unless you are starting fresh you likely will already have your own versions of some of the
25
+ package files in ** src/ ** . In this case you will need to be sure to merge some necessary
26
+ settings for ** CIModuleTests** . In ** composer.json ** :
23
27
* ` repositories ` needs an entry for ` https://github.com/codeigniter4/CodeIgniter4 `
24
28
* ` require-dev ` needs the CodeIgniter 4 repo, PHPUnit, and Mockery
25
29
* ` autoload-dev ` must supply the PSR4 namespace for the test supports
26
-
27
30
See the provided [ composer.json] ( src/composer.json ) for examples.
28
31
32
+ Also review ** src/.gitignore** for helpful additions so you don't track test results.
33
+
34
+ ### phpunit.xml
35
+
36
+ ** src/** includes a ready-to-use PHPUnit template in ** phpunit.xml.dist** . You can keep this
37
+ as is but if you plan to add environment info (like database connections) be sure to rename
38
+ it to ** phpunit.xml** and prevent it from being tracked via ** .gitignore** .
39
+
29
40
## Customizing
30
41
31
42
The ** _ support** directory comes loaded with easy-to-use examples of test cases and their
@@ -52,10 +63,10 @@ Tests are individual methods within each file. Method names must start with the
52
63
53
64
### Database Tests
54
65
55
- If you are using database tests that require a live database connect you will need to edit
56
- ** phpunit.xml.dist** , uncomment the database configuration lines and add your connection
57
- details. Example directories and files are provided for test Seeds and Models, which you
58
- can modify or replace with your own. Also be sure to modify
66
+ If you are using database tests that require a live database connect you will need to
67
+ rename ** phpunit.xml.dist** to ** phpunit.xml ** , uncomment the database configuration lines
68
+ and add your connection details. Example directories and files are provided for test Seeds
69
+ and Models, which you can modify or replace with your own. Also be sure to modify
59
70
** tests/_ support/DatabaseTestCase.php** to point to your seed and include any additional
60
71
steps in ` setUp() ` .
61
72
0 commit comments