Skip to content
This repository was archived by the owner on May 18, 2024. It is now read-only.

Commit fa5f18d

Browse files
committed
Add .gitignore; Update docs
1 parent 7a52ba0 commit fa5f18d

File tree

3 files changed

+128
-13
lines changed

3 files changed

+128
-13
lines changed

README.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,33 @@ framework without being integrated into a specific project.
1010
For 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.
1718
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
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-
2730
See 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

3142
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
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
6071
steps in `setUp()`.
6172

src/.gitignore

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#-------------------------
2+
# Operating Specific Junk Files
3+
#-------------------------
4+
5+
# OS X
6+
.DS_Store
7+
.AppleDouble
8+
.LSOverride
9+
10+
# OS X Thumbnails
11+
._*
12+
13+
# Windows image file caches
14+
Thumbs.db
15+
ehthumbs.db
16+
Desktop.ini
17+
18+
# Recycle Bin used on file shares
19+
$RECYCLE.BIN/
20+
21+
# Windows Installer files
22+
*.cab
23+
*.msi
24+
*.msm
25+
*.msp
26+
27+
# Windows shortcuts
28+
*.lnk
29+
30+
# Linux
31+
*~
32+
33+
# KDE directory preferences
34+
.directory
35+
36+
# Linux trash folder which might appear on any partition or disk
37+
.Trash-*
38+
39+
#-------------------------
40+
# Environment Files
41+
#-------------------------
42+
# These should never be under version control,
43+
# as it poses a security risk.
44+
.env
45+
.vagrant
46+
Vagrantfile
47+
48+
#-------------------------
49+
# Temporary Files
50+
#-------------------------
51+
php_errors.log
52+
53+
#-------------------------
54+
# Test Files
55+
#-------------------------
56+
build/*
57+
58+
# Don't save phpunit under version control.
59+
phpunit
60+
61+
#-------------------------
62+
# Composer
63+
#-------------------------
64+
vendor/
65+
composer.lock
66+
67+
#-------------------------
68+
# IDE / Development Files
69+
#-------------------------
70+
71+
# Modules Testing
72+
_modules/*
73+
74+
# phpenv local config
75+
.php-version
76+
77+
# Jetbrains editors (PHPStorm, etc)
78+
.idea/
79+
*.iml
80+
81+
# Netbeans
82+
nbproject/
83+
build/
84+
nbbuild/
85+
dist/
86+
nbdist/
87+
nbactions.xml
88+
nb-configuration.xml
89+
.nb-gradle/
90+
91+
# Sublime Text
92+
*.tmlanguage.cache
93+
*.tmPreferences.cache
94+
*.stTheme.cache
95+
*.sublime-workspace
96+
*.sublime-project
97+
.phpintel
98+
/api/
99+
100+
# Visual Studio Code
101+
.vscode/
102+
103+
/results/
104+
/phpunit*.xml

src/tests/session/ExampleSessionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function testSessionSimple()
1111
{
1212
$this->session->set('logged_in', 123);
1313

14-
$value = $this->session->get('logged_in')
14+
$value = $this->session->get('logged_in');
1515

1616
$this->assertEquals(123, $value);
1717
}

0 commit comments

Comments
 (0)