Skip to content

Commit ff9229e

Browse files
committed
feat: Add comprehensive test suites for SQLServer nested sets behavior, covering cache management, exception handling, extensibility, node operations, and validation.
1 parent cfbfe27 commit ff9229e

11 files changed

+409
-0
lines changed

tests/mssql/CacheManagementTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,47 @@
77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractCacheManagement;
99

10+
/**
11+
* Test suite for cache invalidation in nested sets tree behaviors using SQL Server.
12+
*
13+
* Verifies correct cache management, invalidation, and memoization for nested sets tree structures in SQL Server
14+
* environments, covering node insertions, updates, deletions, and structural changes for both single and multiple tree
15+
* models.
16+
*
17+
* Inherits integration and unit tests from {@see AbstractCacheManagement} to ensure cache lifecycle correctness,
18+
* including depth, left, and right attribute handling, and supports both manual and automatic cache invalidation
19+
* scenarios.
20+
*
21+
* Key features.
22+
* - Ensures compatibility and correctness of cache logic on the SQL Server platform.
23+
* - Full coverage of cache population, invalidation, and memoization for nested sets behaviors.
24+
* - SQL Server-specific configuration for database connection and credentials.
25+
*
26+
* @see AbstractCacheManagement for test logic and scenarios.
27+
*
28+
* @copyright Copyright (C) 2023 Terabytesoftw.
29+
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
30+
*/
1031
#[Group('mssql')]
1132
final class CacheManagementTest extends AbstractCacheManagement
1233
{
34+
/**
35+
* Database driver name for SQL Server.
36+
*/
1337
protected string $driverName = 'sqlsrv';
38+
39+
/**
40+
* Data Source Name (DSN) for SQL Server connection.
41+
*/
1442
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
43+
44+
/**
45+
* Password for SQL Server connection.
46+
*/
1547
protected string $password = 'YourStrong!Passw0rd';
48+
49+
/**
50+
* Username for SQL Server connection.
51+
*/
1652
protected string $username = 'SA';
1753
}

tests/mssql/ExceptionHandlingTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,47 @@
77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractExceptionHandling;
99

10+
/**
11+
* Test suite for exception handling in nested sets tree behaviors using SQL Server.
12+
*
13+
* Verifies correct exception throwing and error messages for invalid node operations and edge cases in nested sets tree
14+
* structures on SQL Server, covering both single and multiple tree models.
15+
*
16+
* Inherits unit tests from {@see AbstractExceptionHandling} to ensure robustness of the nested sets behavior by
17+
* simulating invalid operations such as appending, inserting, deleting, and making root nodes under unsupported
18+
* conditions.
19+
*
20+
* Key features.
21+
* - Ensures error handling consistency for unsupported operations on SQL Server.
22+
* - Full coverage for invalid append, insert, delete, and makeRoot operations.
23+
* - Support for both single-tree and multi-tree models.
24+
* - Tests for exception messages and types in various edge cases.
25+
*
26+
* @see AbstractExceptionHandling for test logic and scenarios.
27+
*
28+
* @copyright Copyright (C) 2023 Terabytesoftw.
29+
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
30+
*/
1031
#[Group('mssql')]
1132
final class ExceptionHandlingTest extends AbstractExceptionHandling
1233
{
34+
/**
35+
* Database driver name for SQL Server.
36+
*/
1337
protected string $driverName = 'sqlsrv';
38+
39+
/**
40+
* Data Source Name (DSN) for SQL Server connection.
41+
*/
1442
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
43+
44+
/**
45+
* Password for SQL Server connection.
46+
*/
1547
protected string $password = 'YourStrong!Passw0rd';
48+
49+
/**
50+
* Username for SQL Server connection.
51+
*/
1652
protected string $username = 'SA';
1753
}

tests/mssql/ExtensibilityTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,47 @@
77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractExtensibility;
99

10+
/**
11+
* Test suite for extensibility in nested sets tree behaviors using SQL Server.
12+
*
13+
* Verifies that protected methods in the nested sets behavior remain accessible and customizable for subclassing
14+
* scenarios on SQL Server, ensuring extensibility for advanced use cases in both single-tree and multi-tree models.
15+
*
16+
* Inherits unit tests from {@see AbstractExtensibility} to validate the exposure and correct execution of key internal
17+
* methods, supporting framework extension and advanced customization in descendant classes.
18+
*
19+
* Key features.
20+
* - Ensures protected methods are accessible for subclass extension.
21+
* - Supports both single-tree and multi-tree model scenarios.
22+
* - Tests before-insert and move operations for extensibility.
23+
* - Validates extensibility for root and non-root node operations.
24+
* - Verifies correct attribute assignment by protected methods.
25+
*
26+
* @see AbstractExtensibility for test logic and scenarios.
27+
*
28+
* @copyright Copyright (C) 2023 Terabytesoftw.
29+
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
30+
*/
1031
#[Group('mssql')]
1132
final class ExtensibilityTest extends AbstractExtensibility
1233
{
34+
/**
35+
* Database driver name for SQL Server.
36+
*/
1337
protected string $driverName = 'sqlsrv';
38+
39+
/**
40+
* Data Source Name (DSN) for SQL Server connection.
41+
*/
1442
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
43+
44+
/**
45+
* Password for SQL Server connection.
46+
*/
1547
protected string $password = 'YourStrong!Passw0rd';
48+
49+
/**
50+
* Username for SQL Server connection.
51+
*/
1652
protected string $username = 'SA';
1753
}

tests/mssql/NodeAppendTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,50 @@
77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractNodeAppend;
99

10+
/**
11+
* Test suite for node append and root promotion in nested sets tree behaviors using SQL Server.
12+
*
13+
* Provides comprehensive unit and integration tests for appending nodes and promoting nodes to root in nested sets tree
14+
* structures on SQL Server, ensuring correct tree structure, attribute updates, and validation logic for both
15+
* single-tree and multi-tree models.
16+
*
17+
* Inherits tests from {@see AbstractNodeAppend} to validate node append operations, strict validation scenarios, root
18+
* promotion, and XML dataset matching after structural changes, covering edge cases such as validation bypass,
19+
* attribute refresh requirements, and cross-tree operations.
20+
*
21+
* Key features.
22+
* - Covers both {@see Tree} and {@see MultipleTree} model scenarios.
23+
* - Cross-tree append operations for multi-tree models.
24+
* - Ensures correct left, right, depth, and tree attribute updates for SQL Server.
25+
* - Root promotion and attribute refresh verification.
26+
* - Validation of strict and non-strict append operations.
27+
* - XML dataset matching after structural changes.
28+
*
29+
* @see AbstractNodeAppend for test logic and scenarios.
30+
*
31+
* @copyright Copyright (C) 2023 Terabytesoftw.
32+
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
33+
*/
1034
#[Group('mssql')]
1135
final class NodeAppendTest extends AbstractNodeAppend
1236
{
37+
/**
38+
* Database driver name for SQL Server.
39+
*/
1340
protected string $driverName = 'sqlsrv';
41+
42+
/**
43+
* Data Source Name (DSN) for SQL Server connection.
44+
*/
1445
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
46+
47+
/**
48+
* Password for SQL Server connection.
49+
*/
1550
protected string $password = 'YourStrong!Passw0rd';
51+
52+
/**
53+
* Username for SQL Server connection.
54+
*/
1655
protected string $username = 'SA';
1756
}

tests/mssql/NodeDeleteTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,51 @@
77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractNodeDelete;
99

10+
/**
11+
* Test suite for node deletion in nested sets tree behaviors using SQL Server.
12+
*
13+
* Provides comprehensive unit tests for node and subtree deletion operations in nested sets tree structures on SQL
14+
* Server, ensuring correct state transitions, affected row counts, and data integrity after deletions for both
15+
* single-tree and multi-tree models.
16+
*
17+
* Inherits tests from {@see AbstractNodeDelete} to validate node deletion, subtree removals, abort scenarios,
18+
* transactional behavior, and update operations on node attributes, covering edge cases and XML dataset consistency
19+
* after deletions.
20+
*
21+
* Key features.
22+
* - Covers update operations and affected row count for node attribute changes.
23+
* - Ensures correct affected row counts for node and subtree deletions in both {@see Tree} and {@see MultipleTree}
24+
* models.
25+
* - SQL Server-specific configuration for database connection and credentials.
26+
* - Tests aborting deletions via `beforeDelete()` and transactional behavior.
27+
* - Validates XML dataset consistency after deletions.
28+
* - Verifies node state transitions after `deleteWithChildren()` (new record status, old attributes).
29+
*
30+
* @see AbstractNodeDelete for test logic and scenarios.
31+
*
32+
* @copyright Copyright (C) 2023 Terabytesoftw.
33+
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
34+
*/
1035
#[Group('mssql')]
1136
final class NodeDeleteTest extends AbstractNodeDelete
1237
{
38+
/**
39+
* Database driver name for SQL Server.
40+
*/
1341
protected string $driverName = 'sqlsrv';
42+
43+
/**
44+
* Data Source Name (DSN) for SQL Server connection.
45+
*/
1446
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
47+
48+
/**
49+
* Password for SQL Server connection.
50+
*/
1551
protected string $password = 'YourStrong!Passw0rd';
52+
53+
/**
54+
* Username for SQL Server connection.
55+
*/
1656
protected string $username = 'SA';
1757
}

tests/mssql/NodeInsertTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,49 @@
77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractNodeInsert;
99

10+
/**
11+
* Test suite for node insertion in nested sets tree behaviors using SQL Server.
12+
*
13+
* Provides comprehensive unit tests for node insertion operations in nested sets tree structures on SQL Server,
14+
* ensuring correct behavior for inserting nodes before and after targets, with and without validation, and across both
15+
* single-tree and multi-tree models.
16+
*
17+
* Inherits tests from {@see AbstractNodeInsert} to validate insertion logic, strict validation scenarios, cross-tree
18+
* insertions, and XML dataset matching after structural changes, covering edge cases such as validation bypass,
19+
* attribute refresh requirements, and multi-tree operations.
20+
*
21+
* Key features.
22+
* - Covers both {@see Tree} and {@see MultipleTree} model scenarios.
23+
* - Edge case handling for strict validation and cross-tree insertions.
24+
* - Ensures correct left, right, depth, and tree attribute updates for SQL Server.
25+
* - Validation of strict and non-strict insert operations.
26+
* - XML dataset matching after structural changes.
27+
*
28+
* @see AbstractNodeInsert for test logic and scenarios.
29+
*
30+
* @copyright Copyright (C) 2023 Terabytesoftw.
31+
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
32+
*/
1033
#[Group('mssql')]
1134
final class NodeInsertTest extends AbstractNodeInsert
1235
{
36+
/**
37+
* Database driver name for SQL Server.
38+
*/
1339
protected string $driverName = 'sqlsrv';
40+
41+
/**
42+
* Data Source Name (DSN) for SQL Server connection.
43+
*/
1444
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
45+
46+
/**
47+
* Password for SQL Server connection.
48+
*/
1549
protected string $password = 'YourStrong!Passw0rd';
50+
51+
/**
52+
* Username for SQL Server connection.
53+
*/
1654
protected string $username = 'SA';
1755
}

tests/mssql/NodePrependTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,48 @@
77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractNodePrepend;
99

10+
/**
11+
* Test suite for node prepend operations in nested sets tree behaviors using SQL Server.
12+
*
13+
* Provides comprehensive unit and integration tests for prepending nodes in nested sets tree structures on SQL Server,
14+
* ensuring correct tree structure, attribute updates, and validation logic for both single-tree and multi-tree models.
15+
*
16+
* Inherits tests from {@see AbstractNodePrepend} to validate node prepend operations, strict validation scenarios, and
17+
* XML dataset matching after structural changes, covering edge cases such as validation bypass, attribute refresh
18+
* requirements, and cross-tree operations.
19+
*
20+
* Key features.
21+
* - Covers both {@see Tree} and {@see MultipleTree} model scenarios.
22+
* - Ensures correct left, right, depth, and tree attribute updates after prepend operations for SQL Server.
23+
* - Tests for prepending new and existing nodes, including cross-tree operations.
24+
* - Validation of strict and non-strict prepend operations.
25+
* - XML dataset matching after structural changes.
26+
*
27+
* @see AbstractNodePrepend for test logic and scenarios.
28+
*
29+
* @copyright Copyright (C) 2023 Terabytesoftw.
30+
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
31+
*/
1032
#[Group('mssql')]
1133
final class NodePrependTest extends AbstractNodePrepend
1234
{
35+
/**
36+
* Database driver name for SQL Server.
37+
*/
1338
protected string $driverName = 'sqlsrv';
39+
40+
/**
41+
* Data Source Name (DSN) for SQL Server connection.
42+
*/
1443
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
44+
45+
/**
46+
* Password for SQL Server connection.
47+
*/
1548
protected string $password = 'YourStrong!Passw0rd';
49+
50+
/**
51+
* Username for SQL Server connection.
52+
*/
1653
protected string $username = 'SA';
1754
}

tests/mssql/NodeStateTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,47 @@
77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractNodeState;
99

10+
/**
11+
* Test suite for node state and relationship in nested sets tree behaviors using SQL Server.
12+
*
13+
* Provides comprehensive unit tests for verifying node state, parent-child relationships, and root/leaf detection in
14+
* both single-tree and multi-tree nested sets models on SQL Server.
15+
*
16+
* Inherits tests from {@see AbstractNodeState} to ensure correctness of methods that determine node ancestry, root
17+
* status, and leaf status by testing various edge cases and boundary conditions, such as equal left/right values and
18+
* ancestor chains.
19+
*
20+
* Key features.
21+
* - Coverage for both {@see Tree} and {@see MultipleTree} model implementations.
22+
* - Ensures correct behavior for left/right value manipulations and ancestor checks.
23+
* - Tests for `isChildOf()` under different ancestor and boundary scenarios.
24+
* - Validation of `isRoot()` and `isLeaf()` logic for root, leaf, and intermediate nodes.
25+
*
26+
* @see AbstractNodeState for test logic and scenarios.
27+
*
28+
* @copyright Copyright (C) 2023 Terabytesoftw.
29+
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
30+
*/
1031
#[Group('mssql')]
1132
final class NodeStateTest extends AbstractNodeState
1233
{
34+
/**
35+
* Database driver name for SQL Server.
36+
*/
1337
protected string $driverName = 'sqlsrv';
38+
39+
/**
40+
* Data Source Name (DSN) for SQL Server connection.
41+
*/
1442
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
43+
44+
/**
45+
* Password for SQL Server connection.
46+
*/
1547
protected string $password = 'YourStrong!Passw0rd';
48+
49+
/**
50+
* Username for SQL Server connection.
51+
*/
1652
protected string $username = 'SA';
1753
}

0 commit comments

Comments
 (0)