diff --git a/README.md b/README.md index 58725ec..92e24d1 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# ci4-module-tests +# ModuleTests PHPUnit testing scaffold for CodeIgniter 4 modules ## Overview 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. +**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](https://codeigniter4.github.io/userguide/testing/index.html). @@ -29,7 +29,7 @@ project root. Add the following lines to **composer.json**: }, "autoload-dev": { "psr-4": { - "CIModuleTests\\Support\\": "tests/_support" + "ModuleTests\\Support\\": "tests/_support" } }, "scripts": { diff --git a/docs/CREATING.md b/docs/CREATING.md index d1b5b3b..4262cc4 100644 --- a/docs/CREATING.md +++ b/docs/CREATING.md @@ -12,16 +12,16 @@ provides a few that you may use directly: * `CodeIgniter\Test\CIUnitTestCase` - for basic tests with no other service needs * `CodeIgniter\Test\CIDatabaseTestCase` - for tests that need database access -**ci-module-tests** also provides some examples: -* `CIModuleTests\Support\DatabaseTestCase` - for database tests, pre-configured for migrations, seeds, and models from **tests/_support** -* `CIModuleTests\Support\SessionTestCase` - for session tests, pre-configured with a mock session driver +**ModuleTests** also provides some examples: +* `ModuleTests\Support\DatabaseTestCase` - for database tests, pre-configured for migrations, seeds, and models from **tests/_support** +* `ModuleTests\Support\SessionTestCase` - for session tests, pre-configured with a mock session driver Most of the time you will want to write your own test cases to hold functions and services common to your test suites. ## Tests -All tests go in the **tests/** directory. **ci-module-tests** provides two generic +All tests go in the **tests/** directory. **ModuleTests** provides two generic subfolders for you, **unit** and **database** - but feel free to make your own. Each test file is a class that extends a **Test Case** (see above) and contains methods for the individual tests. These method names must start with the word "test" and should have descriptive names @@ -33,7 +33,7 @@ the links above and always pay attention to your [Code Coverage](docs/COVERAGE.m ### Database Tests -**ci-module-tests** provides examples for migrating, seeding, and testing against a mock +**ModuleTests** provides examples for migrating, seeding, and testing against a mock or live1 database. The example files can be modified or replaced with your own: * **tests/_support/Database/Migrations/create_test_tables.php** * **tests/_support/Database/Seeds/ExampleSeeder.php** @@ -50,7 +50,7 @@ repo by adding it to **.gitignore**. ### Session Tests -Similar to database testing, **ci-module-tests** provides a test case pre-configured +Similar to database testing, **ModuleTests** provides a test case pre-configured with the [mock session class](https://codeigniter4.github.io/userguide/testing/overview.html#mocking-services) to make testing sessions easier: * **tests/_support/SessionTestCase.php** diff --git a/examples/composer.json b/examples/composer.json index 8174a58..beb2153 100644 --- a/examples/composer.json +++ b/examples/composer.json @@ -29,7 +29,6 @@ "require-dev": { "phpunit/phpunit" : "^7.0", "mockery/mockery": "^1.0", - "mgatner/ci-module-tests": "^1.0", "codeigniter4/codeigniter4": "dev-develop" }, "autoload": { @@ -39,7 +38,7 @@ }, "autoload-dev": { "psr-4": { - "CIModuleTests\\Support\\": "tests/_support" + "ModuleTests\\Support\\": "tests/_support" } }, "scripts": { diff --git a/src/phpunit.xml.dist b/src/phpunit.xml.dist index 0fbfdcb..3b2cf45 100644 --- a/src/phpunit.xml.dist +++ b/src/phpunit.xml.dist @@ -1,31 +1,31 @@ - - - ./tests - - + backupGlobals="false" + colors="true" + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + stopOnError="false" + stopOnFailure="false" + stopOnIncomplete="false" + stopOnSkipped="false"> + + + ./tests + + - - - ./src - - ./src/Views - ./src/Config/Routes.php - - - - - + + + ./src + + ./src/Views + ./src/Config/Routes.php + + + + + @@ -33,18 +33,18 @@ - + - + - + - - - + + + - + diff --git a/src/tests/_support/Database/Migrations/2019-09-02-092335_create_test_tables.php b/src/tests/_support/Database/Migrations/2019-09-02-092335_create_test_tables.php index 9cf2043..e63da6f 100644 --- a/src/tests/_support/Database/Migrations/2019-09-02-092335_create_test_tables.php +++ b/src/tests/_support/Database/Migrations/2019-09-02-092335_create_test_tables.php @@ -1,4 +1,4 @@ -findAll(); diff --git a/src/tests/session/ExampleSessionTest.php b/src/tests/session/ExampleSessionTest.php index a4dac12..738b8b0 100644 --- a/src/tests/session/ExampleSessionTest.php +++ b/src/tests/session/ExampleSessionTest.php @@ -1,6 +1,6 @@