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

Commit 998b42e

Browse files
authored
Merge pull request #2 from MGatner/total-rename
Rename to ModuleTests
2 parents 99044db + 028b549 commit 998b42e

11 files changed

+52
-52
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# ci4-module-tests
1+
# ModuleTests
22

33
PHPUnit testing scaffold for CodeIgniter 4 modules
44

55
## Overview
66

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

1010
To read more on Unit Testing in CodeIgniter 4 visit the
1111
[User Guide](https://codeigniter4.github.io/userguide/testing/index.html).
@@ -29,7 +29,7 @@ project root. Add the following lines to **composer.json**:
2929
},
3030
"autoload-dev": {
3131
"psr-4": {
32-
"CIModuleTests\\Support\\": "tests/_support"
32+
"ModuleTests\\Support\\": "tests/_support"
3333
}
3434
},
3535
"scripts": {

docs/CREATING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ provides a few that you may use directly:
1212
* `CodeIgniter\Test\CIUnitTestCase` - for basic tests with no other service needs
1313
* `CodeIgniter\Test\CIDatabaseTestCase` - for tests that need database access
1414

15-
**ci4-module-tests** also provides some examples:
16-
* `CIModuleTests\Support\DatabaseTestCase` - for database tests, pre-configured for migrations, seeds, and models from **tests/_support**
17-
* `CIModuleTests\Support\SessionTestCase` - for session tests, pre-configured with a mock session driver
15+
**ModuleTests** also provides some examples:
16+
* `ModuleTests\Support\DatabaseTestCase` - for database tests, pre-configured for migrations, seeds, and models from **tests/_support**
17+
* `ModuleTests\Support\SessionTestCase` - for session tests, pre-configured with a mock session driver
1818

1919
Most of the time you will want to write your own test cases to hold functions and services
2020
common to your test suites.
2121

2222
## Tests
2323

24-
All tests go in the **tests/** directory. **ci4-module-tests** provides two generic
24+
All tests go in the **tests/** directory. **ModuleTests** provides two generic
2525
subfolders for you, **unit** and **database** - but feel free to make your own. Each test file
2626
is a class that extends a **Test Case** (see above) and contains methods for the individual
2727
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
3333

3434
### Database Tests
3535

36-
**ci-module-tests** provides examples for migrating, seeding, and testing against a mock
36+
**ModuleTests** provides examples for migrating, seeding, and testing against a mock
3737
or live<sup>1</sup> database. The example files can be modified or replaced with your own:
3838
* **tests/_support/Database/Migrations/create_test_tables.php**
3939
* **tests/_support/Database/Seeds/ExampleSeeder.php**
@@ -50,7 +50,7 @@ repo by adding it to **.gitignore**.
5050

5151
### Session Tests
5252

53-
Similar to database testing, **ci4-module-tests** provides a test case pre-configured
53+
Similar to database testing, **ModuleTests** provides a test case pre-configured
5454
with the [mock session class](https://codeigniter4.github.io/userguide/testing/overview.html#mocking-services)
5555
to make testing sessions easier:
5656
* **tests/_support/SessionTestCase.php**

examples/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"autoload-dev": {
4040
"psr-4": {
41-
"CIModuleTests\\Support\\": "tests/_support"
41+
"ModuleTests\\Support\\": "tests/_support"
4242
}
4343
},
4444
"scripts": {

src/phpunit.xml.dist

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit bootstrap="tests/_support/bootstrap.php"
3-
backupGlobals="false"
4-
colors="true"
5-
convertErrorsToExceptions="true"
6-
convertNoticesToExceptions="true"
7-
convertWarningsToExceptions="true"
8-
stopOnError="false"
9-
stopOnFailure="false"
10-
stopOnIncomplete="false"
11-
stopOnSkipped="false">
12-
<testsuites>
13-
<testsuite name="all">
14-
<directory>./tests</directory>
15-
</testsuite>
16-
</testsuites>
3+
backupGlobals="false"
4+
colors="true"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
stopOnError="false"
9+
stopOnFailure="false"
10+
stopOnIncomplete="false"
11+
stopOnSkipped="false">
12+
<testsuites>
13+
<testsuite name="all">
14+
<directory>./tests</directory>
15+
</testsuite>
16+
</testsuites>
1717

18-
<filter>
19-
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="true">
20-
<directory suffix=".php">./src</directory>
21-
<exclude>
22-
<directory suffix=".php">./src/Views</directory>
23-
<file>./src/Config/Routes.php</file>
24-
</exclude>
25-
</whitelist>
26-
</filter>
27-
28-
<logging>
18+
<filter>
19+
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="true">
20+
<directory suffix=".php">./src</directory>
21+
<exclude>
22+
<directory suffix=".php">./src/Views</directory>
23+
<file>./src/Config/Routes.php</file>
24+
</exclude>
25+
</whitelist>
26+
</filter>
27+
28+
<logging>
2929
<log type="coverage-html" target="build/logs/html"/>
3030
<log type="coverage-clover" target="build/logs/clover.xml"/>
3131
<log type="coverage-php" target="build/logs/coverage.serialized"/>
3232
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false"/>
3333
<log type="testdox-html" target="build/logs/testdox.html"/>
3434
<log type="testdox-text" target="build/logs/testdox.txt"/>
3535
<log type="junit" target="build/logs/logfile.xml"/>
36-
</logging>
36+
</logging>
3737

38-
<php>
38+
<php>
3939
<env name="app.baseURL" value="http://example.com"/>
4040
<env name="CI_ENVIRONMENT" value="testing"/>
4141
<!-- <env name="database.tests.hostname" value="localhost"/> -->
42-
<!-- <env name="database.tests.database" value="tests"/> -->
42+
<!-- <env name="database.tests.database" value="tests"/> -->
4343
<!-- <env name="database.tests.username" value="tests_user"/> -->
44-
<!-- <env name="database.tests.password" value=""/> -->
45-
<!-- <env name="database.tests.DBDriver" value="MySQLi"/> -->
46-
<!-- <env name="database.tests.DBPrefix" value="tests_"/> -->
44+
<!-- <env name="database.tests.password" value=""/> -->
45+
<!-- <env name="database.tests.DBDriver" value="MySQLi"/> -->
46+
<!-- <env name="database.tests.DBPrefix" value="tests_"/> -->
4747
<env name="database.tests.database" value=":memory:"/>
4848
<env name="database.tests.DBDriver" value="SQLite3"/>
49-
</php>
49+
</php>
5050
</phpunit>

src/tests/_support/Database/Migrations/2019-09-02-092335_create_test_tables.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace CIModuleTests\Support\Database\Migrations;
1+
<?php namespace ModuleTests\Support\Database\Migrations;
22

33
use CodeIgniter\Database\Migration;
44

src/tests/_support/Database/Seeds/ExampleSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace CIModuleTests\Support\Database\Seeds;
1+
<?php namespace ModuleTests\Support\Database\Seeds;
22

33
class ExampleSeeder extends \CodeIgniter\Database\Seeder
44
{

src/tests/_support/DatabaseTestCase.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace CIModuleTests\Support;
1+
<?php namespace ModuleTests\Support;
22

33
class DatabaseTestCase extends \CodeIgniter\Test\CIDatabaseTestCase
44
{
@@ -14,7 +14,7 @@ class DatabaseTestCase extends \CodeIgniter\Test\CIDatabaseTestCase
1414
*
1515
* @var string
1616
*/
17-
protected $seed = 'CIModuleTests\Support\Database\Seeds\ExampleSeeder';
17+
protected $seed = 'ModuleTests\Support\Database\Seeds\ExampleSeeder';
1818

1919
/**
2020
* The path to where we can find the test Seeds directory.
@@ -28,7 +28,7 @@ class DatabaseTestCase extends \CodeIgniter\Test\CIDatabaseTestCase
2828
*
2929
* @var string
3030
*/
31-
protected $namespace = 'CIModuleTests\Support';
31+
protected $namespace = 'ModuleTests\Support';
3232

3333
public function setUp(): void
3434
{

src/tests/_support/Models/ExampleModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace CIModuleTests\Support\Models;
1+
<?php namespace ModuleTests\Support\Models;
22

33
use CodeIgniter\Model;
44

src/tests/_support/SessionTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace CIModuleTests\Support;
1+
<?php namespace ModuleTests\Support;
22

33
use CodeIgniter\Session\Handlers\ArrayHandler;
44
use Tests\Support\Session\MockSession;

src/tests/database/ExampleDatabaseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
class ExampleDatabaseTest extends CIModuleTests\Support\DatabaseTestCase
3+
class ExampleDatabaseTest extends ModuleTests\Support\DatabaseTestCase
44
{
55
public function setUp(): void
66
{
@@ -9,7 +9,7 @@ public function setUp(): void
99

1010
public function testDatabaseSimple()
1111
{
12-
$model = new \CIModuleTests\Support\Models\ExampleModel();
12+
$model = new \ModuleTests\Support\Models\ExampleModel();
1313

1414
$objects = $model->findAll();
1515

src/tests/session/ExampleSessionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
class ExampleSessionTest extends CIModuleTests\Support\SessionTestCase
3+
class ExampleSessionTest extends ModuleTests\Support\SessionTestCase
44
{
55
public function setUp(): void
66
{

0 commit comments

Comments
 (0)