From ff9229efca9b2900f3e329081b42b3e2d6c9f96f Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Tue, 8 Jul 2025 06:53:06 -0400 Subject: [PATCH 1/2] feat: Add comprehensive test suites for `SQLServer` nested sets behavior, covering cache management, exception handling, extensibility, node operations, and validation. --- tests/mssql/CacheManagementTest.php | 36 +++++++++++++++++++ tests/mssql/ExceptionHandlingTest.php | 36 +++++++++++++++++++ tests/mssql/ExtensibilityTest.php | 36 +++++++++++++++++++ tests/mssql/NodeAppendTest.php | 39 +++++++++++++++++++++ tests/mssql/NodeDeleteTest.php | 40 ++++++++++++++++++++++ tests/mssql/NodeInsertTest.php | 38 ++++++++++++++++++++ tests/mssql/NodePrependTest.php | 37 ++++++++++++++++++++ tests/mssql/NodeStateTest.php | 36 +++++++++++++++++++ tests/mssql/QueryBehaviorTest.php | 38 ++++++++++++++++++++ tests/mssql/TreeTraversalTest.php | 36 +++++++++++++++++++ tests/mssql/ValidationAndStructureTest.php | 37 ++++++++++++++++++++ 11 files changed, 409 insertions(+) diff --git a/tests/mssql/CacheManagementTest.php b/tests/mssql/CacheManagementTest.php index 804feb0..4caa47b 100644 --- a/tests/mssql/CacheManagementTest.php +++ b/tests/mssql/CacheManagementTest.php @@ -7,11 +7,47 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractCacheManagement; +/** + * Test suite for cache invalidation in nested sets tree behaviors using SQL Server. + * + * Verifies correct cache management, invalidation, and memoization for nested sets tree structures in SQL Server + * environments, covering node insertions, updates, deletions, and structural changes for both single and multiple tree + * models. + * + * Inherits integration and unit tests from {@see AbstractCacheManagement} to ensure cache lifecycle correctness, + * including depth, left, and right attribute handling, and supports both manual and automatic cache invalidation + * scenarios. + * + * Key features. + * - Ensures compatibility and correctness of cache logic on the SQL Server platform. + * - Full coverage of cache population, invalidation, and memoization for nested sets behaviors. + * - SQL Server-specific configuration for database connection and credentials. + * + * @see AbstractCacheManagement for test logic and scenarios. + * + * @copyright Copyright (C) 2023 Terabytesoftw. + * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. + */ #[Group('mssql')] final class CacheManagementTest extends AbstractCacheManagement { + /** + * Database driver name for SQL Server. + */ protected string $driverName = 'sqlsrv'; + + /** + * Data Source Name (DSN) for SQL Server connection. + */ protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; + + /** + * Password for SQL Server connection. + */ protected string $password = 'YourStrong!Passw0rd'; + + /** + * Username for SQL Server connection. + */ protected string $username = 'SA'; } diff --git a/tests/mssql/ExceptionHandlingTest.php b/tests/mssql/ExceptionHandlingTest.php index 7c35ba3..59c3323 100644 --- a/tests/mssql/ExceptionHandlingTest.php +++ b/tests/mssql/ExceptionHandlingTest.php @@ -7,11 +7,47 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExceptionHandling; +/** + * Test suite for exception handling in nested sets tree behaviors using SQL Server. + * + * Verifies correct exception throwing and error messages for invalid node operations and edge cases in nested sets tree + * structures on SQL Server, covering both single and multiple tree models. + * + * Inherits unit tests from {@see AbstractExceptionHandling} to ensure robustness of the nested sets behavior by + * simulating invalid operations such as appending, inserting, deleting, and making root nodes under unsupported + * conditions. + * + * Key features. + * - Ensures error handling consistency for unsupported operations on SQL Server. + * - Full coverage for invalid append, insert, delete, and makeRoot operations. + * - Support for both single-tree and multi-tree models. + * - Tests for exception messages and types in various edge cases. + * + * @see AbstractExceptionHandling for test logic and scenarios. + * + * @copyright Copyright (C) 2023 Terabytesoftw. + * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. + */ #[Group('mssql')] final class ExceptionHandlingTest extends AbstractExceptionHandling { + /** + * Database driver name for SQL Server. + */ protected string $driverName = 'sqlsrv'; + + /** + * Data Source Name (DSN) for SQL Server connection. + */ protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; + + /** + * Password for SQL Server connection. + */ protected string $password = 'YourStrong!Passw0rd'; + + /** + * Username for SQL Server connection. + */ protected string $username = 'SA'; } diff --git a/tests/mssql/ExtensibilityTest.php b/tests/mssql/ExtensibilityTest.php index 25b010c..dc15e07 100644 --- a/tests/mssql/ExtensibilityTest.php +++ b/tests/mssql/ExtensibilityTest.php @@ -7,11 +7,47 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExtensibility; +/** + * Test suite for extensibility in nested sets tree behaviors using SQL Server. + * + * Verifies that protected methods in the nested sets behavior remain accessible and customizable for subclassing + * scenarios on SQL Server, ensuring extensibility for advanced use cases in both single-tree and multi-tree models. + * + * Inherits unit tests from {@see AbstractExtensibility} to validate the exposure and correct execution of key internal + * methods, supporting framework extension and advanced customization in descendant classes. + * + * Key features. + * - Ensures protected methods are accessible for subclass extension. + * - Supports both single-tree and multi-tree model scenarios. + * - Tests before-insert and move operations for extensibility. + * - Validates extensibility for root and non-root node operations. + * - Verifies correct attribute assignment by protected methods. + * + * @see AbstractExtensibility for test logic and scenarios. + * + * @copyright Copyright (C) 2023 Terabytesoftw. + * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. + */ #[Group('mssql')] final class ExtensibilityTest extends AbstractExtensibility { + /** + * Database driver name for SQL Server. + */ protected string $driverName = 'sqlsrv'; + + /** + * Data Source Name (DSN) for SQL Server connection. + */ protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; + + /** + * Password for SQL Server connection. + */ protected string $password = 'YourStrong!Passw0rd'; + + /** + * Username for SQL Server connection. + */ protected string $username = 'SA'; } diff --git a/tests/mssql/NodeAppendTest.php b/tests/mssql/NodeAppendTest.php index fad8db8..bfa8ca3 100644 --- a/tests/mssql/NodeAppendTest.php +++ b/tests/mssql/NodeAppendTest.php @@ -7,11 +7,50 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeAppend; +/** + * Test suite for node append and root promotion in nested sets tree behaviors using SQL Server. + * + * Provides comprehensive unit and integration tests for appending nodes and promoting nodes to root in nested sets tree + * structures on SQL Server, ensuring correct tree structure, attribute updates, and validation logic for both + * single-tree and multi-tree models. + * + * Inherits tests from {@see AbstractNodeAppend} to validate node append operations, strict validation scenarios, root + * promotion, and XML dataset matching after structural changes, covering edge cases such as validation bypass, + * attribute refresh requirements, and cross-tree operations. + * + * Key features. + * - Covers both {@see Tree} and {@see MultipleTree} model scenarios. + * - Cross-tree append operations for multi-tree models. + * - Ensures correct left, right, depth, and tree attribute updates for SQL Server. + * - Root promotion and attribute refresh verification. + * - Validation of strict and non-strict append operations. + * - XML dataset matching after structural changes. + * + * @see AbstractNodeAppend for test logic and scenarios. + * + * @copyright Copyright (C) 2023 Terabytesoftw. + * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. + */ #[Group('mssql')] final class NodeAppendTest extends AbstractNodeAppend { + /** + * Database driver name for SQL Server. + */ protected string $driverName = 'sqlsrv'; + + /** + * Data Source Name (DSN) for SQL Server connection. + */ protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; + + /** + * Password for SQL Server connection. + */ protected string $password = 'YourStrong!Passw0rd'; + + /** + * Username for SQL Server connection. + */ protected string $username = 'SA'; } diff --git a/tests/mssql/NodeDeleteTest.php b/tests/mssql/NodeDeleteTest.php index 9586a8e..bc9ee1b 100644 --- a/tests/mssql/NodeDeleteTest.php +++ b/tests/mssql/NodeDeleteTest.php @@ -7,11 +7,51 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeDelete; +/** + * Test suite for node deletion in nested sets tree behaviors using SQL Server. + * + * Provides comprehensive unit tests for node and subtree deletion operations in nested sets tree structures on SQL + * Server, ensuring correct state transitions, affected row counts, and data integrity after deletions for both + * single-tree and multi-tree models. + * + * Inherits tests from {@see AbstractNodeDelete} to validate node deletion, subtree removals, abort scenarios, + * transactional behavior, and update operations on node attributes, covering edge cases and XML dataset consistency + * after deletions. + * + * Key features. + * - Covers update operations and affected row count for node attribute changes. + * - Ensures correct affected row counts for node and subtree deletions in both {@see Tree} and {@see MultipleTree} + * models. + * - SQL Server-specific configuration for database connection and credentials. + * - Tests aborting deletions via `beforeDelete()` and transactional behavior. + * - Validates XML dataset consistency after deletions. + * - Verifies node state transitions after `deleteWithChildren()` (new record status, old attributes). + * + * @see AbstractNodeDelete for test logic and scenarios. + * + * @copyright Copyright (C) 2023 Terabytesoftw. + * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. + */ #[Group('mssql')] final class NodeDeleteTest extends AbstractNodeDelete { + /** + * Database driver name for SQL Server. + */ protected string $driverName = 'sqlsrv'; + + /** + * Data Source Name (DSN) for SQL Server connection. + */ protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; + + /** + * Password for SQL Server connection. + */ protected string $password = 'YourStrong!Passw0rd'; + + /** + * Username for SQL Server connection. + */ protected string $username = 'SA'; } diff --git a/tests/mssql/NodeInsertTest.php b/tests/mssql/NodeInsertTest.php index 3cf7399..c74d56f 100644 --- a/tests/mssql/NodeInsertTest.php +++ b/tests/mssql/NodeInsertTest.php @@ -7,11 +7,49 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeInsert; +/** + * Test suite for node insertion in nested sets tree behaviors using SQL Server. + * + * Provides comprehensive unit tests for node insertion operations in nested sets tree structures on SQL Server, + * ensuring correct behavior for inserting nodes before and after targets, with and without validation, and across both + * single-tree and multi-tree models. + * + * Inherits tests from {@see AbstractNodeInsert} to validate insertion logic, strict validation scenarios, cross-tree + * insertions, and XML dataset matching after structural changes, covering edge cases such as validation bypass, + * attribute refresh requirements, and multi-tree operations. + * + * Key features. + * - Covers both {@see Tree} and {@see MultipleTree} model scenarios. + * - Edge case handling for strict validation and cross-tree insertions. + * - Ensures correct left, right, depth, and tree attribute updates for SQL Server. + * - Validation of strict and non-strict insert operations. + * - XML dataset matching after structural changes. + * + * @see AbstractNodeInsert for test logic and scenarios. + * + * @copyright Copyright (C) 2023 Terabytesoftw. + * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. + */ #[Group('mssql')] final class NodeInsertTest extends AbstractNodeInsert { + /** + * Database driver name for SQL Server. + */ protected string $driverName = 'sqlsrv'; + + /** + * Data Source Name (DSN) for SQL Server connection. + */ protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; + + /** + * Password for SQL Server connection. + */ protected string $password = 'YourStrong!Passw0rd'; + + /** + * Username for SQL Server connection. + */ protected string $username = 'SA'; } diff --git a/tests/mssql/NodePrependTest.php b/tests/mssql/NodePrependTest.php index 6e26632..c092680 100644 --- a/tests/mssql/NodePrependTest.php +++ b/tests/mssql/NodePrependTest.php @@ -7,11 +7,48 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodePrepend; +/** + * Test suite for node prepend operations in nested sets tree behaviors using SQL Server. + * + * Provides comprehensive unit and integration tests for prepending nodes in nested sets tree structures on SQL Server, + * ensuring correct tree structure, attribute updates, and validation logic for both single-tree and multi-tree models. + * + * Inherits tests from {@see AbstractNodePrepend} to validate node prepend operations, strict validation scenarios, and + * XML dataset matching after structural changes, covering edge cases such as validation bypass, attribute refresh + * requirements, and cross-tree operations. + * + * Key features. + * - Covers both {@see Tree} and {@see MultipleTree} model scenarios. + * - Ensures correct left, right, depth, and tree attribute updates after prepend operations for SQL Server. + * - Tests for prepending new and existing nodes, including cross-tree operations. + * - Validation of strict and non-strict prepend operations. + * - XML dataset matching after structural changes. + * + * @see AbstractNodePrepend for test logic and scenarios. + * + * @copyright Copyright (C) 2023 Terabytesoftw. + * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. + */ #[Group('mssql')] final class NodePrependTest extends AbstractNodePrepend { + /** + * Database driver name for SQL Server. + */ protected string $driverName = 'sqlsrv'; + + /** + * Data Source Name (DSN) for SQL Server connection. + */ protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; + + /** + * Password for SQL Server connection. + */ protected string $password = 'YourStrong!Passw0rd'; + + /** + * Username for SQL Server connection. + */ protected string $username = 'SA'; } diff --git a/tests/mssql/NodeStateTest.php b/tests/mssql/NodeStateTest.php index 0a5a862..5fff295 100644 --- a/tests/mssql/NodeStateTest.php +++ b/tests/mssql/NodeStateTest.php @@ -7,11 +7,47 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeState; +/** + * Test suite for node state and relationship in nested sets tree behaviors using SQL Server. + * + * Provides comprehensive unit tests for verifying node state, parent-child relationships, and root/leaf detection in + * both single-tree and multi-tree nested sets models on SQL Server. + * + * Inherits tests from {@see AbstractNodeState} to ensure correctness of methods that determine node ancestry, root + * status, and leaf status by testing various edge cases and boundary conditions, such as equal left/right values and + * ancestor chains. + * + * Key features. + * - Coverage for both {@see Tree} and {@see MultipleTree} model implementations. + * - Ensures correct behavior for left/right value manipulations and ancestor checks. + * - Tests for `isChildOf()` under different ancestor and boundary scenarios. + * - Validation of `isRoot()` and `isLeaf()` logic for root, leaf, and intermediate nodes. + * + * @see AbstractNodeState for test logic and scenarios. + * + * @copyright Copyright (C) 2023 Terabytesoftw. + * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. + */ #[Group('mssql')] final class NodeStateTest extends AbstractNodeState { + /** + * Database driver name for SQL Server. + */ protected string $driverName = 'sqlsrv'; + + /** + * Data Source Name (DSN) for SQL Server connection. + */ protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; + + /** + * Password for SQL Server connection. + */ protected string $password = 'YourStrong!Passw0rd'; + + /** + * Username for SQL Server connection. + */ protected string $username = 'SA'; } diff --git a/tests/mssql/QueryBehaviorTest.php b/tests/mssql/QueryBehaviorTest.php index c6c47b3..788a6da 100644 --- a/tests/mssql/QueryBehaviorTest.php +++ b/tests/mssql/QueryBehaviorTest.php @@ -7,11 +7,49 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractQueryBehavior; +/** + * Test suite for query behavior in nested sets tree behaviors using SQL Server. + * + * Provides comprehensive unit tests for query methods related to leaf and root node retrieval, ordering, and behavior + * attachment in both single-tree and multi-tree nested sets models on SQL Server, ensuring correctness of query methods + * such as `leaves()` and `roots()`, including ordering guarantees, SQL generation, and error handling when the behavior + * is detached or not attached to the owner. + * + * Inherits tests from {@see AbstractQueryBehavior} to validate deterministic ordering, correct node retrieval, SQL + * structure, and exception handling for query behaviors. + * + * Key features. + * - Ensures deterministic ordering of results by left and tree attributes. + * - SQL Server-specific configuration for database connection and credentials. + * - Tests for correct leaf and root node retrieval in {@see Tree} and {@see MultipleTree} models. + * - Validates SQL query structure for ordering requirements. + * - Verifies exception handling when the behavior is detached or not attached to the query owner. + * + * @see AbstractQueryBehavior for test logic and scenarios. + * + * @copyright Copyright (C) 2023 Terabytesoftw. + * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. + */ #[Group('mssql')] final class QueryBehaviorTest extends AbstractQueryBehavior { + /** + * Database driver name for SQL Server. + */ protected string $driverName = 'sqlsrv'; + + /** + * Data Source Name (DSN) for SQL Server connection. + */ protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; + + /** + * Password for SQL Server connection. + */ protected string $password = 'YourStrong!Passw0rd'; + + /** + * Username for SQL Server connection. + */ protected string $username = 'SA'; } diff --git a/tests/mssql/TreeTraversalTest.php b/tests/mssql/TreeTraversalTest.php index b53c8ad..0e980aa 100644 --- a/tests/mssql/TreeTraversalTest.php +++ b/tests/mssql/TreeTraversalTest.php @@ -7,11 +7,47 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractTreeTraversal; +/** + * Test suite for tree traversal and relationship methods in nested sets tree behaviors using SQL Server. + * + * Provides comprehensive unit tests for verifying traversal methods, node ordering, and parent/child/leaf relationships + * in both single-tree and multi-tree nested sets models on SQL Server. + * + * Inherits tests from {@see AbstractTreeTraversal} to ensure correctness and determinism of children, leaves, parents, + * next, and previous node retrieval, including order-by requirements and depth constraints, by testing various tree + * structures and update scenarios. + * + * Key features. + * - Covers both {@see Tree} and {@see MultipleTree} model scenarios. + * - Ensures correct node ordering and deterministic traversal for children, leaves, and parents. + * - Tests for order-by enforcement and depth constraints in traversal queries. + * - Validation of structure updates and relationship methods on SQL Server. + * + * @see AbstractTreeTraversal for test logic and scenarios. + * + * @copyright Copyright (C) 2023 Terabytesoftw. + * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. + */ #[Group('mssql')] final class TreeTraversalTest extends AbstractTreeTraversal { + /** + * Database driver name for SQL Server. + */ protected string $driverName = 'sqlsrv'; + + /** + * Data Source Name (DSN) for SQL Server connection. + */ protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; + + /** + * Password for SQL Server connection. + */ protected string $password = 'YourStrong!Passw0rd'; + + /** + * Username for SQL Server connection. + */ protected string $username = 'SA'; } diff --git a/tests/mssql/ValidationAndStructureTest.php b/tests/mssql/ValidationAndStructureTest.php index f99081f..733e869 100644 --- a/tests/mssql/ValidationAndStructureTest.php +++ b/tests/mssql/ValidationAndStructureTest.php @@ -7,11 +7,48 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractValidationAndStructure; +/** + * Test suite for validation and structural integrity in nested sets tree behaviors using SQL Server. + * + * Provides focused unit tests for validating node creation, root assignment, and structural attribute correctness in + * nested sets tree models on SQL Server, including strict validation scenarios and direct manipulation of node + * attributes during insertion. + * + * Inherits tests from {@see AbstractValidationAndStructure} to ensure correct node validation logic, left/right + * attribute shifting, and depth assignment when creating root nodes, appending children, and invoking internal behavior + * methods, covering both validation-enabled and validation-bypassed operations. + * + * Key features. + * - Ensures correct attribute assignment when appending children to root nodes. + * - Tests strict validation logic for root node creation with and without validation enforcement. + * - Validates direct invocation of behavior hooks for node attribute initialization. + * - Verifies left, right, and depth attribute values after root and child node operations. + * + * @see AbstractValidationAndStructure for test logic and scenarios. + * + * @copyright Copyright (C) 2023 Terabytesoftw. + * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. + */ #[Group('mssql')] final class ValidationAndStructureTest extends AbstractValidationAndStructure { + /** + * Database driver name for SQL Server. + */ protected string $driverName = 'sqlsrv'; + + /** + * Data Source Name (DSN) for SQL Server connection. + */ protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; + + /** + * Password for SQL Server connection. + */ protected string $password = 'YourStrong!Passw0rd'; + + /** + * Username for SQL Server connection. + */ protected string $username = 'SA'; } From 58fc0945e342c4576bf0504cd2a8599388f6158b Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Tue, 8 Jul 2025 07:42:06 -0400 Subject: [PATCH 2/2] feat: Refactor SQLServer test suites to utilize centralized `MSSQLConnection` configuration for improved maintainability and consistency. --- tests/mssql/CacheManagementTest.php | 27 +++++--------- tests/mssql/ExceptionHandlingTest.php | 27 +++++--------- tests/mssql/ExtensibilityTest.php | 27 +++++--------- tests/mssql/NodeAppendTest.php | 27 +++++--------- tests/mssql/NodeDeleteTest.php | 27 +++++--------- tests/mssql/NodeInsertTest.php | 27 +++++--------- tests/mssql/NodePrependTest.php | 27 +++++--------- tests/mssql/NodeStateTest.php | 27 +++++--------- tests/mssql/QueryBehaviorTest.php | 27 +++++--------- tests/mssql/TreeTraversalTest.php | 27 +++++--------- tests/mssql/ValidationAndStructureTest.php | 27 +++++--------- tests/support/MSSQLConnection.php | 43 ++++++++++++++++++++++ 12 files changed, 142 insertions(+), 198 deletions(-) create mode 100644 tests/support/MSSQLConnection.php diff --git a/tests/mssql/CacheManagementTest.php b/tests/mssql/CacheManagementTest.php index 4caa47b..22678d6 100644 --- a/tests/mssql/CacheManagementTest.php +++ b/tests/mssql/CacheManagementTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractCacheManagement; +use yii2\extensions\nestedsets\tests\support\MSSQLConnection; /** * Test suite for cache invalidation in nested sets tree behaviors using SQL Server. @@ -31,23 +32,13 @@ #[Group('mssql')] final class CacheManagementTest extends AbstractCacheManagement { - /** - * Database driver name for SQL Server. - */ - protected string $driverName = 'sqlsrv'; + 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; - /** - * Data Source Name (DSN) for SQL Server connection. - */ - protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - - /** - * Password for SQL Server connection. - */ - protected string $password = 'YourStrong!Passw0rd'; - - /** - * Username for SQL Server connection. - */ - protected string $username = 'SA'; + parent::setUp(); + } } diff --git a/tests/mssql/ExceptionHandlingTest.php b/tests/mssql/ExceptionHandlingTest.php index 59c3323..1959560 100644 --- a/tests/mssql/ExceptionHandlingTest.php +++ b/tests/mssql/ExceptionHandlingTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExceptionHandling; +use yii2\extensions\nestedsets\tests\support\MSSQLConnection; /** * Test suite for exception handling in nested sets tree behaviors using SQL Server. @@ -31,23 +32,13 @@ #[Group('mssql')] final class ExceptionHandlingTest extends AbstractExceptionHandling { - /** - * Database driver name for SQL Server. - */ - protected string $driverName = 'sqlsrv'; + 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; - /** - * Data Source Name (DSN) for SQL Server connection. - */ - protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - - /** - * Password for SQL Server connection. - */ - protected string $password = 'YourStrong!Passw0rd'; - - /** - * Username for SQL Server connection. - */ - protected string $username = 'SA'; + parent::setUp(); + } } diff --git a/tests/mssql/ExtensibilityTest.php b/tests/mssql/ExtensibilityTest.php index dc15e07..19a05c1 100644 --- a/tests/mssql/ExtensibilityTest.php +++ b/tests/mssql/ExtensibilityTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractExtensibility; +use yii2\extensions\nestedsets\tests\support\MSSQLConnection; /** * Test suite for extensibility in nested sets tree behaviors using SQL Server. @@ -31,23 +32,13 @@ #[Group('mssql')] final class ExtensibilityTest extends AbstractExtensibility { - /** - * Database driver name for SQL Server. - */ - protected string $driverName = 'sqlsrv'; + 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; - /** - * Data Source Name (DSN) for SQL Server connection. - */ - protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - - /** - * Password for SQL Server connection. - */ - protected string $password = 'YourStrong!Passw0rd'; - - /** - * Username for SQL Server connection. - */ - protected string $username = 'SA'; + parent::setUp(); + } } diff --git a/tests/mssql/NodeAppendTest.php b/tests/mssql/NodeAppendTest.php index bfa8ca3..43b2a2f 100644 --- a/tests/mssql/NodeAppendTest.php +++ b/tests/mssql/NodeAppendTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeAppend; +use yii2\extensions\nestedsets\tests\support\MSSQLConnection; /** * Test suite for node append and root promotion in nested sets tree behaviors using SQL Server. @@ -34,23 +35,13 @@ #[Group('mssql')] final class NodeAppendTest extends AbstractNodeAppend { - /** - * Database driver name for SQL Server. - */ - protected string $driverName = 'sqlsrv'; + 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; - /** - * Data Source Name (DSN) for SQL Server connection. - */ - protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - - /** - * Password for SQL Server connection. - */ - protected string $password = 'YourStrong!Passw0rd'; - - /** - * Username for SQL Server connection. - */ - protected string $username = 'SA'; + parent::setUp(); + } } diff --git a/tests/mssql/NodeDeleteTest.php b/tests/mssql/NodeDeleteTest.php index bc9ee1b..b8f7b92 100644 --- a/tests/mssql/NodeDeleteTest.php +++ b/tests/mssql/NodeDeleteTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeDelete; +use yii2\extensions\nestedsets\tests\support\MSSQLConnection; /** * Test suite for node deletion in nested sets tree behaviors using SQL Server. @@ -35,23 +36,13 @@ #[Group('mssql')] final class NodeDeleteTest extends AbstractNodeDelete { - /** - * Database driver name for SQL Server. - */ - protected string $driverName = 'sqlsrv'; + 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; - /** - * Data Source Name (DSN) for SQL Server connection. - */ - protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - - /** - * Password for SQL Server connection. - */ - protected string $password = 'YourStrong!Passw0rd'; - - /** - * Username for SQL Server connection. - */ - protected string $username = 'SA'; + parent::setUp(); + } } diff --git a/tests/mssql/NodeInsertTest.php b/tests/mssql/NodeInsertTest.php index c74d56f..fc3c064 100644 --- a/tests/mssql/NodeInsertTest.php +++ b/tests/mssql/NodeInsertTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeInsert; +use yii2\extensions\nestedsets\tests\support\MSSQLConnection; /** * Test suite for node insertion in nested sets tree behaviors using SQL Server. @@ -33,23 +34,13 @@ #[Group('mssql')] final class NodeInsertTest extends AbstractNodeInsert { - /** - * Database driver name for SQL Server. - */ - protected string $driverName = 'sqlsrv'; + 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; - /** - * Data Source Name (DSN) for SQL Server connection. - */ - protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - - /** - * Password for SQL Server connection. - */ - protected string $password = 'YourStrong!Passw0rd'; - - /** - * Username for SQL Server connection. - */ - protected string $username = 'SA'; + parent::setUp(); + } } diff --git a/tests/mssql/NodePrependTest.php b/tests/mssql/NodePrependTest.php index c092680..ccd4250 100644 --- a/tests/mssql/NodePrependTest.php +++ b/tests/mssql/NodePrependTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodePrepend; +use yii2\extensions\nestedsets\tests\support\MSSQLConnection; /** * Test suite for node prepend operations in nested sets tree behaviors using SQL Server. @@ -32,23 +33,13 @@ #[Group('mssql')] final class NodePrependTest extends AbstractNodePrepend { - /** - * Database driver name for SQL Server. - */ - protected string $driverName = 'sqlsrv'; + 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; - /** - * Data Source Name (DSN) for SQL Server connection. - */ - protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - - /** - * Password for SQL Server connection. - */ - protected string $password = 'YourStrong!Passw0rd'; - - /** - * Username for SQL Server connection. - */ - protected string $username = 'SA'; + parent::setUp(); + } } diff --git a/tests/mssql/NodeStateTest.php b/tests/mssql/NodeStateTest.php index 5fff295..9749800 100644 --- a/tests/mssql/NodeStateTest.php +++ b/tests/mssql/NodeStateTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractNodeState; +use yii2\extensions\nestedsets\tests\support\MSSQLConnection; /** * Test suite for node state and relationship in nested sets tree behaviors using SQL Server. @@ -31,23 +32,13 @@ #[Group('mssql')] final class NodeStateTest extends AbstractNodeState { - /** - * Database driver name for SQL Server. - */ - protected string $driverName = 'sqlsrv'; + 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; - /** - * Data Source Name (DSN) for SQL Server connection. - */ - protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - - /** - * Password for SQL Server connection. - */ - protected string $password = 'YourStrong!Passw0rd'; - - /** - * Username for SQL Server connection. - */ - protected string $username = 'SA'; + parent::setUp(); + } } diff --git a/tests/mssql/QueryBehaviorTest.php b/tests/mssql/QueryBehaviorTest.php index 788a6da..422eb85 100644 --- a/tests/mssql/QueryBehaviorTest.php +++ b/tests/mssql/QueryBehaviorTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractQueryBehavior; +use yii2\extensions\nestedsets\tests\support\MSSQLConnection; /** * Test suite for query behavior in nested sets tree behaviors using SQL Server. @@ -33,23 +34,13 @@ #[Group('mssql')] final class QueryBehaviorTest extends AbstractQueryBehavior { - /** - * Database driver name for SQL Server. - */ - protected string $driverName = 'sqlsrv'; + 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; - /** - * Data Source Name (DSN) for SQL Server connection. - */ - protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - - /** - * Password for SQL Server connection. - */ - protected string $password = 'YourStrong!Passw0rd'; - - /** - * Username for SQL Server connection. - */ - protected string $username = 'SA'; + parent::setUp(); + } } diff --git a/tests/mssql/TreeTraversalTest.php b/tests/mssql/TreeTraversalTest.php index 0e980aa..5cfefee 100644 --- a/tests/mssql/TreeTraversalTest.php +++ b/tests/mssql/TreeTraversalTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractTreeTraversal; +use yii2\extensions\nestedsets\tests\support\MSSQLConnection; /** * Test suite for tree traversal and relationship methods in nested sets tree behaviors using SQL Server. @@ -31,23 +32,13 @@ #[Group('mssql')] final class TreeTraversalTest extends AbstractTreeTraversal { - /** - * Database driver name for SQL Server. - */ - protected string $driverName = 'sqlsrv'; + 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; - /** - * Data Source Name (DSN) for SQL Server connection. - */ - protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - - /** - * Password for SQL Server connection. - */ - protected string $password = 'YourStrong!Passw0rd'; - - /** - * Username for SQL Server connection. - */ - protected string $username = 'SA'; + parent::setUp(); + } } diff --git a/tests/mssql/ValidationAndStructureTest.php b/tests/mssql/ValidationAndStructureTest.php index 733e869..233c938 100644 --- a/tests/mssql/ValidationAndStructureTest.php +++ b/tests/mssql/ValidationAndStructureTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\Group; use yii2\extensions\nestedsets\tests\base\AbstractValidationAndStructure; +use yii2\extensions\nestedsets\tests\support\MSSQLConnection; /** * Test suite for validation and structural integrity in nested sets tree behaviors using SQL Server. @@ -32,23 +33,13 @@ #[Group('mssql')] final class ValidationAndStructureTest extends AbstractValidationAndStructure { - /** - * Database driver name for SQL Server. - */ - protected string $driverName = 'sqlsrv'; + 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; - /** - * Data Source Name (DSN) for SQL Server connection. - */ - protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no'; - - /** - * Password for SQL Server connection. - */ - protected string $password = 'YourStrong!Passw0rd'; - - /** - * Username for SQL Server connection. - */ - protected string $username = 'SA'; + parent::setUp(); + } } diff --git a/tests/support/MSSQLConnection.php b/tests/support/MSSQLConnection.php new file mode 100644 index 0000000..043c77a --- /dev/null +++ b/tests/support/MSSQLConnection.php @@ -0,0 +1,43 @@ +