diff --git a/.github/workflows/build-mssql.yml b/.github/workflows/build-mssql.yml index 95c3a02..623c116 100644 --- a/.github/workflows/build-mssql.yml +++ b/.github/workflows/build-mssql.yml @@ -29,7 +29,7 @@ jobs: { "ACCEPT_EULA": "Y", "SA_PASSWORD": "YourStrong!Passw0rd", - "MSSQL_PID": "Developer" + "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 diff --git a/.github/workflows/build-oracle.yml b/.github/workflows/build-oracle.yml index 79dd54c..74c6092 100644 --- a/.github/workflows/build-oracle.yml +++ b/.github/workflows/build-oracle.yml @@ -28,7 +28,7 @@ jobs: database-env: | { "ORACLE_DATABASE": "yiitest", - "ORACLE_PASSWORD": "root" + "ORACLE_PASSWORD": "root", } database-health-cmd: "healthcheck.sh" database-health-retries: 10 diff --git a/.github/workflows/build-pgsql.yml b/.github/workflows/build-pgsql.yml index 45682bd..ec67222 100644 --- a/.github/workflows/build-pgsql.yml +++ b/.github/workflows/build-pgsql.yml @@ -29,7 +29,7 @@ jobs: { "POSTGRES_DB": "yiitest", "POSTGRES_USER": "root", - "POSTGRES_PASSWORD": "root" + "POSTGRES_PASSWORD": "root", } database-health-cmd: "pg_isready -U postgres" database-health-retries: 3 diff --git a/ecs.php b/ecs.php index b939d59..dc0eeac 100644 --- a/ecs.php +++ b/ecs.php @@ -26,6 +26,7 @@ 'constant_public', 'constant_protected', 'constant_private', + 'case', 'property_public', 'property_protected', 'property_private', diff --git a/tests/TestCase.php b/tests/TestCase.php index bac0ea2..c43419c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -40,12 +40,12 @@ class TestCase extends \PHPUnit\Framework\TestCase { use SchemaBuilderTrait; - protected string $driverName = 'sqlite'; - protected string|null $dsn = null; + /** + * @phpstan-var string[] + */ + protected array $connection = []; protected string $fixtureDirectory = __DIR__ . '/support/data/'; - protected string $password = ''; - protected string $username = ''; protected function setUp(): void { @@ -341,12 +341,7 @@ protected function mockConsoleApplication(): void 'id' => 'testapp', 'basePath' => dirname(__DIR__), 'components' => [ - 'db' => [ - 'class' => Connection::class, - 'dsn' => $this->dsn !== null ? $this->dsn : 'sqlite::memory:', - 'password' => $this->password, - 'username' => $this->username, - ], + 'db' => $this->connection, ], ], ); @@ -361,7 +356,7 @@ protected function mockConsoleApplication(): void */ protected function replaceQuotes(string $sql): string { - return match ($this->driverName) { + return match ($this->getDb()->driverName) { 'mysql', 'sqlite' => str_replace( ['[[', ']]'], '`', diff --git a/tests/mssql/CacheManagementTest.php b/tests/mssql/CacheManagementTest.php index 22678d6..dc557ea 100644 --- a/tests/mssql/CacheManagementTest.php +++ b/tests/mssql/CacheManagementTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractCacheManagement; -use yii2\extensions\nestedsets\tests\support\MSSQLConnection; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; /** * Test suite for cache invalidation in nested sets tree behaviors using SQL Server. @@ -34,10 +34,7 @@ final class CacheManagementTest extends AbstractCacheManagement { protected function setUp(): void { - $this->driverName = MSSQLConnection::DRIVER_NAME->value; - $this->dsn = MSSQLConnection::DSN->value; - $this->password = MSSQLConnection::PASSWORD->value; - $this->username = MSSQLConnection::USERNAME->value; + $this->connection = DatabaseConnection::MSSQL->connection(); parent::setUp(); } diff --git a/tests/mssql/ExceptionHandlingTest.php b/tests/mssql/ExceptionHandlingTest.php index 1959560..6f5886c 100644 --- a/tests/mssql/ExceptionHandlingTest.php +++ b/tests/mssql/ExceptionHandlingTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExceptionHandling; -use yii2\extensions\nestedsets\tests\support\MSSQLConnection; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; /** * Test suite for exception handling in nested sets tree behaviors using SQL Server. @@ -34,10 +34,7 @@ final class ExceptionHandlingTest extends AbstractExceptionHandling { protected function setUp(): void { - $this->driverName = MSSQLConnection::DRIVER_NAME->value; - $this->dsn = MSSQLConnection::DSN->value; - $this->password = MSSQLConnection::PASSWORD->value; - $this->username = MSSQLConnection::USERNAME->value; + $this->connection = DatabaseConnection::MSSQL->connection(); parent::setUp(); } diff --git a/tests/mssql/ExtensibilityTest.php b/tests/mssql/ExtensibilityTest.php index 19a05c1..2351875 100644 --- a/tests/mssql/ExtensibilityTest.php +++ b/tests/mssql/ExtensibilityTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExtensibility; -use yii2\extensions\nestedsets\tests\support\MSSQLConnection; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; /** * Test suite for extensibility in nested sets tree behaviors using SQL Server. @@ -34,10 +34,7 @@ final class ExtensibilityTest extends AbstractExtensibility { protected function setUp(): void { - $this->driverName = MSSQLConnection::DRIVER_NAME->value; - $this->dsn = MSSQLConnection::DSN->value; - $this->password = MSSQLConnection::PASSWORD->value; - $this->username = MSSQLConnection::USERNAME->value; + $this->connection = DatabaseConnection::MSSQL->connection(); parent::setUp(); } diff --git a/tests/mssql/NodeAppendTest.php b/tests/mssql/NodeAppendTest.php index 43b2a2f..0cf69bd 100644 --- a/tests/mssql/NodeAppendTest.php +++ b/tests/mssql/NodeAppendTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeAppend; -use yii2\extensions\nestedsets\tests\support\MSSQLConnection; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; /** * Test suite for node append and root promotion in nested sets tree behaviors using SQL Server. @@ -37,10 +37,7 @@ final class NodeAppendTest extends AbstractNodeAppend { protected function setUp(): void { - $this->driverName = MSSQLConnection::DRIVER_NAME->value; - $this->dsn = MSSQLConnection::DSN->value; - $this->password = MSSQLConnection::PASSWORD->value; - $this->username = MSSQLConnection::USERNAME->value; + $this->connection = DatabaseConnection::MSSQL->connection(); parent::setUp(); } diff --git a/tests/mssql/NodeDeleteTest.php b/tests/mssql/NodeDeleteTest.php index b8f7b92..acf802e 100644 --- a/tests/mssql/NodeDeleteTest.php +++ b/tests/mssql/NodeDeleteTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeDelete; -use yii2\extensions\nestedsets\tests\support\MSSQLConnection; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; /** * Test suite for node deletion in nested sets tree behaviors using SQL Server. @@ -38,10 +38,7 @@ final class NodeDeleteTest extends AbstractNodeDelete { protected function setUp(): void { - $this->driverName = MSSQLConnection::DRIVER_NAME->value; - $this->dsn = MSSQLConnection::DSN->value; - $this->password = MSSQLConnection::PASSWORD->value; - $this->username = MSSQLConnection::USERNAME->value; + $this->connection = DatabaseConnection::MSSQL->connection(); parent::setUp(); } diff --git a/tests/mssql/NodeInsertTest.php b/tests/mssql/NodeInsertTest.php index fc3c064..9f70771 100644 --- a/tests/mssql/NodeInsertTest.php +++ b/tests/mssql/NodeInsertTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeInsert; -use yii2\extensions\nestedsets\tests\support\MSSQLConnection; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; /** * Test suite for node insertion in nested sets tree behaviors using SQL Server. @@ -36,10 +36,7 @@ final class NodeInsertTest extends AbstractNodeInsert { protected function setUp(): void { - $this->driverName = MSSQLConnection::DRIVER_NAME->value; - $this->dsn = MSSQLConnection::DSN->value; - $this->password = MSSQLConnection::PASSWORD->value; - $this->username = MSSQLConnection::USERNAME->value; + $this->connection = DatabaseConnection::MSSQL->connection(); parent::setUp(); } diff --git a/tests/mssql/NodePrependTest.php b/tests/mssql/NodePrependTest.php index ccd4250..b9387bd 100644 --- a/tests/mssql/NodePrependTest.php +++ b/tests/mssql/NodePrependTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodePrepend; -use yii2\extensions\nestedsets\tests\support\MSSQLConnection; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; /** * Test suite for node prepend operations in nested sets tree behaviors using SQL Server. @@ -35,10 +35,7 @@ final class NodePrependTest extends AbstractNodePrepend { protected function setUp(): void { - $this->driverName = MSSQLConnection::DRIVER_NAME->value; - $this->dsn = MSSQLConnection::DSN->value; - $this->password = MSSQLConnection::PASSWORD->value; - $this->username = MSSQLConnection::USERNAME->value; + $this->connection = DatabaseConnection::MSSQL->connection(); parent::setUp(); } diff --git a/tests/mssql/NodeStateTest.php b/tests/mssql/NodeStateTest.php index 9749800..aa584ab 100644 --- a/tests/mssql/NodeStateTest.php +++ b/tests/mssql/NodeStateTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeState; -use yii2\extensions\nestedsets\tests\support\MSSQLConnection; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; /** * Test suite for node state and relationship in nested sets tree behaviors using SQL Server. @@ -34,10 +34,7 @@ final class NodeStateTest extends AbstractNodeState { protected function setUp(): void { - $this->driverName = MSSQLConnection::DRIVER_NAME->value; - $this->dsn = MSSQLConnection::DSN->value; - $this->password = MSSQLConnection::PASSWORD->value; - $this->username = MSSQLConnection::USERNAME->value; + $this->connection = DatabaseConnection::MSSQL->connection(); parent::setUp(); } diff --git a/tests/mssql/QueryBehaviorTest.php b/tests/mssql/QueryBehaviorTest.php index 422eb85..3e642da 100644 --- a/tests/mssql/QueryBehaviorTest.php +++ b/tests/mssql/QueryBehaviorTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractQueryBehavior; -use yii2\extensions\nestedsets\tests\support\MSSQLConnection; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; /** * Test suite for query behavior in nested sets tree behaviors using SQL Server. @@ -36,10 +36,7 @@ final class QueryBehaviorTest extends AbstractQueryBehavior { protected function setUp(): void { - $this->driverName = MSSQLConnection::DRIVER_NAME->value; - $this->dsn = MSSQLConnection::DSN->value; - $this->password = MSSQLConnection::PASSWORD->value; - $this->username = MSSQLConnection::USERNAME->value; + $this->connection = DatabaseConnection::MSSQL->connection(); parent::setUp(); } diff --git a/tests/mssql/TreeTraversalTest.php b/tests/mssql/TreeTraversalTest.php index 5cfefee..e03dd0e 100644 --- a/tests/mssql/TreeTraversalTest.php +++ b/tests/mssql/TreeTraversalTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractTreeTraversal; -use yii2\extensions\nestedsets\tests\support\MSSQLConnection; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; /** * Test suite for tree traversal and relationship methods in nested sets tree behaviors using SQL Server. @@ -34,10 +34,7 @@ final class TreeTraversalTest extends AbstractTreeTraversal { protected function setUp(): void { - $this->driverName = MSSQLConnection::DRIVER_NAME->value; - $this->dsn = MSSQLConnection::DSN->value; - $this->password = MSSQLConnection::PASSWORD->value; - $this->username = MSSQLConnection::USERNAME->value; + $this->connection = DatabaseConnection::MSSQL->connection(); parent::setUp(); } diff --git a/tests/mssql/ValidationAndStructureTest.php b/tests/mssql/ValidationAndStructureTest.php index 233c938..3fce2f8 100644 --- a/tests/mssql/ValidationAndStructureTest.php +++ b/tests/mssql/ValidationAndStructureTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractValidationAndStructure; -use yii2\extensions\nestedsets\tests\support\MSSQLConnection; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; /** * Test suite for validation and structural integrity in nested sets tree behaviors using SQL Server. @@ -35,10 +35,7 @@ final class ValidationAndStructureTest extends AbstractValidationAndStructure { protected function setUp(): void { - $this->driverName = MSSQLConnection::DRIVER_NAME->value; - $this->dsn = MSSQLConnection::DSN->value; - $this->password = MSSQLConnection::PASSWORD->value; - $this->username = MSSQLConnection::USERNAME->value; + $this->connection = DatabaseConnection::MSSQL->connection(); parent::setUp(); } diff --git a/tests/mysql/CacheManagementTest.php b/tests/mysql/CacheManagementTest.php index 1f5c2b4..b2128ed 100644 --- a/tests/mysql/CacheManagementTest.php +++ b/tests/mysql/CacheManagementTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractCacheManagement; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('mysql')] final class CacheManagementTest extends AbstractCacheManagement { - 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'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::MYSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/mysql/ExceptionHandlingTest.php b/tests/mysql/ExceptionHandlingTest.php index 6682dfb..b3fae5b 100644 --- a/tests/mysql/ExceptionHandlingTest.php +++ b/tests/mysql/ExceptionHandlingTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExceptionHandling; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('mysql')] final class ExceptionHandlingTest extends AbstractExceptionHandling { - 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'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::MYSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/mysql/ExtensibilityTest.php b/tests/mysql/ExtensibilityTest.php index ae2114a..e6cb273 100644 --- a/tests/mysql/ExtensibilityTest.php +++ b/tests/mysql/ExtensibilityTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExtensibility; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('mysql')] final class ExtensibilityTest extends AbstractExtensibility { - 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'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::MYSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/mysql/MutationTest.php b/tests/mysql/MutationTest.php index 53eac97..61766dd 100644 --- a/tests/mysql/MutationTest.php +++ b/tests/mysql/MutationTest.php @@ -5,16 +5,19 @@ namespace yii2\extensions\nestedsets\tests\mysql; use PHPUnit\Framework\Attributes\Group; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; use yii2\extensions\nestedsets\tests\support\model\MultipleTree; use yii2\extensions\nestedsets\tests\TestCase; #[Group('mutation')] final class MutationTest extends TestCase { - 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'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::MYSQL->connection(); + + parent::setUp(); + } public function testLeavesMethodRequiresLeftAttributeOrderingForConsistentResults(): void { diff --git a/tests/mysql/NodeAppendTest.php b/tests/mysql/NodeAppendTest.php index a2f885c..ffd69b7 100644 --- a/tests/mysql/NodeAppendTest.php +++ b/tests/mysql/NodeAppendTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeAppend; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('mysql')] final class NodeAppendTest extends AbstractNodeAppend { - 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'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::MYSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/mysql/NodeDeleteTest.php b/tests/mysql/NodeDeleteTest.php index f1c1b89..61e3e02 100644 --- a/tests/mysql/NodeDeleteTest.php +++ b/tests/mysql/NodeDeleteTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeDelete; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('mysql')] final class NodeDeleteTest extends AbstractNodeDelete { - 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'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::MYSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/mysql/NodeInsertTest.php b/tests/mysql/NodeInsertTest.php index 1691012..3c87770 100644 --- a/tests/mysql/NodeInsertTest.php +++ b/tests/mysql/NodeInsertTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeInsert; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('mysql')] final class NodeInsertTest extends AbstractNodeInsert { - 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'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::MYSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/mysql/NodePrependTest.php b/tests/mysql/NodePrependTest.php index 656995e..1d27015 100644 --- a/tests/mysql/NodePrependTest.php +++ b/tests/mysql/NodePrependTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodePrepend; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('mysql')] final class NodePrependTest extends AbstractNodePrepend { - 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'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::MYSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/mysql/NodeStateTest.php b/tests/mysql/NodeStateTest.php index 9fd640d..3597db5 100644 --- a/tests/mysql/NodeStateTest.php +++ b/tests/mysql/NodeStateTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeState; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('mysql')] final class NodeStateTest extends AbstractNodeState { - 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'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::MYSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/mysql/QueryBehaviorTest.php b/tests/mysql/QueryBehaviorTest.php index 1abc4ff..f45195d 100644 --- a/tests/mysql/QueryBehaviorTest.php +++ b/tests/mysql/QueryBehaviorTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractQueryBehavior; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('mysql')] final class QueryBehaviorTest extends AbstractQueryBehavior { - 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'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::MYSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/mysql/TreeTraversalTest.php b/tests/mysql/TreeTraversalTest.php index 562d6b3..6cdaefe 100644 --- a/tests/mysql/TreeTraversalTest.php +++ b/tests/mysql/TreeTraversalTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractTreeTraversal; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('mysql')] final class TreeTraversalTest extends AbstractTreeTraversal { - 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'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::MYSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/mysql/ValidationAndStructureTest.php b/tests/mysql/ValidationAndStructureTest.php index dae7c44..ce027f3 100644 --- a/tests/mysql/ValidationAndStructureTest.php +++ b/tests/mysql/ValidationAndStructureTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractValidationAndStructure; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('mysql')] final class ValidationAndStructureTest extends AbstractValidationAndStructure { - 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'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::MYSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/oracle/CacheManagementTest.php b/tests/oracle/CacheManagementTest.php index 96949d7..b6c5d4d 100644 --- a/tests/oracle/CacheManagementTest.php +++ b/tests/oracle/CacheManagementTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractCacheManagement; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('oci')] final class CacheManagementTest extends AbstractCacheManagement { - protected string $driverName = 'oci'; - protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;'; - protected string $password = 'root'; - protected string $username = 'system'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::ORACLE->connection(); + + parent::setUp(); + } } diff --git a/tests/oracle/ExceptionHandlingTest.php b/tests/oracle/ExceptionHandlingTest.php index 15b29a1..f073036 100644 --- a/tests/oracle/ExceptionHandlingTest.php +++ b/tests/oracle/ExceptionHandlingTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExceptionHandling; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('oci')] final class ExceptionHandlingTest extends AbstractExceptionHandling { - protected string $driverName = 'oci'; - protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;'; - protected string $password = 'root'; - protected string $username = 'system'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::ORACLE->connection(); + + parent::setUp(); + } } diff --git a/tests/oracle/ExtensibilityTest.php b/tests/oracle/ExtensibilityTest.php index 7df7e2f..aa43742 100644 --- a/tests/oracle/ExtensibilityTest.php +++ b/tests/oracle/ExtensibilityTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExtensibility; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('oci')] final class ExtensibilityTest extends AbstractExtensibility { - protected string $driverName = 'oci'; - protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;'; - protected string $password = 'root'; - protected string $username = 'system'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::ORACLE->connection(); + + parent::setUp(); + } } diff --git a/tests/oracle/NodeAppendTest.php b/tests/oracle/NodeAppendTest.php index a8c5c0d..20632d2 100644 --- a/tests/oracle/NodeAppendTest.php +++ b/tests/oracle/NodeAppendTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeAppend; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('oci')] final class NodeAppendTest extends AbstractNodeAppend { - protected string $driverName = 'oci'; - protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;'; - protected string $password = 'root'; - protected string $username = 'system'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::ORACLE->connection(); + + parent::setUp(); + } } diff --git a/tests/oracle/NodeDeleteTest.php b/tests/oracle/NodeDeleteTest.php index 973c548..3b6e94d 100644 --- a/tests/oracle/NodeDeleteTest.php +++ b/tests/oracle/NodeDeleteTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeDelete; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('oci')] final class NodeDeleteTest extends AbstractNodeDelete { - protected string $driverName = 'oci'; - protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;'; - protected string $password = 'root'; - protected string $username = 'system'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::ORACLE->connection(); + + parent::setUp(); + } } diff --git a/tests/oracle/NodeInsertTest.php b/tests/oracle/NodeInsertTest.php index 88b73f8..4360ff6 100644 --- a/tests/oracle/NodeInsertTest.php +++ b/tests/oracle/NodeInsertTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeInsert; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('oci')] final class NodeInsertTest extends AbstractNodeInsert { - protected string $driverName = 'oci'; - protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;'; - protected string $password = 'root'; - protected string $username = 'system'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::ORACLE->connection(); + + parent::setUp(); + } } diff --git a/tests/oracle/NodePrependTest.php b/tests/oracle/NodePrependTest.php index a205529..860aca9 100644 --- a/tests/oracle/NodePrependTest.php +++ b/tests/oracle/NodePrependTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodePrepend; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('oci')] final class NodePrependTest extends AbstractNodePrepend { - protected string $driverName = 'oci'; - protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;'; - protected string $password = 'root'; - protected string $username = 'system'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::ORACLE->connection(); + + parent::setUp(); + } } diff --git a/tests/oracle/NodeStateTest.php b/tests/oracle/NodeStateTest.php index 70a9dcc..7125bb1 100644 --- a/tests/oracle/NodeStateTest.php +++ b/tests/oracle/NodeStateTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeState; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('oci')] final class NodeStateTest extends AbstractNodeState { - protected string $driverName = 'oci'; - protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;'; - protected string $password = 'root'; - protected string $username = 'system'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::ORACLE->connection(); + + parent::setUp(); + } } diff --git a/tests/oracle/QueryBehaviorTest.php b/tests/oracle/QueryBehaviorTest.php index 048dcb8..9650905 100644 --- a/tests/oracle/QueryBehaviorTest.php +++ b/tests/oracle/QueryBehaviorTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractQueryBehavior; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('oci')] final class QueryBehaviorTest extends AbstractQueryBehavior { - protected string $driverName = 'oci'; - protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;'; - protected string $password = 'root'; - protected string $username = 'system'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::ORACLE->connection(); + + parent::setUp(); + } } diff --git a/tests/oracle/TreeTraversalTest.php b/tests/oracle/TreeTraversalTest.php index 0f511c4..93edb86 100644 --- a/tests/oracle/TreeTraversalTest.php +++ b/tests/oracle/TreeTraversalTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractTreeTraversal; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('oci')] final class TreeTraversalTest extends AbstractTreeTraversal { - protected string $driverName = 'oci'; - protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;'; - protected string $password = 'root'; - protected string $username = 'system'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::ORACLE->connection(); + + parent::setUp(); + } } diff --git a/tests/oracle/ValidationAndStructureTest.php b/tests/oracle/ValidationAndStructureTest.php index 4afaf84..7e6950f 100644 --- a/tests/oracle/ValidationAndStructureTest.php +++ b/tests/oracle/ValidationAndStructureTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractValidationAndStructure; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('oci')] final class ValidationAndStructureTest extends AbstractValidationAndStructure { - protected string $driverName = 'oci'; - protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;'; - protected string $password = 'root'; - protected string $username = 'system'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::ORACLE->connection(); + + parent::setUp(); + } } diff --git a/tests/pgsql/CacheManagementTest.php b/tests/pgsql/CacheManagementTest.php index 0578883..16934e2 100644 --- a/tests/pgsql/CacheManagementTest.php +++ b/tests/pgsql/CacheManagementTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractCacheManagement; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('pgsql')] final class CacheManagementTest extends AbstractCacheManagement { - protected string $driverName = 'pgsql'; - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; - protected string $password = 'root'; - protected string $username = 'root'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::PGSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/pgsql/ExceptionHandlingTest.php b/tests/pgsql/ExceptionHandlingTest.php index 293f462..1818b6d 100644 --- a/tests/pgsql/ExceptionHandlingTest.php +++ b/tests/pgsql/ExceptionHandlingTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExceptionHandling; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('pgsql')] final class ExceptionHandlingTest extends AbstractExceptionHandling { - protected string $driverName = 'pgsql'; - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; - protected string $password = 'root'; - protected string $username = 'root'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::PGSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/pgsql/ExtensibilityTest.php b/tests/pgsql/ExtensibilityTest.php index b0242c1..b624436 100644 --- a/tests/pgsql/ExtensibilityTest.php +++ b/tests/pgsql/ExtensibilityTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExtensibility; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('pgsql')] final class ExtensibilityTest extends AbstractExtensibility { - protected string $driverName = 'pgsql'; - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; - protected string $password = 'root'; - protected string $username = 'root'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::PGSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/pgsql/MutationTest.php b/tests/pgsql/MutationTest.php index a6ded69..8aa5b63 100644 --- a/tests/pgsql/MutationTest.php +++ b/tests/pgsql/MutationTest.php @@ -5,15 +5,18 @@ namespace yii2\extensions\nestedsets\tests\pgsql; use PHPUnit\Framework\Attributes\Group; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; use yii2\extensions\nestedsets\tests\TestCase; #[Group('mutation')] final class MutationTest extends TestCase { - protected string $driverName = 'pgsql'; - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; - protected string $password = 'root'; - protected string $username = 'root'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::PGSQL->connection(); + + parent::setUp(); + } public function testChildrenMethodRequiresOrderByForCorrectTreeTraversal(): void { diff --git a/tests/pgsql/NodeAppendTest.php b/tests/pgsql/NodeAppendTest.php index 742ddab..1055210 100644 --- a/tests/pgsql/NodeAppendTest.php +++ b/tests/pgsql/NodeAppendTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeAppend; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('pgsql')] final class NodeAppendTest extends AbstractNodeAppend { - protected string $driverName = 'pgsql'; - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; - protected string $password = 'root'; - protected string $username = 'root'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::PGSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/pgsql/NodeDeleteTest.php b/tests/pgsql/NodeDeleteTest.php index 521d189..21b4cff 100644 --- a/tests/pgsql/NodeDeleteTest.php +++ b/tests/pgsql/NodeDeleteTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeDelete; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('pgsql')] final class NodeDeleteTest extends AbstractNodeDelete { - protected string $driverName = 'pgsql'; - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; - protected string $password = 'root'; - protected string $username = 'root'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::PGSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/pgsql/NodeInsertTest.php b/tests/pgsql/NodeInsertTest.php index 3e1fcac..f1ff34c 100644 --- a/tests/pgsql/NodeInsertTest.php +++ b/tests/pgsql/NodeInsertTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeInsert; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('pgsql')] final class NodeInsertTest extends AbstractNodeInsert { - protected string $driverName = 'pgsql'; - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; - protected string $password = 'root'; - protected string $username = 'root'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::PGSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/pgsql/NodePrependTest.php b/tests/pgsql/NodePrependTest.php index d2b56c1..3a90818 100644 --- a/tests/pgsql/NodePrependTest.php +++ b/tests/pgsql/NodePrependTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodePrepend; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('pgsql')] final class NodePrependTest extends AbstractNodePrepend { - protected string $driverName = 'pgsql'; - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; - protected string $password = 'root'; - protected string $username = 'root'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::PGSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/pgsql/NodeStateTest.php b/tests/pgsql/NodeStateTest.php index c49dedc..4f786db 100644 --- a/tests/pgsql/NodeStateTest.php +++ b/tests/pgsql/NodeStateTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeState; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('pgsql')] final class NodeStateTest extends AbstractNodeState { - protected string $driverName = 'pgsql'; - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; - protected string $password = 'root'; - protected string $username = 'root'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::PGSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/pgsql/QueryBehaviorTest.php b/tests/pgsql/QueryBehaviorTest.php index feb1682..274f101 100644 --- a/tests/pgsql/QueryBehaviorTest.php +++ b/tests/pgsql/QueryBehaviorTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractQueryBehavior; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('pgsql')] final class QueryBehaviorTest extends AbstractQueryBehavior { - protected string $driverName = 'pgsql'; - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; - protected string $password = 'root'; - protected string $username = 'root'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::PGSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/pgsql/TreeTraversalTest.php b/tests/pgsql/TreeTraversalTest.php index fc1c3b7..4f4f04e 100644 --- a/tests/pgsql/TreeTraversalTest.php +++ b/tests/pgsql/TreeTraversalTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractTreeTraversal; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('pgsql')] final class TreeTraversalTest extends AbstractTreeTraversal { - protected string $driverName = 'pgsql'; - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; - protected string $password = 'root'; - protected string $username = 'root'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::PGSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/pgsql/ValidationAndStructureTest.php b/tests/pgsql/ValidationAndStructureTest.php index e419869..a172193 100644 --- a/tests/pgsql/ValidationAndStructureTest.php +++ b/tests/pgsql/ValidationAndStructureTest.php @@ -6,12 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractValidationAndStructure; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('pgsql')] final class ValidationAndStructureTest extends AbstractValidationAndStructure { - protected string $driverName = 'pgsql'; - protected string|null $dsn = 'pgsql:host=localhost;dbname=yiitest;port=5432;'; - protected string $password = 'root'; - protected string $username = 'root'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::PGSQL->connection(); + + parent::setUp(); + } } diff --git a/tests/sqlite/CacheManagementTest.php b/tests/sqlite/CacheManagementTest.php index 40ddc1c..47238b4 100644 --- a/tests/sqlite/CacheManagementTest.php +++ b/tests/sqlite/CacheManagementTest.php @@ -6,9 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractCacheManagement; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('sqlite')] final class CacheManagementTest extends AbstractCacheManagement { - protected string|null $dsn = 'sqlite::memory:'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::SQLITE->connection(); + + parent::setUp(); + } } diff --git a/tests/sqlite/ExceptionHandlingTest.php b/tests/sqlite/ExceptionHandlingTest.php index 9cfda48..e9794ff 100644 --- a/tests/sqlite/ExceptionHandlingTest.php +++ b/tests/sqlite/ExceptionHandlingTest.php @@ -6,9 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExceptionHandling; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('sqlite')] final class ExceptionHandlingTest extends AbstractExceptionHandling { - protected string|null $dsn = 'sqlite::memory:'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::SQLITE->connection(); + + parent::setUp(); + } } diff --git a/tests/sqlite/ExtensibilityTest.php b/tests/sqlite/ExtensibilityTest.php index a898195..9f83a89 100644 --- a/tests/sqlite/ExtensibilityTest.php +++ b/tests/sqlite/ExtensibilityTest.php @@ -6,9 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExtensibility; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('sqlite')] final class ExtensibilityTest extends AbstractExtensibility { - protected string|null $dsn = 'sqlite::memory:'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::SQLITE->connection(); + + parent::setUp(); + } } diff --git a/tests/sqlite/NodeAppendTest.php b/tests/sqlite/NodeAppendTest.php index c8a8721..0a3fa22 100644 --- a/tests/sqlite/NodeAppendTest.php +++ b/tests/sqlite/NodeAppendTest.php @@ -6,9 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeAppend; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('sqlite')] final class NodeAppendTest extends AbstractNodeAppend { - protected string|null $dsn = 'sqlite::memory:'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::SQLITE->connection(); + + parent::setUp(); + } } diff --git a/tests/sqlite/NodeDeleteTest.php b/tests/sqlite/NodeDeleteTest.php index 227ab6b..03d012b 100644 --- a/tests/sqlite/NodeDeleteTest.php +++ b/tests/sqlite/NodeDeleteTest.php @@ -6,9 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeDelete; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('sqlite')] final class NodeDeleteTest extends AbstractNodeDelete { - protected string|null $dsn = 'sqlite::memory:'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::SQLITE->connection(); + + parent::setUp(); + } } diff --git a/tests/sqlite/NodeInsertTest.php b/tests/sqlite/NodeInsertTest.php index 90cb478..f512054 100644 --- a/tests/sqlite/NodeInsertTest.php +++ b/tests/sqlite/NodeInsertTest.php @@ -6,9 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeInsert; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('sqlite')] final class NodeInsertTest extends AbstractNodeInsert { - protected string|null $dsn = 'sqlite::memory:'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::SQLITE->connection(); + + parent::setUp(); + } } diff --git a/tests/sqlite/NodePrependTest.php b/tests/sqlite/NodePrependTest.php index eb310b1..8898a63 100644 --- a/tests/sqlite/NodePrependTest.php +++ b/tests/sqlite/NodePrependTest.php @@ -6,9 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodePrepend; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('sqlite')] final class NodePrependTest extends AbstractNodePrepend { - protected string|null $dsn = 'sqlite::memory:'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::SQLITE->connection(); + + parent::setUp(); + } } diff --git a/tests/sqlite/NodeStateTest.php b/tests/sqlite/NodeStateTest.php index ff2d74b..f25959c 100644 --- a/tests/sqlite/NodeStateTest.php +++ b/tests/sqlite/NodeStateTest.php @@ -6,9 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeState; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('sqlite')] final class NodeStateTest extends AbstractNodeState { - protected string|null $dsn = 'sqlite::memory:'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::SQLITE->connection(); + + parent::setUp(); + } } diff --git a/tests/sqlite/QueryBehaviorTest.php b/tests/sqlite/QueryBehaviorTest.php index e084f0c..8ab939f 100644 --- a/tests/sqlite/QueryBehaviorTest.php +++ b/tests/sqlite/QueryBehaviorTest.php @@ -6,9 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractQueryBehavior; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('sqlite')] final class QueryBehaviorTest extends AbstractQueryBehavior { - protected string|null $dsn = 'sqlite::memory:'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::SQLITE->connection(); + + parent::setUp(); + } } diff --git a/tests/sqlite/TreeTraversalTest.php b/tests/sqlite/TreeTraversalTest.php index faac023..4a4f52d 100644 --- a/tests/sqlite/TreeTraversalTest.php +++ b/tests/sqlite/TreeTraversalTest.php @@ -6,9 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractTreeTraversal; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('sqlite')] final class TreeTraversalTest extends AbstractTreeTraversal { - protected string|null $dsn = 'sqlite::memory:'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::SQLITE->connection(); + + parent::setUp(); + } } diff --git a/tests/sqlite/ValidationAndStructureTest.php b/tests/sqlite/ValidationAndStructureTest.php index b96a027..138e609 100644 --- a/tests/sqlite/ValidationAndStructureTest.php +++ b/tests/sqlite/ValidationAndStructureTest.php @@ -6,9 +6,15 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractValidationAndStructure; +use yii2\extensions\nestedsets\tests\support\DatabaseConnection; #[Group('sqlite')] final class ValidationAndStructureTest extends AbstractValidationAndStructure { - protected string|null $dsn = 'sqlite::memory:'; + protected function setUp(): void + { + $this->connection = DatabaseConnection::SQLITE->connection(); + + parent::setUp(); + } } diff --git a/tests/support/DatabaseConnection.php b/tests/support/DatabaseConnection.php new file mode 100644 index 0000000..84b4f5c --- /dev/null +++ b/tests/support/DatabaseConnection.php @@ -0,0 +1,109 @@ +connection(); + * ``` + * + * @return array Connection parameters for the selected database driver. + * + * @phpstan-return string[] + */ + public function connection(): array + { + return match ($this) { + self::MSSQL => [ + 'class' => Connection::class, + 'dsn' => 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no', + 'password' => 'YourStrong!Passw0rd', + 'username' => 'SA', + ], + self::MYSQL => [ + 'class' => Connection::class, + 'dsn' => 'mysql:host=127.0.0.1;dbname=yiitest;charset=utf8mb4', + 'password' => 'root', + 'username' => 'root', + ], + self::ORACLE => [ + 'class' => Connection::class, + 'dsn' => 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;', + 'password' => 'root', + 'username' => 'system', + ], + self::PGSQL => [ + 'class' => Connection::class, + 'dsn' => 'pgsql:host=localhost;dbname=yiitest;port=5432;', + 'password' => 'root', + 'username' => 'root', + ], + self::SQLITE => [ + 'class' => Connection::class, + 'dsn' => 'sqlite::memory:', + ], + }; + } +} diff --git a/tests/support/MSSQLConnection.php b/tests/support/MSSQLConnection.php deleted file mode 100644 index 043c77a..0000000 --- a/tests/support/MSSQLConnection.php +++ /dev/null @@ -1,43 +0,0 @@ -