Skip to content
PHPUnit testing scaffold for CodeIgniter 4 modules
Branch: develop
Clone or download
MGatner Merge pull request #1 from MGatner/legacy-package
Remove legacy package reference
Latest commit 99044db Sep 6, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Fix name typos Sep 5, 2019
examples Remove legacy package reference Sep 6, 2019
src Docs overhaul Sep 5, 2019
LICENSE Initial commit Sep 3, 2019 Docs overhaul Sep 5, 2019


PHPUnit testing scaffold for CodeIgniter 4 modules


Not a module itself but a testing scaffold for CodeIgniter 4 modules, ci4-module-tests makes it easy to setup PHPUnit tests in your modules.

To read more on Unit Testing in CodeIgniter 4 visit the User Guide.


Clone or download this repo and place src/tests and src/phpunit.xml.dist in your project root. Add the following lines to composer.json:

	"repositories": [
			"type": "vcs",
			"url": ""
	"minimum-stability": "dev",
	"require-dev": {
		"phpunit/phpunit" : "^7.0",
		"mockery/mockery": "^1.0",
		"codeigniter4/codeigniter4": "dev-develop"
	"autoload-dev": {
		"psr-4": {
			"CIModuleTests\\Support\\": "tests/_support"
	"scripts": {
		"test": "phpunit",
		"post-update-cmd": [
			"composer dump-autoload"

If you are using version tracking you should exclude test results by adding this to .gitignore:


Examples of composer.json and .gitignore are located in the examples/ folder if you need a starting point.


As this repo is updated with bugfixes and improvements you will want to update your modules that use it. Because files need to be copied in place manually you will have to handle updates manually by cloning or downloading this repo and merging changed files into your project. "Watch" this repo to be notified of new releases and changes.

Creating Tests

See the docs on Creating Tests.

Running Tests

From your package root run composer install (or composer upgrade) to install all the required support packages, then run composer test to initiate the tests. Test results and code coverage will be written to standard output and formatted log versions will go in build/logs/.

Code Coverage

See the docs on Code Coverage.

You can’t perform that action at this time.