From 6089254a3f341390fb11cc2bd85929bc3a1ad918 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Mon, 11 Aug 2025 21:08:15 +0800 Subject: [PATCH 1/4] replicate error in GitHub Actions --- .github/workflows/reusable-phpunit-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-phpunit-test.yml b/.github/workflows/reusable-phpunit-test.yml index cf23be58f2bc..a3794f747000 100644 --- a/.github/workflows/reusable-phpunit-test.yml +++ b/.github/workflows/reusable-phpunit-test.yml @@ -206,7 +206,7 @@ jobs: - name: Run tests run: script -e -c "vendor/bin/phpunit --color=always ${{ env.EXTRA_PHPUNIT_OPTIONS }}" env: - DB: ${{ inputs.db-platform }} + # DB: ${{ inputs.db-platform }} TACHYCARDIA_MONITOR_GA: ${{ inputs.enable-profiling && 'enabled' || '' }} TERM: xterm-256color From ad1f42c5b85a23d87c155ce8aae30ac56deac7a7 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Mon, 11 Aug 2025 21:21:19 +0800 Subject: [PATCH 2/4] add fix --- tests/_support/Config/Registrar.php | 6 +++--- tests/system/Commands/Database/MigrateStatusTest.php | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/_support/Config/Registrar.php b/tests/_support/Config/Registrar.php index b92c5e24bb16..43e44de30fc7 100644 --- a/tests/_support/Config/Registrar.php +++ b/tests/_support/Config/Registrar.php @@ -134,9 +134,9 @@ public static function Database(): array // Under GitHub Actions, we can set an ENV var named 'DB' // so that we can test against multiple databases. - if (($group = getenv('DB')) && isset(self::$dbConfig[$group])) { - $config['tests'] = self::$dbConfig[$group]; - } + $group = env('DB', 'SQLite3'); + + $config['tests'] = self::$dbConfig[$group] ?? []; return $config; } diff --git a/tests/system/Commands/Database/MigrateStatusTest.php b/tests/system/Commands/Database/MigrateStatusTest.php index b08557790de0..c9d9b20cc489 100644 --- a/tests/system/Commands/Database/MigrateStatusTest.php +++ b/tests/system/Commands/Database/MigrateStatusTest.php @@ -15,6 +15,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Test\CIUnitTestCase; +use CodeIgniter\Test\DatabaseTestTrait; use CodeIgniter\Test\StreamFilterTrait; use Config\Database; use PHPUnit\Framework\Attributes\Group; @@ -26,17 +27,18 @@ final class MigrateStatusTest extends CIUnitTestCase { use StreamFilterTrait; + use DatabaseTestTrait; private string $migrationFileFrom = SUPPORTPATH . 'MigrationTestMigrations/Database/Migrations/2018-01-24-102301_Some_migration.php'; private string $migrationFileTo = APPPATH . 'Database/Migrations/2018-01-24-102301_Some_migration.php'; protected function setUp(): void { - $forge = Database::forge(); - $forge->dropTable('foo', true); - parent::setUp(); + Database::connect()->table('migrations')->emptyTable(); + Database::forge()->dropTable('foo', true); + if (! is_file($this->migrationFileFrom)) { $this->fail(clean_path($this->migrationFileFrom) . ' is not found.'); } @@ -63,8 +65,7 @@ protected function tearDown(): void { parent::tearDown(); - $db = db_connect(); - $db->table('migrations')->emptyTable(); + Database::connect()->table('migrations')->emptyTable(); if (is_file($this->migrationFileTo)) { @unlink($this->migrationFileTo); From 87fd50d3e4c60a27980fba61101c6c83d0d0dde0 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Tue, 12 Aug 2025 00:38:16 +0800 Subject: [PATCH 3/4] rename tested db to `database` to coincide with other tests' db name --- tests/system/Commands/CreateDatabaseTest.php | 22 ++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/tests/system/Commands/CreateDatabaseTest.php b/tests/system/Commands/CreateDatabaseTest.php index af5b6d3b1682..a7e0fe11638f 100644 --- a/tests/system/Commands/CreateDatabaseTest.php +++ b/tests/system/Commands/CreateDatabaseTest.php @@ -14,7 +14,6 @@ namespace CodeIgniter\Commands; use CodeIgniter\Database\BaseConnection; -use CodeIgniter\Database\Database as DatabaseFactory; use CodeIgniter\Database\OCI8\Connection as OCI8Connection; use CodeIgniter\Database\SQLite3\Connection as SQLite3Connection; use CodeIgniter\Test\CIUnitTestCase; @@ -51,16 +50,13 @@ protected function tearDown(): void private function dropDatabase(): void { if ($this->connection instanceof SQLite3Connection) { - $file = WRITEPATH . 'foobar.db'; + $file = WRITEPATH . 'database.db'; + if (is_file($file)) { unlink($file); } - } else { - $util = (new DatabaseFactory())->loadUtils($this->connection); - - if ($util->databaseExists('foobar')) { - Database::forge()->dropDatabase('foobar'); - } + } elseif (Database::utils('tests')->databaseExists('database')) { + Database::forge()->dropDatabase('database'); } } @@ -75,7 +71,7 @@ public function testCreateDatabase(): void $this->markTestSkipped('Needs to run on non-OCI8 drivers.'); } - command('db:create foobar'); + command('db:create database'); $this->assertStringContainsString('successfully created.', $this->getBuffer()); } @@ -85,10 +81,10 @@ public function testSqliteDatabaseDuplicated(): void $this->markTestSkipped('Needs to run on SQLite3.'); } - command('db:create foobar'); + command('db:create database'); $this->resetStreamFilterBuffer(); - command('db:create foobar --ext db'); + command('db:create database --ext db'); $this->assertStringContainsString('already exists.', $this->getBuffer()); } @@ -98,10 +94,10 @@ public function testOtherDriverDuplicatedDatabase(): void $this->markTestSkipped('Needs to run on non-SQLite3 and non-OCI8 drivers.'); } - command('db:create foobar'); + command('db:create database'); $this->resetStreamFilterBuffer(); - command('db:create foobar'); + command('db:create database'); $this->assertStringContainsString('Unable to create the specified database.', $this->getBuffer()); } } From 2a0003ded1331d5c09e806e9e39c68832be025d8 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Tue, 12 Aug 2025 01:08:47 +0800 Subject: [PATCH 4/4] revert 1st commit --- .github/workflows/reusable-phpunit-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-phpunit-test.yml b/.github/workflows/reusable-phpunit-test.yml index a3794f747000..cf23be58f2bc 100644 --- a/.github/workflows/reusable-phpunit-test.yml +++ b/.github/workflows/reusable-phpunit-test.yml @@ -206,7 +206,7 @@ jobs: - name: Run tests run: script -e -c "vendor/bin/phpunit --color=always ${{ env.EXTRA_PHPUNIT_OPTIONS }}" env: - # DB: ${{ inputs.db-platform }} + DB: ${{ inputs.db-platform }} TACHYCARDIA_MONITOR_GA: ${{ inputs.enable-profiling && 'enabled' || '' }} TERM: xterm-256color