From 19ee1ed078d4415065d067a991dd05a8f81689b2 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 5 Jul 2025 21:38:30 -0400 Subject: [PATCH 01/22] feat: add `MySQL` CI workflow and corresponding test classes for improved database testing. --- .github/workflows/build.yml | 2 ++ .github/workflows/ci-mysql.yml | 29 +++++++++++++++++++++ tests/mysql/CacheManagementTest.php | 14 ++++++++++ tests/mysql/ExceptionHandlingTest.php | 14 ++++++++++ tests/mysql/ExtensibilityTest.php | 14 ++++++++++ tests/mysql/NodeAppendTest.php | 14 ++++++++++ tests/mysql/NodeDeleteTest.php | 14 ++++++++++ tests/mysql/NodeInsertTest.php | 14 ++++++++++ tests/mysql/NodePrependTest.php | 14 ++++++++++ tests/mysql/NodeStateTest.php | 14 ++++++++++ tests/mysql/QueryBehaviorTest.php | 14 ++++++++++ tests/mysql/TreeTraversalTest.php | 14 ++++++++++ tests/mysql/ValidationAndStructureTest.php | 14 ++++++++++ tests/sqlite/CacheManagementTest.php | 2 +- tests/sqlite/ExceptionHandlingTest.php | 2 +- tests/sqlite/ExtensibilityTest.php | 2 +- tests/sqlite/NodeAppendTest.php | 2 +- tests/sqlite/NodeDeleteTest.php | 2 +- tests/sqlite/NodeInsertTest.php | 2 +- tests/sqlite/NodePrependTest.php | 2 +- tests/sqlite/NodeStateTest.php | 2 +- tests/sqlite/QueryBehaviorTest.php | 2 +- tests/sqlite/TreeTraversalTest.php | 2 +- tests/sqlite/ValidationAndStructureTest.php | 2 +- 24 files changed, 196 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/ci-mysql.yml create mode 100644 tests/mysql/CacheManagementTest.php create mode 100644 tests/mysql/ExceptionHandlingTest.php create mode 100644 tests/mysql/ExtensibilityTest.php create mode 100644 tests/mysql/NodeAppendTest.php create mode 100644 tests/mysql/NodeDeleteTest.php create mode 100644 tests/mysql/NodeInsertTest.php create mode 100644 tests/mysql/NodePrependTest.php create mode 100644 tests/mysql/NodeStateTest.php create mode 100644 tests/mysql/QueryBehaviorTest.php create mode 100644 tests/mysql/TreeTraversalTest.php create mode 100644 tests/mysql/ValidationAndStructureTest.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 089297a..d491a54 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,6 +26,7 @@ jobs: composer-command: | composer require yiisoft/yii2:22.0.x-dev --prefer-dist --no-progress --no-interaction --no-scripts --ansi concurrency-group: phpunit-${{ github.workflow }}-${{ github.ref }} + exclude-group-phpunit: mysql extensions: pdo, pdo_sqlite phpunit-compatibility: uses: php-forge/actions/.github/workflows/phpunit.yml@main @@ -33,4 +34,5 @@ jobs: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: concurrency-group: compatibility-${{ github.workflow }}-${{ github.ref }} + exclude-group-phpunit: mysql extensions: pdo, pdo_sqlite diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml new file mode 100644 index 0000000..d99e1ce --- /dev/null +++ b/.github/workflows/ci-mysql.yml @@ -0,0 +1,29 @@ +on: + - pull_request + - push + +name: ci-mysql + +jobs: + mysql: + name: MySQL database tests. + uses: ./.github/workflows/phpunit-database.yml + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + concurrency-group: mysql-${{ github.ref }} + database-env: | + { + "MYSQL_DATABASE": "yiitest", + "MYSQL_ROOT_PASSWORD": "root", + } + database-health-cmd: "mysqladmin ping" + database-health-retries: 3 + database-image: mysql + database-port: 3306 + database-type: mysql + database-versions: '["8.0", "8.4", "latest"]' + enable-concurrency: true + group-phpunit: mysql + extensions: pdo, pdo_mysql + os: '["ubuntu-latest"]' diff --git a/tests/mysql/CacheManagementTest.php b/tests/mysql/CacheManagementTest.php new file mode 100644 index 0000000..f39a0fe --- /dev/null +++ b/tests/mysql/CacheManagementTest.php @@ -0,0 +1,14 @@ + Date: Sat, 5 Jul 2025 21:42:35 -0400 Subject: [PATCH 02/22] fix: update action reference in `MySQL` CI workflow for correct path, --- .github/workflows/ci-mysql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index d99e1ce..36c671a 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -7,7 +7,7 @@ name: ci-mysql jobs: mysql: name: MySQL database tests. - uses: ./.github/workflows/phpunit-database.yml + uses: php-forge/actions/.github/workflows/phpunit-database.yml secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: From 26ba36234bfafd01a0c9bb88b40ae8c545695cef Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 5 Jul 2025 21:44:31 -0400 Subject: [PATCH 03/22] fix: specify version for phpunit-database workflow in `MySQL` CI configuration. --- .github/workflows/ci-mysql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index 36c671a..f6a9647 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -7,7 +7,7 @@ name: ci-mysql jobs: mysql: name: MySQL database tests. - uses: php-forge/actions/.github/workflows/phpunit-database.yml + uses: php-forge/actions/.github/workflows/phpunit-database.yml@main secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: From f66dfa277a487652658a3b11d5a1ea935fd6fccc Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 5 Jul 2025 21:56:13 -0400 Subject: [PATCH 04/22] fix: update database connection settings in `MySQL` test classes. --- tests/TestCase.php | 4 ++++ tests/mysql/CacheManagementTest.php | 4 +++- tests/mysql/ExceptionHandlingTest.php | 4 +++- tests/mysql/ExtensibilityTest.php | 4 +++- tests/mysql/NodeAppendTest.php | 4 +++- tests/mysql/NodeDeleteTest.php | 4 +++- tests/mysql/NodeInsertTest.php | 4 +++- tests/mysql/NodePrependTest.php | 4 +++- tests/mysql/NodeStateTest.php | 4 +++- tests/mysql/QueryBehaviorTest.php | 4 +++- tests/mysql/TreeTraversalTest.php | 4 +++- tests/mysql/ValidationAndStructureTest.php | 4 +++- 12 files changed, 37 insertions(+), 11 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 0bf1beb..203ee80 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -41,6 +41,8 @@ class TestCase extends \PHPUnit\Framework\TestCase protected string|null $dsn = null; protected string $fixtureDirectory = __DIR__ . '/support/data/'; + protected string $password = ''; + protected string $user = ''; protected function setUp(): void { @@ -352,6 +354,8 @@ protected function mockConsoleApplication(): void 'db' => [ 'class' => Connection::class, 'dsn' => $this->dsn !== null ? $this->dsn : 'sqlite::memory:', + 'user' => $this->user, + 'password' => $this->password, ], ], ], diff --git a/tests/mysql/CacheManagementTest.php b/tests/mysql/CacheManagementTest.php index f39a0fe..ae9fbfe 100644 --- a/tests/mysql/CacheManagementTest.php +++ b/tests/mysql/CacheManagementTest.php @@ -10,5 +10,7 @@ #[Group('mysql')] final class CacheManagementTest extends AbstractCacheManagement { - protected string|null $dsn = 'sqlite::memory:'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; + protected string $user = 'root'; + protected string $password = 'root'; } diff --git a/tests/mysql/ExceptionHandlingTest.php b/tests/mysql/ExceptionHandlingTest.php index 49754a9..82f89fa 100644 --- a/tests/mysql/ExceptionHandlingTest.php +++ b/tests/mysql/ExceptionHandlingTest.php @@ -10,5 +10,7 @@ #[Group('mysql')] final class ExceptionHandlingTest extends AbstractExceptionHandling { - protected string|null $dsn = 'sqlite::memory:'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; + protected string $user = 'root'; + protected string $password = 'root'; } diff --git a/tests/mysql/ExtensibilityTest.php b/tests/mysql/ExtensibilityTest.php index cb2a027..e420521 100644 --- a/tests/mysql/ExtensibilityTest.php +++ b/tests/mysql/ExtensibilityTest.php @@ -10,5 +10,7 @@ #[Group('mysql')] final class ExtensibilityTest extends AbstractExtensibility { - protected string|null $dsn = 'sqlite::memory:'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; + protected string $user = 'root'; + protected string $password = 'root'; } diff --git a/tests/mysql/NodeAppendTest.php b/tests/mysql/NodeAppendTest.php index ff2c1f2..2054f44 100644 --- a/tests/mysql/NodeAppendTest.php +++ b/tests/mysql/NodeAppendTest.php @@ -10,5 +10,7 @@ #[Group('mysql')] final class NodeAppendTest extends AbstractNodeAppend { - protected string|null $dsn = 'sqlite::memory:'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; + protected string $user = 'root'; + protected string $password = 'root'; } diff --git a/tests/mysql/NodeDeleteTest.php b/tests/mysql/NodeDeleteTest.php index 42c9344..933fae0 100644 --- a/tests/mysql/NodeDeleteTest.php +++ b/tests/mysql/NodeDeleteTest.php @@ -10,5 +10,7 @@ #[Group('mysql')] final class NodeDeleteTest extends AbstractNodeDelete { - protected string|null $dsn = 'sqlite::memory:'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; + protected string $user = 'root'; + protected string $password = 'root'; } diff --git a/tests/mysql/NodeInsertTest.php b/tests/mysql/NodeInsertTest.php index 7478e3a..06a5d58 100644 --- a/tests/mysql/NodeInsertTest.php +++ b/tests/mysql/NodeInsertTest.php @@ -10,5 +10,7 @@ #[Group('mysql')] final class NodeInsertTest extends AbstractNodeInsert { - protected string|null $dsn = 'sqlite::memory:'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; + protected string $user = 'root'; + protected string $password = 'root'; } diff --git a/tests/mysql/NodePrependTest.php b/tests/mysql/NodePrependTest.php index 7c6bb30..4b01884 100644 --- a/tests/mysql/NodePrependTest.php +++ b/tests/mysql/NodePrependTest.php @@ -10,5 +10,7 @@ #[Group('mysql')] final class NodePrependTest extends AbstractNodePrepend { - protected string|null $dsn = 'sqlite::memory:'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; + protected string $user = 'root'; + protected string $password = 'root'; } diff --git a/tests/mysql/NodeStateTest.php b/tests/mysql/NodeStateTest.php index b301486..836897a 100644 --- a/tests/mysql/NodeStateTest.php +++ b/tests/mysql/NodeStateTest.php @@ -10,5 +10,7 @@ #[Group('mysql')] final class NodeStateTest extends AbstractNodeState { - protected string|null $dsn = 'sqlite::memory:'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; + protected string $user = 'root'; + protected string $password = 'root'; } diff --git a/tests/mysql/QueryBehaviorTest.php b/tests/mysql/QueryBehaviorTest.php index 0c58e4c..2e8bf4c 100644 --- a/tests/mysql/QueryBehaviorTest.php +++ b/tests/mysql/QueryBehaviorTest.php @@ -10,5 +10,7 @@ #[Group('mysql')] final class QueryBehaviorTest extends AbstractQueryBehavior { - protected string|null $dsn = 'sqlite::memory:'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; + protected string $user = 'root'; + protected string $password = 'root'; } diff --git a/tests/mysql/TreeTraversalTest.php b/tests/mysql/TreeTraversalTest.php index 3292c12..61dad22 100644 --- a/tests/mysql/TreeTraversalTest.php +++ b/tests/mysql/TreeTraversalTest.php @@ -10,5 +10,7 @@ #[Group('mysql')] final class TreeTraversalTest extends AbstractTreeTraversal { - protected string|null $dsn = 'sqlite::memory:'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; + protected string $user = 'root'; + protected string $password = 'root'; } diff --git a/tests/mysql/ValidationAndStructureTest.php b/tests/mysql/ValidationAndStructureTest.php index 4734c04..858a8d4 100644 --- a/tests/mysql/ValidationAndStructureTest.php +++ b/tests/mysql/ValidationAndStructureTest.php @@ -10,5 +10,7 @@ #[Group('mysql')] final class ValidationAndStructureTest extends AbstractValidationAndStructure { - protected string|null $dsn = 'sqlite::memory:'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; + protected string $user = 'root'; + protected string $password = 'root'; } From cc2773e78545726363afff37e924943e93db270f Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 5 Jul 2025 22:08:49 -0400 Subject: [PATCH 05/22] fix: rename 'user' to 'username' in database connection configuration for clarity. --- .github/workflows/ci-mysql.yml | 4 ++-- tests/TestCase.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index f6a9647..bfb4d0c 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -2,11 +2,11 @@ on: - pull_request - push -name: ci-mysql +name: build jobs: mysql: - name: MySQL database tests. + name: MySQL tests. uses: php-forge/actions/.github/workflows/phpunit-database.yml@main secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/tests/TestCase.php b/tests/TestCase.php index 203ee80..e715fc4 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -354,7 +354,7 @@ protected function mockConsoleApplication(): void 'db' => [ 'class' => Connection::class, 'dsn' => $this->dsn !== null ? $this->dsn : 'sqlite::memory:', - 'user' => $this->user, + 'username' => $this->user, 'password' => $this->password, ], ], From c089ff4d385d78ceeba17eac8a4b25dbfb1d9f58 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 5 Jul 2025 22:14:23 -0400 Subject: [PATCH 06/22] fix: remove redundant name from `MySQL` CI job configuration. --- .github/workflows/ci-mysql.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index bfb4d0c..780314c 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -6,7 +6,6 @@ name: build jobs: mysql: - name: MySQL tests. uses: php-forge/actions/.github/workflows/phpunit-database.yml@main secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From a69fe7075d8a41534d2ba90399fa2837d7db5d4e Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 5 Jul 2025 22:21:30 -0400 Subject: [PATCH 07/22] fix: add descriptive name to `MySQL` job in CI configuration. --- .github/workflows/ci-mysql.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index 780314c..bfb4d0c 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -6,6 +6,7 @@ name: build jobs: mysql: + name: MySQL tests. uses: php-forge/actions/.github/workflows/phpunit-database.yml@main secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From f476257779741329799a625bd76c77e27c0a3d98 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 6 Jul 2025 05:38:00 -0400 Subject: [PATCH 08/22] fix: rename 'user' to 'username' in `MySQL` test classes for consistency. --- tests/TestCase.php | 4 ++-- tests/mysql/CacheManagementTest.php | 2 +- tests/mysql/ExceptionHandlingTest.php | 3 ++- tests/mysql/ExtensibilityTest.php | 2 +- tests/mysql/NodeAppendTest.php | 3 ++- tests/mysql/NodeDeleteTest.php | 3 ++- tests/mysql/NodeInsertTest.php | 3 ++- tests/mysql/NodePrependTest.php | 3 ++- tests/mysql/NodeStateTest.php | 3 ++- tests/mysql/QueryBehaviorTest.php | 3 ++- tests/mysql/TreeTraversalTest.php | 3 ++- tests/mysql/ValidationAndStructureTest.php | 3 ++- 12 files changed, 22 insertions(+), 13 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index e715fc4..a4e626d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -42,7 +42,7 @@ class TestCase extends \PHPUnit\Framework\TestCase protected string|null $dsn = null; protected string $fixtureDirectory = __DIR__ . '/support/data/'; protected string $password = ''; - protected string $user = ''; + protected string $username = ''; protected function setUp(): void { @@ -354,8 +354,8 @@ protected function mockConsoleApplication(): void 'db' => [ 'class' => Connection::class, 'dsn' => $this->dsn !== null ? $this->dsn : 'sqlite::memory:', - 'username' => $this->user, 'password' => $this->password, + 'username' => $this->username, ], ], ], diff --git a/tests/mysql/CacheManagementTest.php b/tests/mysql/CacheManagementTest.php index ae9fbfe..d032957 100644 --- a/tests/mysql/CacheManagementTest.php +++ b/tests/mysql/CacheManagementTest.php @@ -11,6 +11,6 @@ final class CacheManagementTest extends AbstractCacheManagement { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - protected string $user = 'root'; protected string $password = 'root'; + protected string $username = 'root'; } diff --git a/tests/mysql/ExceptionHandlingTest.php b/tests/mysql/ExceptionHandlingTest.php index 82f89fa..2ade30e 100644 --- a/tests/mysql/ExceptionHandlingTest.php +++ b/tests/mysql/ExceptionHandlingTest.php @@ -11,6 +11,7 @@ final class ExceptionHandlingTest extends AbstractExceptionHandling { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - protected string $user = 'root'; + protected string $password = 'root'; + protected string $username = 'root'; } diff --git a/tests/mysql/ExtensibilityTest.php b/tests/mysql/ExtensibilityTest.php index e420521..28415ed 100644 --- a/tests/mysql/ExtensibilityTest.php +++ b/tests/mysql/ExtensibilityTest.php @@ -11,6 +11,6 @@ final class ExtensibilityTest extends AbstractExtensibility { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - protected string $user = 'root'; protected string $password = 'root'; + protected string $username = 'root'; } diff --git a/tests/mysql/NodeAppendTest.php b/tests/mysql/NodeAppendTest.php index 2054f44..ac4b0e7 100644 --- a/tests/mysql/NodeAppendTest.php +++ b/tests/mysql/NodeAppendTest.php @@ -11,6 +11,7 @@ final class NodeAppendTest extends AbstractNodeAppend { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - protected string $user = 'root'; + protected string $password = 'root'; + protected string $username = 'root'; } diff --git a/tests/mysql/NodeDeleteTest.php b/tests/mysql/NodeDeleteTest.php index 933fae0..7eab73e 100644 --- a/tests/mysql/NodeDeleteTest.php +++ b/tests/mysql/NodeDeleteTest.php @@ -11,6 +11,7 @@ final class NodeDeleteTest extends AbstractNodeDelete { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - protected string $user = 'root'; + protected string $password = 'root'; + protected string $username = 'root'; } diff --git a/tests/mysql/NodeInsertTest.php b/tests/mysql/NodeInsertTest.php index 06a5d58..e070feb 100644 --- a/tests/mysql/NodeInsertTest.php +++ b/tests/mysql/NodeInsertTest.php @@ -11,6 +11,7 @@ final class NodeInsertTest extends AbstractNodeInsert { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - protected string $user = 'root'; + protected string $password = 'root'; + protected string $username = 'root'; } diff --git a/tests/mysql/NodePrependTest.php b/tests/mysql/NodePrependTest.php index 4b01884..2a03510 100644 --- a/tests/mysql/NodePrependTest.php +++ b/tests/mysql/NodePrependTest.php @@ -11,6 +11,7 @@ final class NodePrependTest extends AbstractNodePrepend { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - protected string $user = 'root'; + protected string $password = 'root'; + protected string $username = 'root'; } diff --git a/tests/mysql/NodeStateTest.php b/tests/mysql/NodeStateTest.php index 836897a..5efdc8e 100644 --- a/tests/mysql/NodeStateTest.php +++ b/tests/mysql/NodeStateTest.php @@ -11,6 +11,7 @@ final class NodeStateTest extends AbstractNodeState { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - protected string $user = 'root'; + protected string $password = 'root'; + protected string $username = 'root'; } diff --git a/tests/mysql/QueryBehaviorTest.php b/tests/mysql/QueryBehaviorTest.php index 2e8bf4c..eef9f76 100644 --- a/tests/mysql/QueryBehaviorTest.php +++ b/tests/mysql/QueryBehaviorTest.php @@ -11,6 +11,7 @@ final class QueryBehaviorTest extends AbstractQueryBehavior { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - protected string $user = 'root'; + protected string $password = 'root'; + protected string $username = 'root'; } diff --git a/tests/mysql/TreeTraversalTest.php b/tests/mysql/TreeTraversalTest.php index 61dad22..230671e 100644 --- a/tests/mysql/TreeTraversalTest.php +++ b/tests/mysql/TreeTraversalTest.php @@ -11,6 +11,7 @@ final class TreeTraversalTest extends AbstractTreeTraversal { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - protected string $user = 'root'; + protected string $password = 'root'; + protected string $username = 'root'; } diff --git a/tests/mysql/ValidationAndStructureTest.php b/tests/mysql/ValidationAndStructureTest.php index 858a8d4..51a8302 100644 --- a/tests/mysql/ValidationAndStructureTest.php +++ b/tests/mysql/ValidationAndStructureTest.php @@ -11,6 +11,7 @@ final class ValidationAndStructureTest extends AbstractValidationAndStructure { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - protected string $user = 'root'; + protected string $password = 'root'; + protected string $username = 'root'; } From 7ca090221ef3425eaa7f9fd28346703bdd31acbd Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 6 Jul 2025 05:50:29 -0400 Subject: [PATCH 09/22] fix: execute `dropTable()` commands in `TestCase` to ensure proper table removal. --- tests/TestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index a4e626d..b924911 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -169,11 +169,11 @@ protected function createDatabase(): void $command = $this->getDb()->createCommand(); if ($this->getDb()->getTableSchema('tree', true) !== null) { - $command->dropTable('tree'); + $command->dropTable('tree')->execute(); } if ($this->getDb()->getTableSchema('multiple_tree', true) !== null) { - $command->dropTable('multiple_tree'); + $command->dropTable('multiple_tree')->execute(); } $command->createTable( From 8d723b4bf5fa2fadeae1fa9d31bf76ca05c935b2 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 6 Jul 2025 05:58:39 -0400 Subject: [PATCH 10/22] fix: add `phpunit` group to `MySQL` CI configuration for improved test organization and include `framework-options` for mutation tests in configuration. --- .github/workflows/ci-mysql.yml | 3 ++- .github/workflows/mutation.yml | 1 + composer.json | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index bfb4d0c..d25df4d 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -24,6 +24,7 @@ jobs: database-type: mysql database-versions: '["8.0", "8.4", "latest"]' enable-concurrency: true - group-phpunit: mysql extensions: pdo, pdo_mysql + group-phpunit: mysql os: '["ubuntu-latest"]' + php-versions: '["8.4"]' diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index 9c6f1ec..6d35498 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -22,5 +22,6 @@ jobs: uses: php-forge/actions/.github/workflows/infection.yml@main with: phpstan: true + framework-options: --test-framework-options="--group=sqlite" secrets: STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} diff --git a/composer.json b/composer.json index 7fe8f94..3d299ea 100644 --- a/composer.json +++ b/composer.json @@ -51,8 +51,8 @@ "scripts": { "check-dependencies": "./vendor/bin/composer-require-checker check", "ecs": "./vendor/bin/ecs --fix", - "mutation": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --only-covered --min-msi=100 --min-covered-msi=100", - "mutation-static": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --only-covered --min-msi=100 --min-covered-msi=100 --static-analysis-tool=phpstan", + "mutation": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --only-covered --min-msi=100 --min-covered-msi=100 --test-framework-options=--group=sqlite", + "mutation-static": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --only-covered --min-msi=100 --min-covered-msi=100 --static-analysis-tool=phpstan --test-framework-options=--group=sqlite", "rector": "./vendor/bin/rector process src", "static": "./vendor/bin/phpstan --memory-limit=512M", "tests": "./vendor/bin/phpunit" From 62de88fe06d44dc0c62431b6d6e1823c612c09c6 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 6 Jul 2025 06:01:20 -0400 Subject: [PATCH 11/22] fix: rename CI workflow to `build-mysql` for clarity and correct `php-versions` to `php-version` in configuration. --- .github/workflows/ci-mysql.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index d25df4d..0f6db57 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -2,7 +2,7 @@ on: - pull_request - push -name: build +name: build-mysql jobs: mysql: @@ -27,4 +27,4 @@ jobs: extensions: pdo, pdo_mysql group-phpunit: mysql os: '["ubuntu-latest"]' - php-versions: '["8.4"]' + php-version: '["8.4"]' From 16bfd6f3404fef2acb41d57a775c4187c97fa8c0 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 6 Jul 2025 06:59:16 -0400 Subject: [PATCH 12/22] fix: rename `group-phpunit` to `phpunit-group` for consistency in CI configuration. --- .github/workflows/ci-mysql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index 0f6db57..5c05c8c 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -25,6 +25,6 @@ jobs: database-versions: '["8.0", "8.4", "latest"]' enable-concurrency: true extensions: pdo, pdo_mysql - group-phpunit: mysql os: '["ubuntu-latest"]' php-version: '["8.4"]' + phpunit-group: mysql From 1e58e92e0d00080bf874061d8dd6cfbf9106e298 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 6 Jul 2025 07:20:30 -0400 Subject: [PATCH 13/22] fix: update CI configuration to use `phpunit-group` for `MySQL` compatibility tests. --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d491a54..ce9b83a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,13 +26,13 @@ jobs: composer-command: | composer require yiisoft/yii2:22.0.x-dev --prefer-dist --no-progress --no-interaction --no-scripts --ansi concurrency-group: phpunit-${{ github.workflow }}-${{ github.ref }} - exclude-group-phpunit: mysql extensions: pdo, pdo_sqlite + phpunit-group: sqlite phpunit-compatibility: uses: php-forge/actions/.github/workflows/phpunit.yml@main secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: concurrency-group: compatibility-${{ github.workflow }}-${{ github.ref }} - exclude-group-phpunit: mysql extensions: pdo, pdo_sqlite + phpunit-group: sqlite From 73ef80c66dcaaae428110888a82ae047f0ebeb75 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 6 Jul 2025 07:46:06 -0400 Subject: [PATCH 14/22] feat: add initial CI workflow for MySQL tests with phpunit integration. --- .../workflows/{ci-mysql.yml => build-mysql.yml} | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) rename .github/workflows/{ci-mysql.yml => build-mysql.yml} (72%) diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/build-mysql.yml similarity index 72% rename from .github/workflows/ci-mysql.yml rename to .github/workflows/build-mysql.yml index 5c05c8c..1e830ac 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/build-mysql.yml @@ -1,6 +1,19 @@ on: - - pull_request - - push + pull_request: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + + push: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' name: build-mysql From 2dca3d671951c29d81bb5588f32863e0c1a4a9d1 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 6 Jul 2025 08:16:22 -0400 Subject: [PATCH 15/22] feat: Add `PostgreSQL` test suite with multiple test cases for improved coverage. --- .github/workflows/build-pgsql.yml | 44 ++++++++++++++++++++++ tests/pgsql/CacheManagementTest.php | 16 ++++++++ tests/pgsql/ExceptionHandlingTest.php | 16 ++++++++ tests/pgsql/ExtensibilityTest.php | 16 ++++++++ tests/pgsql/NodeAppendTest.php | 16 ++++++++ tests/pgsql/NodeDeleteTest.php | 16 ++++++++ tests/pgsql/NodeInsertTest.php | 16 ++++++++ tests/pgsql/NodePrependTest.php | 16 ++++++++ tests/pgsql/NodeStateTest.php | 16 ++++++++ tests/pgsql/QueryBehaviorTest.php | 16 ++++++++ tests/pgsql/TreeTraversalTest.php | 16 ++++++++ tests/pgsql/ValidationAndStructureTest.php | 16 ++++++++ 12 files changed, 220 insertions(+) create mode 100644 .github/workflows/build-pgsql.yml create mode 100644 tests/pgsql/CacheManagementTest.php create mode 100644 tests/pgsql/ExceptionHandlingTest.php create mode 100644 tests/pgsql/ExtensibilityTest.php create mode 100644 tests/pgsql/NodeAppendTest.php create mode 100644 tests/pgsql/NodeDeleteTest.php create mode 100644 tests/pgsql/NodeInsertTest.php create mode 100644 tests/pgsql/NodePrependTest.php create mode 100644 tests/pgsql/NodeStateTest.php create mode 100644 tests/pgsql/QueryBehaviorTest.php create mode 100644 tests/pgsql/TreeTraversalTest.php create mode 100644 tests/pgsql/ValidationAndStructureTest.php diff --git a/.github/workflows/build-pgsql.yml b/.github/workflows/build-pgsql.yml new file mode 100644 index 0000000..45682bd --- /dev/null +++ b/.github/workflows/build-pgsql.yml @@ -0,0 +1,44 @@ +on: + pull_request: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + + push: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + +name: build-pgsql + +jobs: + pgsql: + name: PostgreSQL tests. + uses: php-forge/actions/.github/workflows/phpunit-database.yml@main + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + concurrency-group: pgsql-${{ github.ref }} + database-env: | + { + "POSTGRES_DB": "yiitest", + "POSTGRES_USER": "root", + "POSTGRES_PASSWORD": "root" + } + database-health-cmd: "pg_isready -U postgres" + database-health-retries: 3 + database-image: postgres + database-port: 5432 + database-type: pgsql + database-versions: '["15", "16", "17"]' + enable-concurrency: true + extensions: pdo, pdo_pgsql + os: '["ubuntu-latest"]' + php-version: '["8.4"]' + phpunit-group: pgsql diff --git a/tests/pgsql/CacheManagementTest.php b/tests/pgsql/CacheManagementTest.php new file mode 100644 index 0000000..2133f1e --- /dev/null +++ b/tests/pgsql/CacheManagementTest.php @@ -0,0 +1,16 @@ + Date: Sun, 6 Jul 2025 08:33:02 -0400 Subject: [PATCH 16/22] fix: sort dataset queries by `id` for consistent order in test cases. --- tests/TestCase.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index b924911..0677e23 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -293,14 +293,14 @@ protected function generateFixtureTree(): void */ protected function getDataSet(): array { - $dataSetTree = Tree::find()->asArray()->all(); + $dataSetTree = Tree::find()->orderBy(['id' => SORT_ASC])->asArray()->all(); foreach ($dataSetTree as $key => $value) { $dataSetTree[$key]['type'] = 'tree'; $dataSetTree[$key]['tree'] = 0; } - $dataSetMultipleTree = MultipleTree::find()->asArray()->all(); + $dataSetMultipleTree = MultipleTree::find()->orderBy(['id' => SORT_ASC])->asArray()->all(); foreach ($dataSetMultipleTree as $key => $value) { $dataSetMultipleTree[$key]['type'] = 'multiple_tree'; @@ -316,7 +316,7 @@ protected function getDataSet(): array */ protected function getDataSetMultipleTree(): array { - $dataSetMultipleTree = MultipleTree::find()->asArray()->all(); + $dataSetMultipleTree = MultipleTree::find()->orderBy(['id' => SORT_ASC])->asArray()->all(); foreach ($dataSetMultipleTree as $key => $value) { $dataSetMultipleTree[$key]['type'] = 'multiple_tree'; From f43e8bb2dcfa3119284a395ef75e113796679ed2 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 6 Jul 2025 08:53:34 -0400 Subject: [PATCH 17/22] feat: add `driverName` property to test classes for database compatibility. --- tests/TestCase.php | 40 ++++++++++++++++++++-- tests/base/AbstractQueryBehavior.php | 2 +- tests/mysql/CacheManagementTest.php | 1 + tests/mysql/ExceptionHandlingTest.php | 2 +- tests/mysql/ExtensibilityTest.php | 1 + tests/mysql/NodeAppendTest.php | 2 +- tests/mysql/NodeDeleteTest.php | 2 +- tests/mysql/NodeInsertTest.php | 2 +- tests/mysql/NodePrependTest.php | 2 +- tests/mysql/NodeStateTest.php | 2 +- tests/mysql/QueryBehaviorTest.php | 2 +- tests/mysql/TreeTraversalTest.php | 2 +- tests/mysql/ValidationAndStructureTest.php | 2 +- tests/pgsql/CacheManagementTest.php | 1 + tests/pgsql/ExceptionHandlingTest.php | 1 + tests/pgsql/ExtensibilityTest.php | 1 + tests/pgsql/NodeAppendTest.php | 1 + tests/pgsql/NodeDeleteTest.php | 1 + tests/pgsql/NodeInsertTest.php | 1 + tests/pgsql/NodePrependTest.php | 1 + tests/pgsql/NodeStateTest.php | 1 + tests/pgsql/QueryBehaviorTest.php | 1 + tests/pgsql/TreeTraversalTest.php | 1 + tests/pgsql/ValidationAndStructureTest.php | 1 + 24 files changed, 61 insertions(+), 12 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 0677e23..300bb1d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -16,6 +16,7 @@ use function array_values; use function dom_import_simplexml; use function file_get_contents; +use function preg_replace; use function simplexml_load_string; use function str_replace; @@ -40,6 +41,7 @@ class TestCase extends \PHPUnit\Framework\TestCase use SchemaBuilderTrait; protected string|null $dsn = null; + protected string $driverName = 'sqlite'; protected string $fixtureDirectory = __DIR__ . '/support/data/'; protected string $password = ''; protected string $username = ''; @@ -105,12 +107,12 @@ protected function assertQueryHasOrderBy(ActiveQuery $query, string $methodName) self::assertStringContainsString( 'ORDER BY', - $sql, + $this->replaceQuotes($sql), "'{$methodName}' query should include 'ORDER BY' clause for deterministic results.", ); self::assertStringContainsString( - '`lft`', + $this->replaceQuotes('[[lft]]'), $sql, "'{$methodName}' query should order by 'left' attribute for consistent ordering.", ); @@ -362,6 +364,40 @@ protected function mockConsoleApplication(): void ); } + /** + * Adjust dbms specific escaping. + * + * @param string $sql SQL to adjust. + * + * @return string Adjusted SQL. + */ + protected function replaceQuotes(string $sql): string + { + return match ($this->driverName) { + 'mysql', 'sqlite' => str_replace( + ['[[', ']]'], + '`', + $sql, + ), + 'oci' => str_replace( + ['[[', ']]'], + '"', + $sql, + ), + 'pgsql' => str_replace( + ['\\[', '\\]'], + ['[', ']'], + preg_replace('/(\[\[)|((? str_replace( + ['[[', ']]'], + ['[', ']'], + $sql, + ), + default => $sql, + }; + } + /** * Applies database updates to tree nodes. * diff --git a/tests/base/AbstractQueryBehavior.php b/tests/base/AbstractQueryBehavior.php index 53c3e2f..2dfbbdd 100644 --- a/tests/base/AbstractQueryBehavior.php +++ b/tests/base/AbstractQueryBehavior.php @@ -128,7 +128,7 @@ public function testRootsMethodRequiresLeftAttributeOrderingWhenTreeAttributeIsD "'roots()' query should include 'ORDER BY' clause for consistent results.", ); self::assertStringContainsString( - '`lft`', + $this->replaceQuotes('[[lft]]'), $sql, "'roots()' query should order by 'left' attribute for deterministic ordering.", ); diff --git a/tests/mysql/CacheManagementTest.php b/tests/mysql/CacheManagementTest.php index d032957..c815c60 100644 --- a/tests/mysql/CacheManagementTest.php +++ b/tests/mysql/CacheManagementTest.php @@ -11,6 +11,7 @@ final class CacheManagementTest extends AbstractCacheManagement { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; + protected string $driverName = 'mysql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/ExceptionHandlingTest.php b/tests/mysql/ExceptionHandlingTest.php index 2ade30e..ed8db0e 100644 --- a/tests/mysql/ExceptionHandlingTest.php +++ b/tests/mysql/ExceptionHandlingTest.php @@ -11,7 +11,7 @@ final class ExceptionHandlingTest extends AbstractExceptionHandling { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - + protected string $driverName = 'mysql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/ExtensibilityTest.php b/tests/mysql/ExtensibilityTest.php index 28415ed..96118bc 100644 --- a/tests/mysql/ExtensibilityTest.php +++ b/tests/mysql/ExtensibilityTest.php @@ -11,6 +11,7 @@ final class ExtensibilityTest extends AbstractExtensibility { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; + protected string $driverName = 'mysql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/NodeAppendTest.php b/tests/mysql/NodeAppendTest.php index ac4b0e7..951ed13 100644 --- a/tests/mysql/NodeAppendTest.php +++ b/tests/mysql/NodeAppendTest.php @@ -11,7 +11,7 @@ final class NodeAppendTest extends AbstractNodeAppend { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - + protected string $driverName = 'mysql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/NodeDeleteTest.php b/tests/mysql/NodeDeleteTest.php index 7eab73e..e2a5cca 100644 --- a/tests/mysql/NodeDeleteTest.php +++ b/tests/mysql/NodeDeleteTest.php @@ -11,7 +11,7 @@ final class NodeDeleteTest extends AbstractNodeDelete { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - + protected string $driverName = 'mysql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/NodeInsertTest.php b/tests/mysql/NodeInsertTest.php index e070feb..2db3f8f 100644 --- a/tests/mysql/NodeInsertTest.php +++ b/tests/mysql/NodeInsertTest.php @@ -11,7 +11,7 @@ final class NodeInsertTest extends AbstractNodeInsert { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - + protected string $driverName = 'mysql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/NodePrependTest.php b/tests/mysql/NodePrependTest.php index 2a03510..26dd8ce 100644 --- a/tests/mysql/NodePrependTest.php +++ b/tests/mysql/NodePrependTest.php @@ -11,7 +11,7 @@ final class NodePrependTest extends AbstractNodePrepend { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - + protected string $driverName = 'mysql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/NodeStateTest.php b/tests/mysql/NodeStateTest.php index 5efdc8e..44bde6e 100644 --- a/tests/mysql/NodeStateTest.php +++ b/tests/mysql/NodeStateTest.php @@ -11,7 +11,7 @@ final class NodeStateTest extends AbstractNodeState { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - + protected string $driverName = 'mysql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/QueryBehaviorTest.php b/tests/mysql/QueryBehaviorTest.php index eef9f76..7a5e484 100644 --- a/tests/mysql/QueryBehaviorTest.php +++ b/tests/mysql/QueryBehaviorTest.php @@ -11,7 +11,7 @@ final class QueryBehaviorTest extends AbstractQueryBehavior { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - + protected string $driverName = 'mysql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/TreeTraversalTest.php b/tests/mysql/TreeTraversalTest.php index 230671e..d477f01 100644 --- a/tests/mysql/TreeTraversalTest.php +++ b/tests/mysql/TreeTraversalTest.php @@ -11,7 +11,7 @@ final class TreeTraversalTest extends AbstractTreeTraversal { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - + protected string $driverName = 'mysql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/ValidationAndStructureTest.php b/tests/mysql/ValidationAndStructureTest.php index 51a8302..2814ba0 100644 --- a/tests/mysql/ValidationAndStructureTest.php +++ b/tests/mysql/ValidationAndStructureTest.php @@ -11,7 +11,7 @@ final class ValidationAndStructureTest extends AbstractValidationAndStructure { protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; - + protected string $driverName = 'mysql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/CacheManagementTest.php b/tests/pgsql/CacheManagementTest.php index 2133f1e..7274b9e 100644 --- a/tests/pgsql/CacheManagementTest.php +++ b/tests/pgsql/CacheManagementTest.php @@ -11,6 +11,7 @@ final class CacheManagementTest extends AbstractCacheManagement { protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; + protected string $driverName = 'pgsql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/ExceptionHandlingTest.php b/tests/pgsql/ExceptionHandlingTest.php index 43f97c2..aa52cf1 100644 --- a/tests/pgsql/ExceptionHandlingTest.php +++ b/tests/pgsql/ExceptionHandlingTest.php @@ -11,6 +11,7 @@ final class ExceptionHandlingTest extends AbstractExceptionHandling { protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; + protected string $driverName = 'pgsql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/ExtensibilityTest.php b/tests/pgsql/ExtensibilityTest.php index 4130829..932a0d4 100644 --- a/tests/pgsql/ExtensibilityTest.php +++ b/tests/pgsql/ExtensibilityTest.php @@ -11,6 +11,7 @@ final class ExtensibilityTest extends AbstractExtensibility { protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; + protected string $driverName = 'pgsql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/NodeAppendTest.php b/tests/pgsql/NodeAppendTest.php index dd470e6..93ce240 100644 --- a/tests/pgsql/NodeAppendTest.php +++ b/tests/pgsql/NodeAppendTest.php @@ -11,6 +11,7 @@ final class NodeAppendTest extends AbstractNodeAppend { protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; + protected string $driverName = 'pgsql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/NodeDeleteTest.php b/tests/pgsql/NodeDeleteTest.php index 42ab1a6..8e92a69 100644 --- a/tests/pgsql/NodeDeleteTest.php +++ b/tests/pgsql/NodeDeleteTest.php @@ -11,6 +11,7 @@ final class NodeDeleteTest extends AbstractNodeDelete { protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; + protected string $driverName = 'pgsql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/NodeInsertTest.php b/tests/pgsql/NodeInsertTest.php index cb3ab22..7591bde 100644 --- a/tests/pgsql/NodeInsertTest.php +++ b/tests/pgsql/NodeInsertTest.php @@ -11,6 +11,7 @@ final class NodeInsertTest extends AbstractNodeInsert { protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; + protected string $driverName = 'pgsql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/NodePrependTest.php b/tests/pgsql/NodePrependTest.php index 54ce213..38031a5 100644 --- a/tests/pgsql/NodePrependTest.php +++ b/tests/pgsql/NodePrependTest.php @@ -11,6 +11,7 @@ final class NodePrependTest extends AbstractNodePrepend { protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; + protected string $driverName = 'pgsql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/NodeStateTest.php b/tests/pgsql/NodeStateTest.php index ce60f9d..4ba2c44 100644 --- a/tests/pgsql/NodeStateTest.php +++ b/tests/pgsql/NodeStateTest.php @@ -11,6 +11,7 @@ final class NodeStateTest extends AbstractNodeState { protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; + protected string $driverName = 'pgsql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/QueryBehaviorTest.php b/tests/pgsql/QueryBehaviorTest.php index 8683e69..ac4a137 100644 --- a/tests/pgsql/QueryBehaviorTest.php +++ b/tests/pgsql/QueryBehaviorTest.php @@ -11,6 +11,7 @@ final class QueryBehaviorTest extends AbstractQueryBehavior { protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; + protected string $driverName = 'pgsql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/TreeTraversalTest.php b/tests/pgsql/TreeTraversalTest.php index 81d0ad9..5005fe5 100644 --- a/tests/pgsql/TreeTraversalTest.php +++ b/tests/pgsql/TreeTraversalTest.php @@ -11,6 +11,7 @@ final class TreeTraversalTest extends AbstractTreeTraversal { protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; + protected string $driverName = 'pgsql'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/ValidationAndStructureTest.php b/tests/pgsql/ValidationAndStructureTest.php index b04d744..6586d9b 100644 --- a/tests/pgsql/ValidationAndStructureTest.php +++ b/tests/pgsql/ValidationAndStructureTest.php @@ -11,6 +11,7 @@ final class ValidationAndStructureTest extends AbstractValidationAndStructure { protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; + protected string $driverName = 'pgsql'; protected string $password = 'root'; protected string $username = 'root'; } From e90daf59156597273f540f29f2a7daa583556648 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 6 Jul 2025 08:56:24 -0400 Subject: [PATCH 18/22] fix: update `DSN` property placement in `MySQL` and `PostgreSQL` test classes for consistency. --- tests/TestCase.php | 2 +- tests/mysql/CacheManagementTest.php | 2 +- tests/mysql/ExceptionHandlingTest.php | 2 +- tests/mysql/ExtensibilityTest.php | 2 +- tests/mysql/NodeAppendTest.php | 2 +- tests/mysql/NodeDeleteTest.php | 2 +- tests/mysql/NodeInsertTest.php | 2 +- tests/mysql/NodePrependTest.php | 2 +- tests/mysql/NodeStateTest.php | 2 +- tests/mysql/QueryBehaviorTest.php | 2 +- tests/mysql/TreeTraversalTest.php | 2 +- tests/mysql/ValidationAndStructureTest.php | 2 +- tests/pgsql/CacheManagementTest.php | 2 +- tests/pgsql/ExceptionHandlingTest.php | 2 +- tests/pgsql/ExtensibilityTest.php | 2 +- tests/pgsql/NodeAppendTest.php | 2 +- tests/pgsql/NodeDeleteTest.php | 2 +- tests/pgsql/NodeInsertTest.php | 2 +- tests/pgsql/NodePrependTest.php | 2 +- tests/pgsql/NodeStateTest.php | 2 +- tests/pgsql/QueryBehaviorTest.php | 2 +- tests/pgsql/TreeTraversalTest.php | 2 +- tests/pgsql/ValidationAndStructureTest.php | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 300bb1d..58c9e0e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -39,9 +39,9 @@ class TestCase extends \PHPUnit\Framework\TestCase { use SchemaBuilderTrait; + protected string $driverName = 'sqlite'; protected string|null $dsn = null; - protected string $driverName = 'sqlite'; protected string $fixtureDirectory = __DIR__ . '/support/data/'; protected string $password = ''; protected string $username = ''; diff --git a/tests/mysql/CacheManagementTest.php b/tests/mysql/CacheManagementTest.php index c815c60..1f5c2b4 100644 --- a/tests/mysql/CacheManagementTest.php +++ b/tests/mysql/CacheManagementTest.php @@ -10,8 +10,8 @@ #[Group('mysql')] final class CacheManagementTest extends AbstractCacheManagement { - protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $driverName = 'mysql'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/ExceptionHandlingTest.php b/tests/mysql/ExceptionHandlingTest.php index ed8db0e..6682dfb 100644 --- a/tests/mysql/ExceptionHandlingTest.php +++ b/tests/mysql/ExceptionHandlingTest.php @@ -10,8 +10,8 @@ #[Group('mysql')] final class ExceptionHandlingTest extends AbstractExceptionHandling { - protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $driverName = 'mysql'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/ExtensibilityTest.php b/tests/mysql/ExtensibilityTest.php index 96118bc..ae2114a 100644 --- a/tests/mysql/ExtensibilityTest.php +++ b/tests/mysql/ExtensibilityTest.php @@ -10,8 +10,8 @@ #[Group('mysql')] final class ExtensibilityTest extends AbstractExtensibility { - protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $driverName = 'mysql'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/NodeAppendTest.php b/tests/mysql/NodeAppendTest.php index 951ed13..a2f885c 100644 --- a/tests/mysql/NodeAppendTest.php +++ b/tests/mysql/NodeAppendTest.php @@ -10,8 +10,8 @@ #[Group('mysql')] final class NodeAppendTest extends AbstractNodeAppend { - protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $driverName = 'mysql'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/NodeDeleteTest.php b/tests/mysql/NodeDeleteTest.php index e2a5cca..f1c1b89 100644 --- a/tests/mysql/NodeDeleteTest.php +++ b/tests/mysql/NodeDeleteTest.php @@ -10,8 +10,8 @@ #[Group('mysql')] final class NodeDeleteTest extends AbstractNodeDelete { - protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $driverName = 'mysql'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/NodeInsertTest.php b/tests/mysql/NodeInsertTest.php index 2db3f8f..1691012 100644 --- a/tests/mysql/NodeInsertTest.php +++ b/tests/mysql/NodeInsertTest.php @@ -10,8 +10,8 @@ #[Group('mysql')] final class NodeInsertTest extends AbstractNodeInsert { - protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $driverName = 'mysql'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/NodePrependTest.php b/tests/mysql/NodePrependTest.php index 26dd8ce..656995e 100644 --- a/tests/mysql/NodePrependTest.php +++ b/tests/mysql/NodePrependTest.php @@ -10,8 +10,8 @@ #[Group('mysql')] final class NodePrependTest extends AbstractNodePrepend { - protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $driverName = 'mysql'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/NodeStateTest.php b/tests/mysql/NodeStateTest.php index 44bde6e..9fd640d 100644 --- a/tests/mysql/NodeStateTest.php +++ b/tests/mysql/NodeStateTest.php @@ -10,8 +10,8 @@ #[Group('mysql')] final class NodeStateTest extends AbstractNodeState { - protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $driverName = 'mysql'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/QueryBehaviorTest.php b/tests/mysql/QueryBehaviorTest.php index 7a5e484..1abc4ff 100644 --- a/tests/mysql/QueryBehaviorTest.php +++ b/tests/mysql/QueryBehaviorTest.php @@ -10,8 +10,8 @@ #[Group('mysql')] final class QueryBehaviorTest extends AbstractQueryBehavior { - protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $driverName = 'mysql'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/TreeTraversalTest.php b/tests/mysql/TreeTraversalTest.php index d477f01..562d6b3 100644 --- a/tests/mysql/TreeTraversalTest.php +++ b/tests/mysql/TreeTraversalTest.php @@ -10,8 +10,8 @@ #[Group('mysql')] final class TreeTraversalTest extends AbstractTreeTraversal { - protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $driverName = 'mysql'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/mysql/ValidationAndStructureTest.php b/tests/mysql/ValidationAndStructureTest.php index 2814ba0..dae7c44 100644 --- a/tests/mysql/ValidationAndStructureTest.php +++ b/tests/mysql/ValidationAndStructureTest.php @@ -10,8 +10,8 @@ #[Group('mysql')] final class ValidationAndStructureTest extends AbstractValidationAndStructure { - protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $driverName = 'mysql'; + protected string|null $dsn = 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/CacheManagementTest.php b/tests/pgsql/CacheManagementTest.php index 7274b9e..0578883 100644 --- a/tests/pgsql/CacheManagementTest.php +++ b/tests/pgsql/CacheManagementTest.php @@ -10,8 +10,8 @@ #[Group('pgsql')] final class CacheManagementTest extends AbstractCacheManagement { - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $driverName = 'pgsql'; + protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/ExceptionHandlingTest.php b/tests/pgsql/ExceptionHandlingTest.php index aa52cf1..293f462 100644 --- a/tests/pgsql/ExceptionHandlingTest.php +++ b/tests/pgsql/ExceptionHandlingTest.php @@ -10,8 +10,8 @@ #[Group('pgsql')] final class ExceptionHandlingTest extends AbstractExceptionHandling { - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $driverName = 'pgsql'; + protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/ExtensibilityTest.php b/tests/pgsql/ExtensibilityTest.php index 932a0d4..b0242c1 100644 --- a/tests/pgsql/ExtensibilityTest.php +++ b/tests/pgsql/ExtensibilityTest.php @@ -10,8 +10,8 @@ #[Group('pgsql')] final class ExtensibilityTest extends AbstractExtensibility { - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $driverName = 'pgsql'; + protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/NodeAppendTest.php b/tests/pgsql/NodeAppendTest.php index 93ce240..742ddab 100644 --- a/tests/pgsql/NodeAppendTest.php +++ b/tests/pgsql/NodeAppendTest.php @@ -10,8 +10,8 @@ #[Group('pgsql')] final class NodeAppendTest extends AbstractNodeAppend { - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $driverName = 'pgsql'; + protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/NodeDeleteTest.php b/tests/pgsql/NodeDeleteTest.php index 8e92a69..521d189 100644 --- a/tests/pgsql/NodeDeleteTest.php +++ b/tests/pgsql/NodeDeleteTest.php @@ -10,8 +10,8 @@ #[Group('pgsql')] final class NodeDeleteTest extends AbstractNodeDelete { - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $driverName = 'pgsql'; + protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/NodeInsertTest.php b/tests/pgsql/NodeInsertTest.php index 7591bde..3e1fcac 100644 --- a/tests/pgsql/NodeInsertTest.php +++ b/tests/pgsql/NodeInsertTest.php @@ -10,8 +10,8 @@ #[Group('pgsql')] final class NodeInsertTest extends AbstractNodeInsert { - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $driverName = 'pgsql'; + protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/NodePrependTest.php b/tests/pgsql/NodePrependTest.php index 38031a5..d2b56c1 100644 --- a/tests/pgsql/NodePrependTest.php +++ b/tests/pgsql/NodePrependTest.php @@ -10,8 +10,8 @@ #[Group('pgsql')] final class NodePrependTest extends AbstractNodePrepend { - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $driverName = 'pgsql'; + protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/NodeStateTest.php b/tests/pgsql/NodeStateTest.php index 4ba2c44..c49dedc 100644 --- a/tests/pgsql/NodeStateTest.php +++ b/tests/pgsql/NodeStateTest.php @@ -10,8 +10,8 @@ #[Group('pgsql')] final class NodeStateTest extends AbstractNodeState { - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $driverName = 'pgsql'; + protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/QueryBehaviorTest.php b/tests/pgsql/QueryBehaviorTest.php index ac4a137..feb1682 100644 --- a/tests/pgsql/QueryBehaviorTest.php +++ b/tests/pgsql/QueryBehaviorTest.php @@ -10,8 +10,8 @@ #[Group('pgsql')] final class QueryBehaviorTest extends AbstractQueryBehavior { - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $driverName = 'pgsql'; + protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/TreeTraversalTest.php b/tests/pgsql/TreeTraversalTest.php index 5005fe5..fc1c3b7 100644 --- a/tests/pgsql/TreeTraversalTest.php +++ b/tests/pgsql/TreeTraversalTest.php @@ -10,8 +10,8 @@ #[Group('pgsql')] final class TreeTraversalTest extends AbstractTreeTraversal { - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $driverName = 'pgsql'; + protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $password = 'root'; protected string $username = 'root'; } diff --git a/tests/pgsql/ValidationAndStructureTest.php b/tests/pgsql/ValidationAndStructureTest.php index 6586d9b..e419869 100644 --- a/tests/pgsql/ValidationAndStructureTest.php +++ b/tests/pgsql/ValidationAndStructureTest.php @@ -10,8 +10,8 @@ #[Group('pgsql')] final class ValidationAndStructureTest extends AbstractValidationAndStructure { - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $driverName = 'pgsql'; + protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; protected string $password = 'root'; protected string $username = 'root'; } From 762243b21781ef0bfc3a00c0a9b2e6bfc2bce0a6 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 6 Jul 2025 09:10:42 -0400 Subject: [PATCH 19/22] feat: add `SQLServer` test suite with multiple test cases for improved coverage. --- .github/workflows/build-mssql.yml | 55 ++++++++++++++++++++++ tests/mssql/CacheManagementTest.php | 17 +++++++ tests/mssql/ExceptionHandlingTest.php | 17 +++++++ tests/mssql/ExtensibilityTest.php | 17 +++++++ tests/mssql/NodeAppendTest.php | 17 +++++++ tests/mssql/NodeDeleteTest.php | 17 +++++++ tests/mssql/NodeInsertTest.php | 17 +++++++ tests/mssql/NodePrependTest.php | 17 +++++++ tests/mssql/NodeStateTest.php | 17 +++++++ tests/mssql/QueryBehaviorTest.php | 17 +++++++ tests/mssql/TreeTraversalTest.php | 17 +++++++ tests/mssql/ValidationAndStructureTest.php | 17 +++++++ 12 files changed, 242 insertions(+) create mode 100644 .github/workflows/build-mssql.yml create mode 100644 tests/mssql/CacheManagementTest.php create mode 100644 tests/mssql/ExceptionHandlingTest.php create mode 100644 tests/mssql/ExtensibilityTest.php create mode 100644 tests/mssql/NodeAppendTest.php create mode 100644 tests/mssql/NodeDeleteTest.php create mode 100644 tests/mssql/NodeInsertTest.php create mode 100644 tests/mssql/NodePrependTest.php create mode 100644 tests/mssql/NodeStateTest.php create mode 100644 tests/mssql/QueryBehaviorTest.php create mode 100644 tests/mssql/TreeTraversalTest.php create mode 100644 tests/mssql/ValidationAndStructureTest.php diff --git a/.github/workflows/build-mssql.yml b/.github/workflows/build-mssql.yml new file mode 100644 index 0000000..8686205 --- /dev/null +++ b/.github/workflows/build-mssql.yml @@ -0,0 +1,55 @@ +on: + pull_request: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + + push: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + +name: build-mssql + +jobs: + mssql: + name: SQL Server tests. + uses: php-forge/actions/.github/workflows/phpunit-database.yml@main + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + concurrency-group: mssql-${{ github.ref }} + database-env: | + { + "ACCEPT_EULA": "Y", + "SA_PASSWORD": "YourStrong!Passw0rd", + "MSSQL_PID": "Developer" + } + database-health-cmd: "/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" + database-health-retries: 5 + database-image: mcr.microsoft.com/mssql/server + database-port: 1433 + database-type: mssql + database-versions: '["2022-latest"]' + enable-concurrency: true + extensions: pdo, pdo_sqlsrv, sqlsrv + os: '["ubuntu-latest"]' + php-version: '["8.4"]' + phpunit-group: mssql + setup-commands: | + # Wait for SQL Server to be fully ready + sleep 15 + + # Create test database + docker exec -i database /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U SA -P 'YourStrong!Passw0rd' -Q " + IF NOT EXISTS (SELECT name FROM sys.databases WHERE name = 'yiitest') + BEGIN + CREATE DATABASE yiitest; + END + " diff --git a/tests/mssql/CacheManagementTest.php b/tests/mssql/CacheManagementTest.php new file mode 100644 index 0000000..7f4c2d8 --- /dev/null +++ b/tests/mssql/CacheManagementTest.php @@ -0,0 +1,17 @@ + Date: Sun, 6 Jul 2025 09:14:15 -0400 Subject: [PATCH 20/22] feat: add installation command for Microsoft ODBC Driver in `SQLServer` build workflow. --- .github/workflows/build-mssql.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-mssql.yml b/.github/workflows/build-mssql.yml index 8686205..95c3a02 100644 --- a/.github/workflows/build-mssql.yml +++ b/.github/workflows/build-mssql.yml @@ -43,6 +43,9 @@ jobs: php-version: '["8.4"]' phpunit-group: mssql setup-commands: | + # Install Microsoft ODBC Driver for SQL Server + sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 + # Wait for SQL Server to be fully ready sleep 15 From 6321cb8da53c34a41ae1827603528c1240404d7b Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 6 Jul 2025 09:18:14 -0400 Subject: [PATCH 21/22] fix: reorder `username` and `password` properties for consistency across `MSSQL` test classes. --- tests/mssql/CacheManagementTest.php | 4 ++-- tests/mssql/ExceptionHandlingTest.php | 4 ++-- tests/mssql/ExtensibilityTest.php | 4 ++-- tests/mssql/NodeAppendTest.php | 4 ++-- tests/mssql/NodeDeleteTest.php | 4 ++-- tests/mssql/NodeInsertTest.php | 4 ++-- tests/mssql/NodePrependTest.php | 4 ++-- tests/mssql/NodeStateTest.php | 4 ++-- tests/mssql/QueryBehaviorTest.php | 4 ++-- tests/mssql/TreeTraversalTest.php | 4 ++-- tests/mssql/ValidationAndStructureTest.php | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/mssql/CacheManagementTest.php b/tests/mssql/CacheManagementTest.php index 7f4c2d8..804feb0 100644 --- a/tests/mssql/CacheManagementTest.php +++ b/tests/mssql/CacheManagementTest.php @@ -12,6 +12,6 @@ final class CacheManagementTest extends AbstractCacheManagement { protected string $driverName = 'sqlsrv'; protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - protected string $password = 'SA'; - protected string $username = 'YourStrong!Passw0rd'; + protected string $password = 'YourStrong!Passw0rd'; + protected string $username = 'SA'; } diff --git a/tests/mssql/ExceptionHandlingTest.php b/tests/mssql/ExceptionHandlingTest.php index eee39f3..7c35ba3 100644 --- a/tests/mssql/ExceptionHandlingTest.php +++ b/tests/mssql/ExceptionHandlingTest.php @@ -12,6 +12,6 @@ final class ExceptionHandlingTest extends AbstractExceptionHandling { protected string $driverName = 'sqlsrv'; protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - protected string $password = 'SA'; - protected string $username = 'YourStrong!Passw0rd'; + protected string $password = 'YourStrong!Passw0rd'; + protected string $username = 'SA'; } diff --git a/tests/mssql/ExtensibilityTest.php b/tests/mssql/ExtensibilityTest.php index bc753b3..25b010c 100644 --- a/tests/mssql/ExtensibilityTest.php +++ b/tests/mssql/ExtensibilityTest.php @@ -12,6 +12,6 @@ final class ExtensibilityTest extends AbstractExtensibility { protected string $driverName = 'sqlsrv'; protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - protected string $password = 'SA'; - protected string $username = 'YourStrong!Passw0rd'; + protected string $password = 'YourStrong!Passw0rd'; + protected string $username = 'SA'; } diff --git a/tests/mssql/NodeAppendTest.php b/tests/mssql/NodeAppendTest.php index dddd4d6..fad8db8 100644 --- a/tests/mssql/NodeAppendTest.php +++ b/tests/mssql/NodeAppendTest.php @@ -12,6 +12,6 @@ final class NodeAppendTest extends AbstractNodeAppend { protected string $driverName = 'sqlsrv'; protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - protected string $password = 'SA'; - protected string $username = 'YourStrong!Passw0rd'; + protected string $password = 'YourStrong!Passw0rd'; + protected string $username = 'SA'; } diff --git a/tests/mssql/NodeDeleteTest.php b/tests/mssql/NodeDeleteTest.php index d5a6f3b..9586a8e 100644 --- a/tests/mssql/NodeDeleteTest.php +++ b/tests/mssql/NodeDeleteTest.php @@ -12,6 +12,6 @@ final class NodeDeleteTest extends AbstractNodeDelete { protected string $driverName = 'sqlsrv'; protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - protected string $password = 'SA'; - protected string $username = 'YourStrong!Passw0rd'; + protected string $password = 'YourStrong!Passw0rd'; + protected string $username = 'SA'; } diff --git a/tests/mssql/NodeInsertTest.php b/tests/mssql/NodeInsertTest.php index f2cc283..3cf7399 100644 --- a/tests/mssql/NodeInsertTest.php +++ b/tests/mssql/NodeInsertTest.php @@ -12,6 +12,6 @@ final class NodeInsertTest extends AbstractNodeInsert { protected string $driverName = 'sqlsrv'; protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - protected string $password = 'SA'; - protected string $username = 'YourStrong!Passw0rd'; + protected string $password = 'YourStrong!Passw0rd'; + protected string $username = 'SA'; } diff --git a/tests/mssql/NodePrependTest.php b/tests/mssql/NodePrependTest.php index 58aa4c7..6e26632 100644 --- a/tests/mssql/NodePrependTest.php +++ b/tests/mssql/NodePrependTest.php @@ -12,6 +12,6 @@ final class NodePrependTest extends AbstractNodePrepend { protected string $driverName = 'sqlsrv'; protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - protected string $password = 'SA'; - protected string $username = 'YourStrong!Passw0rd'; + protected string $password = 'YourStrong!Passw0rd'; + protected string $username = 'SA'; } diff --git a/tests/mssql/NodeStateTest.php b/tests/mssql/NodeStateTest.php index f1697b6..0a5a862 100644 --- a/tests/mssql/NodeStateTest.php +++ b/tests/mssql/NodeStateTest.php @@ -12,6 +12,6 @@ final class NodeStateTest extends AbstractNodeState { protected string $driverName = 'sqlsrv'; protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - protected string $password = 'SA'; - protected string $username = 'YourStrong!Passw0rd'; + protected string $password = 'YourStrong!Passw0rd'; + protected string $username = 'SA'; } diff --git a/tests/mssql/QueryBehaviorTest.php b/tests/mssql/QueryBehaviorTest.php index eda5fd8..c6c47b3 100644 --- a/tests/mssql/QueryBehaviorTest.php +++ b/tests/mssql/QueryBehaviorTest.php @@ -12,6 +12,6 @@ final class QueryBehaviorTest extends AbstractQueryBehavior { protected string $driverName = 'sqlsrv'; protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - protected string $password = 'SA'; - protected string $username = 'YourStrong!Passw0rd'; + protected string $password = 'YourStrong!Passw0rd'; + protected string $username = 'SA'; } diff --git a/tests/mssql/TreeTraversalTest.php b/tests/mssql/TreeTraversalTest.php index 5c7f046..b53c8ad 100644 --- a/tests/mssql/TreeTraversalTest.php +++ b/tests/mssql/TreeTraversalTest.php @@ -12,6 +12,6 @@ final class TreeTraversalTest extends AbstractTreeTraversal { protected string $driverName = 'sqlsrv'; protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - protected string $password = 'SA'; - protected string $username = 'YourStrong!Passw0rd'; + protected string $password = 'YourStrong!Passw0rd'; + protected string $username = 'SA'; } diff --git a/tests/mssql/ValidationAndStructureTest.php b/tests/mssql/ValidationAndStructureTest.php index 2aac906..f99081f 100644 --- a/tests/mssql/ValidationAndStructureTest.php +++ b/tests/mssql/ValidationAndStructureTest.php @@ -12,6 +12,6 @@ final class ValidationAndStructureTest extends AbstractValidationAndStructure { protected string $driverName = 'sqlsrv'; protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - protected string $password = 'SA'; - protected string $username = 'YourStrong!Passw0rd'; + protected string $password = 'YourStrong!Passw0rd'; + protected string $username = 'SA'; } From cf299b0bf87a349ebd31f586d471805e00c0f888 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 6 Jul 2025 09:24:17 -0400 Subject: [PATCH 22/22] fix: enhance root node insertion logic to check for existing nodes with left attribute. --- src/NestedSetsBehavior.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/NestedSetsBehavior.php b/src/NestedSetsBehavior.php index 7becb13..211d7d9 100644 --- a/src/NestedSetsBehavior.php +++ b/src/NestedSetsBehavior.php @@ -1070,7 +1070,10 @@ protected function beforeInsertNode(int $value, int $depth): void */ protected function beforeInsertRootNode(): void { - if ($this->treeAttribute === false && $this->getOwner()::find()->roots()->exists()) { + if ( + $this->treeAttribute === false && + $this->getOwner()::find()->andWhere([$this->leftAttribute => 1])->exists() + ) { throw new Exception('Can not create more than one root when "treeAttribute" is false.'); }