@@ -10,22 +10,33 @@ framework without being integrated into a specific project.
1010For more on Testing in CodeIgniter 4 visit the
1111[ User Guide] ( https://codeigniter4.github.io/CodeIgniter4/testing/ ) .
1212
13- ## Install
13+ ## Installation
1414
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.
17182 . 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
1923
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 ** :
2327* ` repositories ` needs an entry for ` https://github.com/codeigniter4/CodeIgniter4 `
2428* ` require-dev ` needs the CodeIgniter 4 repo, PHPUnit, and Mockery
2529* ` autoload-dev ` must supply the PSR4 namespace for the test supports
26-
2730See the provided [ composer.json] ( src/composer.json ) for examples.
2831
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+
2940## Customizing
3041
3142The ** _ 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
5263
5364### Database Tests
5465
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
5970** tests/_ support/DatabaseTestCase.php** to point to your seed and include any additional
6071steps in ` setUp() ` .
6172
0 commit comments