Skip to content

Commit 08ca012

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

12 files changed

+397
-44
lines changed

tests/mssql/CacheManagementTest.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,39 @@
66

77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractCacheManagement;
9+
use yii2\extensions\nestedsets\tests\support\MSSQLConnection;
910

11+
/**
12+
* Test suite for cache invalidation in nested sets tree behaviors using SQL Server.
13+
*
14+
* Verifies correct cache management, invalidation, and memoization for nested sets tree structures in SQL Server
15+
* environments, covering node insertions, updates, deletions, and structural changes for both single and multiple tree
16+
* models.
17+
*
18+
* Inherits integration and unit tests from {@see AbstractCacheManagement} to ensure cache lifecycle correctness,
19+
* including depth, left, and right attribute handling, and supports both manual and automatic cache invalidation
20+
* scenarios.
21+
*
22+
* Key features.
23+
* - Ensures compatibility and correctness of cache logic on the SQL Server platform.
24+
* - Full coverage of cache population, invalidation, and memoization for nested sets behaviors.
25+
* - SQL Server-specific configuration for database connection and credentials.
26+
*
27+
* @see AbstractCacheManagement 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 CacheManagementTest extends AbstractCacheManagement
1234
{
13-
protected string $driverName = 'sqlsrv';
14-
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
15-
protected string $password = 'YourStrong!Passw0rd';
16-
protected string $username = 'SA';
35+
protected function setUp(): void
36+
{
37+
$this->driverName = MSSQLConnection::DRIVER_NAME->value;
38+
$this->dsn = MSSQLConnection::DSN->value;
39+
$this->password = MSSQLConnection::PASSWORD->value;
40+
$this->username = MSSQLConnection::USERNAME->value;
41+
42+
parent::setUp();
43+
}
1744
}

tests/mssql/ExceptionHandlingTest.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,39 @@
66

77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractExceptionHandling;
9+
use yii2\extensions\nestedsets\tests\support\MSSQLConnection;
910

11+
/**
12+
* Test suite for exception handling in nested sets tree behaviors using SQL Server.
13+
*
14+
* Verifies correct exception throwing and error messages for invalid node operations and edge cases in nested sets tree
15+
* structures on SQL Server, covering both single and multiple tree models.
16+
*
17+
* Inherits unit tests from {@see AbstractExceptionHandling} to ensure robustness of the nested sets behavior by
18+
* simulating invalid operations such as appending, inserting, deleting, and making root nodes under unsupported
19+
* conditions.
20+
*
21+
* Key features.
22+
* - Ensures error handling consistency for unsupported operations on SQL Server.
23+
* - Full coverage for invalid append, insert, delete, and makeRoot operations.
24+
* - Support for both single-tree and multi-tree models.
25+
* - Tests for exception messages and types in various edge cases.
26+
*
27+
* @see AbstractExceptionHandling 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 ExceptionHandlingTest extends AbstractExceptionHandling
1234
{
13-
protected string $driverName = 'sqlsrv';
14-
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
15-
protected string $password = 'YourStrong!Passw0rd';
16-
protected string $username = 'SA';
35+
protected function setUp(): void
36+
{
37+
$this->driverName = MSSQLConnection::DRIVER_NAME->value;
38+
$this->dsn = MSSQLConnection::DSN->value;
39+
$this->password = MSSQLConnection::PASSWORD->value;
40+
$this->username = MSSQLConnection::USERNAME->value;
41+
42+
parent::setUp();
43+
}
1744
}

tests/mssql/ExtensibilityTest.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,39 @@
66

77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractExtensibility;
9+
use yii2\extensions\nestedsets\tests\support\MSSQLConnection;
910

11+
/**
12+
* Test suite for extensibility in nested sets tree behaviors using SQL Server.
13+
*
14+
* Verifies that protected methods in the nested sets behavior remain accessible and customizable for subclassing
15+
* scenarios on SQL Server, ensuring extensibility for advanced use cases in both single-tree and multi-tree models.
16+
*
17+
* Inherits unit tests from {@see AbstractExtensibility} to validate the exposure and correct execution of key internal
18+
* methods, supporting framework extension and advanced customization in descendant classes.
19+
*
20+
* Key features.
21+
* - Ensures protected methods are accessible for subclass extension.
22+
* - Supports both single-tree and multi-tree model scenarios.
23+
* - Tests before-insert and move operations for extensibility.
24+
* - Validates extensibility for root and non-root node operations.
25+
* - Verifies correct attribute assignment by protected methods.
26+
*
27+
* @see AbstractExtensibility 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 ExtensibilityTest extends AbstractExtensibility
1234
{
13-
protected string $driverName = 'sqlsrv';
14-
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
15-
protected string $password = 'YourStrong!Passw0rd';
16-
protected string $username = 'SA';
35+
protected function setUp(): void
36+
{
37+
$this->driverName = MSSQLConnection::DRIVER_NAME->value;
38+
$this->dsn = MSSQLConnection::DSN->value;
39+
$this->password = MSSQLConnection::PASSWORD->value;
40+
$this->username = MSSQLConnection::USERNAME->value;
41+
42+
parent::setUp();
43+
}
1744
}

tests/mssql/NodeAppendTest.php

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,42 @@
66

77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractNodeAppend;
9+
use yii2\extensions\nestedsets\tests\support\MSSQLConnection;
910

11+
/**
12+
* Test suite for node append and root promotion in nested sets tree behaviors using SQL Server.
13+
*
14+
* Provides comprehensive unit and integration tests for appending nodes and promoting nodes to root in nested sets tree
15+
* structures on SQL Server, ensuring correct tree structure, attribute updates, and validation logic for both
16+
* single-tree and multi-tree models.
17+
*
18+
* Inherits tests from {@see AbstractNodeAppend} to validate node append operations, strict validation scenarios, root
19+
* promotion, and XML dataset matching after structural changes, covering edge cases such as validation bypass,
20+
* attribute refresh requirements, and cross-tree operations.
21+
*
22+
* Key features.
23+
* - Covers both {@see Tree} and {@see MultipleTree} model scenarios.
24+
* - Cross-tree append operations for multi-tree models.
25+
* - Ensures correct left, right, depth, and tree attribute updates for SQL Server.
26+
* - Root promotion and attribute refresh verification.
27+
* - Validation of strict and non-strict append operations.
28+
* - XML dataset matching after structural changes.
29+
*
30+
* @see AbstractNodeAppend 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 NodeAppendTest extends AbstractNodeAppend
1237
{
13-
protected string $driverName = 'sqlsrv';
14-
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
15-
protected string $password = 'YourStrong!Passw0rd';
16-
protected string $username = 'SA';
38+
protected function setUp(): void
39+
{
40+
$this->driverName = MSSQLConnection::DRIVER_NAME->value;
41+
$this->dsn = MSSQLConnection::DSN->value;
42+
$this->password = MSSQLConnection::PASSWORD->value;
43+
$this->username = MSSQLConnection::USERNAME->value;
44+
45+
parent::setUp();
46+
}
1747
}

tests/mssql/NodeDeleteTest.php

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,43 @@
66

77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractNodeDelete;
9+
use yii2\extensions\nestedsets\tests\support\MSSQLConnection;
910

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

tests/mssql/NodeInsertTest.php

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,41 @@
66

77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractNodeInsert;
9+
use yii2\extensions\nestedsets\tests\support\MSSQLConnection;
910

11+
/**
12+
* Test suite for node insertion in nested sets tree behaviors using SQL Server.
13+
*
14+
* Provides comprehensive unit tests for node insertion operations in nested sets tree structures on SQL Server,
15+
* ensuring correct behavior for inserting nodes before and after targets, with and without validation, and across both
16+
* single-tree and multi-tree models.
17+
*
18+
* Inherits tests from {@see AbstractNodeInsert} to validate insertion logic, strict validation scenarios, cross-tree
19+
* insertions, and XML dataset matching after structural changes, covering edge cases such as validation bypass,
20+
* attribute refresh requirements, and multi-tree operations.
21+
*
22+
* Key features.
23+
* - Covers both {@see Tree} and {@see MultipleTree} model scenarios.
24+
* - Edge case handling for strict validation and cross-tree insertions.
25+
* - Ensures correct left, right, depth, and tree attribute updates for SQL Server.
26+
* - Validation of strict and non-strict insert operations.
27+
* - XML dataset matching after structural changes.
28+
*
29+
* @see AbstractNodeInsert 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 NodeInsertTest extends AbstractNodeInsert
1236
{
13-
protected string $driverName = 'sqlsrv';
14-
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
15-
protected string $password = 'YourStrong!Passw0rd';
16-
protected string $username = 'SA';
37+
protected function setUp(): void
38+
{
39+
$this->driverName = MSSQLConnection::DRIVER_NAME->value;
40+
$this->dsn = MSSQLConnection::DSN->value;
41+
$this->password = MSSQLConnection::PASSWORD->value;
42+
$this->username = MSSQLConnection::USERNAME->value;
43+
44+
parent::setUp();
45+
}
1746
}

tests/mssql/NodePrependTest.php

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,40 @@
66

77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractNodePrepend;
9+
use yii2\extensions\nestedsets\tests\support\MSSQLConnection;
910

11+
/**
12+
* Test suite for node prepend operations in nested sets tree behaviors using SQL Server.
13+
*
14+
* Provides comprehensive unit and integration tests for prepending nodes in nested sets tree structures on SQL Server,
15+
* ensuring correct tree structure, attribute updates, and validation logic for both single-tree and multi-tree models.
16+
*
17+
* Inherits tests from {@see AbstractNodePrepend} to validate node prepend operations, strict validation scenarios, and
18+
* XML dataset matching after structural changes, covering edge cases such as validation bypass, attribute refresh
19+
* requirements, and cross-tree operations.
20+
*
21+
* Key features.
22+
* - Covers both {@see Tree} and {@see MultipleTree} model scenarios.
23+
* - Ensures correct left, right, depth, and tree attribute updates after prepend operations for SQL Server.
24+
* - Tests for prepending new and existing nodes, including cross-tree operations.
25+
* - Validation of strict and non-strict prepend operations.
26+
* - XML dataset matching after structural changes.
27+
*
28+
* @see AbstractNodePrepend 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 NodePrependTest extends AbstractNodePrepend
1235
{
13-
protected string $driverName = 'sqlsrv';
14-
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
15-
protected string $password = 'YourStrong!Passw0rd';
16-
protected string $username = 'SA';
36+
protected function setUp(): void
37+
{
38+
$this->driverName = MSSQLConnection::DRIVER_NAME->value;
39+
$this->dsn = MSSQLConnection::DSN->value;
40+
$this->password = MSSQLConnection::PASSWORD->value;
41+
$this->username = MSSQLConnection::USERNAME->value;
42+
43+
parent::setUp();
44+
}
1745
}

tests/mssql/NodeStateTest.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,39 @@
66

77
use PHPUnit\Framework\Attributes\Group;
88
use yii2\extensions\nestedsets\tests\base\AbstractNodeState;
9+
use yii2\extensions\nestedsets\tests\support\MSSQLConnection;
910

11+
/**
12+
* Test suite for node state and relationship in nested sets tree behaviors using SQL Server.
13+
*
14+
* Provides comprehensive unit tests for verifying node state, parent-child relationships, and root/leaf detection in
15+
* both single-tree and multi-tree nested sets models on SQL Server.
16+
*
17+
* Inherits tests from {@see AbstractNodeState} to ensure correctness of methods that determine node ancestry, root
18+
* status, and leaf status by testing various edge cases and boundary conditions, such as equal left/right values and
19+
* ancestor chains.
20+
*
21+
* Key features.
22+
* - Coverage for both {@see Tree} and {@see MultipleTree} model implementations.
23+
* - Ensures correct behavior for left/right value manipulations and ancestor checks.
24+
* - Tests for `isChildOf()` under different ancestor and boundary scenarios.
25+
* - Validation of `isRoot()` and `isLeaf()` logic for root, leaf, and intermediate nodes.
26+
*
27+
* @see AbstractNodeState 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 NodeStateTest extends AbstractNodeState
1234
{
13-
protected string $driverName = 'sqlsrv';
14-
protected string|null $dsn = 'sqlsrv:Server=127.0.0.1,1433;Database=yiitest;Encrypt=no';
15-
protected string $password = 'YourStrong!Passw0rd';
16-
protected string $username = 'SA';
35+
protected function setUp(): void
36+
{
37+
$this->driverName = MSSQLConnection::DRIVER_NAME->value;
38+
$this->dsn = MSSQLConnection::DSN->value;
39+
$this->password = MSSQLConnection::PASSWORD->value;
40+
$this->username = MSSQLConnection::USERNAME->value;
41+
42+
parent::setUp();
43+
}
1744
}

0 commit comments

Comments
 (0)