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
*[Any tutorials on Unit testing in CI4?](https://forum.codeigniter.com/showthread.php?tid=81830)
11
13
12
14
## Requirements
13
15
14
16
It is recommended to use the latest version of PHPUnit. At the time of this
15
-
writing we are running version 8.5.13. Support for this has been built into the
17
+
writing we are running version 9.x. Support for this has been built into the
16
18
**composer.json** file that ships with CodeIgniter and can easily be installed
17
19
via [Composer](https://getcomposer.org/) if you don't already have it installed globally.
18
20
19
21
```console
20
22
> composer install
21
23
```
22
24
23
-
If running under OS X or Linux, you can create a symbolic link to make running tests a touch nicer.
25
+
If running under macOS or Linux, you can create a symbolic link to make running tests a touch nicer.
24
26
25
27
```console
26
28
> ln -s ./vendor/bin/phpunit ./phpunit
27
29
```
28
30
29
-
You also need to install [XDebug](https://xdebug.org/index.php) in order
30
-
for code coverage to be calculated successfully.
31
+
You also need to install [XDebug](https://xdebug.org/docs/install) in order
32
+
for code coverage to be calculated successfully. After installing `XDebug`, you must add `xdebug.mode=coverage` in the **php.ini** file to enable code coverage.
31
33
32
34
## Setting Up
33
35
34
36
A number of the tests use a running database.
35
37
In order to set up the database edit the details for the `tests` group in
36
-
**phpunit.xml**. Make sure that you provide a database engine that is currently running
37
-
on your machine. More details on a test database setup are in the
38
-
*Docs>>Testing>>Testing Your Database* section of the documentation.
38
+
**phpunit.xml**.
39
+
Make sure that you provide a database engine that is currently running on your machine.
40
+
More details on a test database setup are in the
41
+
[Testing Your Database](https://codeigniter4.github.io/userguide/testing/database.html) section of the documentation.
39
42
40
43
## Running the tests
41
44
@@ -45,6 +48,12 @@ The entire test suite can be run by simply typing one command-line command from
45
48
> ./phpunit
46
49
```
47
50
51
+
If you are using Windows, use the following command.
52
+
53
+
```console
54
+
> vendor\bin\phpunit
55
+
```
56
+
48
57
You can limit tests to those within a single test directory by specifying the
49
58
directory name after phpunit.
50
59
@@ -57,7 +66,6 @@ directory name after phpunit.
57
66
To generate coverage information, including HTML reports you can view in your browser,
*[Any tutorials on Unit testing in CI4?](https://forum.codeigniter.com/showthread.php?tid=81830)
12
13
13
14
## Requirements
14
15
@@ -21,28 +22,24 @@ via [Composer](https://getcomposer.org/) if you don't already have it installed
21
22
> composer install
22
23
```
23
24
24
-
If running under OS X or Linux, you can create a symbolic link to make running tests a touch nicer.
25
+
If running under macOS or Linux, you can create a symbolic link to make running tests a touch nicer.
25
26
26
27
```console
27
28
> ln -s ./vendor/bin/phpunit ./phpunit
28
29
```
29
30
30
-
You also need to install [XDebug](https://xdebug.org/index.php) in order
31
-
for code coverage to be calculated successfully.
31
+
You also need to install [XDebug](https://xdebug.org/docs/install) in order
32
+
for code coverage to be calculated successfully. After installing `XDebug`, you must add `xdebug.mode=coverage` in the **php.ini** file to enable code coverage.
32
33
33
34
## Setting Up
34
35
35
36
A number of the tests use a running database.
36
37
In order to set up the database edit the details for the `tests` group in
37
-
**app/Config/Database.php** or **phpunit.xml**. Make sure that you provide a database engine
38
-
that is currently running on your machine. More details on a test database setup are in the
38
+
**app/Config/Database.php** or **phpunit.xml**.
39
+
Make sure that you provide a database engine that is currently running on your machine.
40
+
More details on a test database setup are in the
39
41
[Testing Your Database](https://codeigniter4.github.io/userguide/testing/database.html) section of the documentation.
40
42
41
-
If you want to run the tests without using live database you can
42
-
exclude @DatabaseLive group. Or make a copy of **phpunit.dist.xml** -
43
-
call it **phpunit.xml** - and comment out the <testsuite> named "database". This will make
44
-
the tests run quite a bit faster.
45
-
46
43
## Running the tests
47
44
48
45
The entire test suite can be run by simply typing one command-line command from the main directory.
0 commit comments