Skip to content

Commit 6ae8858

Browse files
committed
Refactor tests to framework components
1 parent 7d78cf8 commit 6ae8858

22 files changed

+74
-110
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ vendor/
22
build/
33
phpunit*.xml
44
phpunit
5+
*.cache
56
composer.lock
67
.DS_Store

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626
}
2727
],
2828
"minimum-stability": "dev",
29+
"prefer-stable": true,
2930
"require": {
30-
"php" : "^7.0"
31+
"php" : ">=7.2"
3132
},
3233
"require-dev": {
33-
"phpunit/phpunit" : "^7.0",
34+
"phpunit/phpunit": "8.5.*",
3435
"mockery/mockery": "^1.0",
3536
"codeigniter4/codeigniter4": "dev-develop"
3637
},
@@ -41,7 +42,7 @@
4142
},
4243
"autoload-dev": {
4344
"psr-4": {
44-
"CIModuleTests\\Support\\": "tests/_support"
45+
"Tests\\Support\\": "tests/_support"
4546
}
4647
},
4748
"scripts": {

phpunit.xml.dist

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<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">
2+
<phpunit bootstrap="vendor/codeigniter4/codeigniter4/system/Test/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">
1212
<testsuites>
13-
<testsuite name="all">
13+
<testsuite name="app">
1414
<directory>./tests</directory>
1515
</testsuite>
1616
</testsuites>
@@ -26,7 +26,7 @@
2626
</exclude>
2727
</whitelist>
2828
</filter>
29-
29+
3030
<logging>
3131
<log type="coverage-html" target="build/logs/html"/>
3232
<log type="coverage-clover" target="build/logs/clover.xml"/>
@@ -38,8 +38,21 @@
3838
</logging>
3939

4040
<php>
41-
<env name="app.baseURL" value="http://example.com"/>
42-
<env name="CI_ENVIRONMENT" value="testing"/>
41+
<server name="app.baseURL" value="http://example.com"/>
42+
43+
<!-- Directory containing phpunit.xml -->
44+
<const name="HOMEPATH" value="./"/>
45+
46+
<!-- Directory containing the Paths config file -->
47+
<const name="CONFIGPATH" value="./vendor/codeigniter4/codeigniter4/app/Config/"/>
48+
49+
<!-- Directory containing the front controller (index.php) -->
50+
<const name="PUBLICPATH" value="./vendor/codeigniter4/codeigniter4/public/"/>
51+
52+
<!-- https://getcomposer.org/xdebug -->
53+
<env name="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
54+
55+
<!-- Database configuration -->
4356
<!-- <env name="database.tests.hostname" value="localhost"/> -->
4457
<!-- <env name="database.tests.database" value="tests"/> -->
4558
<!-- <env name="database.tests.username" value="tests_user"/> -->

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

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

33
use CodeIgniter\Database\Migration;
44

@@ -175,6 +175,7 @@ public function down()
175175
$this->forge->dropTable('machines_servicers');
176176

177177
$this->forge->dropTable('lawyers');
178+
$this->forge->dropTable('lawsuits');
178179

179180
$this->db->enableForeignKeyChecks();
180181
}

tests/_support/Database/Seeds/TestSeeder.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 Tests\Support\Database\Seeds;
22

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

tests/_support/DatabaseTestCase.php

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

33
use CodeIgniter\Config\Services;
44

@@ -16,21 +16,21 @@ class DatabaseTestCase extends \CodeIgniter\Test\CIDatabaseTestCase
1616
*
1717
* @var string
1818
*/
19-
protected $seed = 'CIModuleTests\Support\Database\Seeds\TestSeeder';
19+
protected $seed = 'Tests\Support\Database\Seeds\TestSeeder';
2020

2121
/**
2222
* The path to where we can find the test Seeds directory.
2323
*
2424
* @var string
2525
*/
26-
protected $basePath = MODULESUPPORTPATH . 'Database/';
26+
protected $basePath = SUPPORTPATH . 'Database/';
2727

2828
/**
2929
* The namespace to help us find the migration classes.
3030
*
3131
* @var string
3232
*/
33-
protected $namespace = 'CIModuleTests\Support';
33+
protected $namespace = 'Tests\Support';
3434

3535
/**
3636
* Preconfigured config instance.
@@ -56,10 +56,11 @@ public function setUp(): void
5656
{
5757
parent::setUp();
5858

59-
$config = new \Tatter\Schemas\Config\Schemas();
60-
$config->silent = false;
61-
$config->ignoredTables = ['migrations'];
62-
$config->schemasDirectory = MODULESUPPORTPATH . 'Schemas/Good';
59+
$config = new \Tatter\Schemas\Config\Schemas();
60+
$config->silent = false;
61+
$config->ignoredTables = ['migrations'];
62+
$config->ignoredNamespaces = [];
63+
$config->schemasDirectory = SUPPORTPATH . 'Schemas/Good';
6364
$config->automate = [
6465
'draft' => false,
6566
'archive' => false,

tests/_support/Models/FactoryModel.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 Tests\Support\Models;
22

33
use CodeIgniter\Model;
44

tests/_support/Models/MachineModel.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 Tests\Support\Models;
22

33
use CodeIgniter\Model;
44

tests/_support/Models/ServicerModel.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 Tests\Support\Models;
22

33
use CodeIgniter\Model;
44

tests/_support/Models/WorkerModel.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 Tests\Support\Models;
22

33
use CodeIgniter\Model;
44

0 commit comments

Comments
 (0)