Skip to content

Commit

Permalink
Merge pull request #8508 from kenjis/docs-update-starter/tests/README.md
Browse files Browse the repository at this point in the history
docs: update starter/tests/README.md
  • Loading branch information
kenjis authored Feb 3, 2024
2 parents 9a11804 + 826f163 commit b743fff
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions admin/starter/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use to test your application. Those details can be found in the documentation.
## Requirements

It is recommended to use the latest version of PHPUnit. At the time of this
writing we are running version 9.x. Support for this has been built into the
writing, we are running version 9.x. Support for this has been built into the
**composer.json** file that ships with CodeIgniter and can easily be installed
via [Composer](https://getcomposer.org/) if you don't already have it installed globally.

Expand All @@ -35,7 +35,7 @@ for code coverage to be calculated successfully. After installing `XDebug`, you

A number of the tests use a running database.
In order to set up the database edit the details for the `tests` group in
**app/Config/Database.php** or **phpunit.xml**.
**app/Config/Database.php** or **.env**.
Make sure that you provide a database engine that is currently running on your machine.
More details on a test database setup are in the
[Testing Your Database](https://codeigniter4.github.io/userguide/testing/database.html) section of the documentation.
Expand Down Expand Up @@ -92,12 +92,11 @@ HTML code coverage reports.
## Test Cases

Every test needs a *test case*, or class that your tests extend. CodeIgniter 4
provides a few that you may use directly:
* `CodeIgniter\Test\CIUnitTestCase` - for basic tests with no other service needs
* `CodeIgniter\Test\DatabaseTestTrait` - for tests that need database access
provides one class that you may use directly:
* `CodeIgniter\Test\CIUnitTestCase`

Most of the time you will want to write your own test cases to hold functions and services
common to your test suites.
Most of the time you will want to write your own test cases that extend `CIUnitTestCase`
to hold functions and services common to your test suites.

## Creating Tests

Expand All @@ -112,11 +111,8 @@ Review the links above and always pay attention to your code coverage.

### Database Tests

Tests can include migrating, seeding, and testing against a mock or live<sup>1</sup> database.
Tests can include migrating, seeding, and testing against a mock or live database.
Be sure to modify the test case (or create your own) to point to your seed and migrations
and include any additional steps to be run before tests in the `setUp()` method.

<sup>1</sup> Note: If you are using database tests that require a live database connection
you will need to rename **phpunit.xml.dist** to **phpunit.xml**, uncomment the database
configuration lines and add your connection details. Prevent **phpunit.xml** from being
tracked in your repo by adding it to **.gitignore**.
See [Testing Your Database](https://codeigniter4.github.io/userguide/testing/database.html)
for details.

0 comments on commit b743fff

Please sign in to comment.