Skip to content

Commit c1ca443

Browse files
feat: Add docs test suites for SQLite nested sets behavior, covering cache management, exception handling, extensibility, node operations, and validation. (#77)
1 parent 1e51613 commit c1ca443

11 files changed

+252
-0
lines changed

tests/sqlite/CacheManagementTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,27 @@
88
use yii2\extensions\nestedsets\tests\base\AbstractCacheManagement;
99
use yii2\extensions\nestedsets\tests\support\DatabaseConnection;
1010

11+
/**
12+
* Test suite for cache invalidation in nested sets tree behaviors using SQLite.
13+
*
14+
* Verifies correct cache management, invalidation, and memoization for nested sets tree structures in SQLite
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 SQLite platform.
24+
* - Full coverage of cache population, invalidation, and memoization for nested sets behaviors.
25+
* - SQLite-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+
*/
1132
#[Group('sqlite')]
1233
final class CacheManagementTest extends AbstractCacheManagement
1334
{

tests/sqlite/ExceptionHandlingTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@
88
use yii2\extensions\nestedsets\tests\base\AbstractExceptionHandling;
99
use yii2\extensions\nestedsets\tests\support\DatabaseConnection;
1010

11+
/**
12+
* Test suite for exception handling in nested sets tree behaviors using SQLite.
13+
*
14+
* Verifies correct exception throwing and error messages for invalid node operations and edge cases in nested sets tree
15+
* structures on SQLite, 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 SQLite.
23+
* - Full coverage for invalid append, insert, delete, and makeRoot operations.
24+
* - SQLite-specific configuration for database connection and credentials.
25+
* - Support for both single-tree and multi-tree models.
26+
* - Tests for exception messages and types in various edge cases.
27+
*
28+
* @see AbstractExceptionHandling 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+
*/
1133
#[Group('sqlite')]
1234
final class ExceptionHandlingTest extends AbstractExceptionHandling
1335
{

tests/sqlite/ExtensibilityTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@
88
use yii2\extensions\nestedsets\tests\base\AbstractExtensibility;
99
use yii2\extensions\nestedsets\tests\support\DatabaseConnection;
1010

11+
/**
12+
* Test suite for extensibility in nested sets tree behaviors using SQLite.
13+
*
14+
* Verifies that protected methods in the nested sets behavior remain accessible and customizable for subclassing
15+
* scenarios on SQLite, 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+
* - SQLite-specific configuration for database connection and credentials.
23+
* - Supports both single-tree and multi-tree model scenarios.
24+
* - Tests before-insert and move operations for extensibility.
25+
* - Validates extensibility for root and non-root node operations.
26+
* - Verifies correct attribute assignment by protected methods.
27+
*
28+
* @see AbstractExtensibility 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+
*/
1133
#[Group('sqlite')]
1234
final class ExtensibilityTest extends AbstractExtensibility
1335
{

tests/sqlite/NodeAppendTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,31 @@
88
use yii2\extensions\nestedsets\tests\base\AbstractNodeAppend;
99
use yii2\extensions\nestedsets\tests\support\DatabaseConnection;
1010

11+
/**
12+
* Test suite for node append and root promotion in nested sets tree behaviors using SQLite.
13+
*
14+
* Provides comprehensive unit and integration tests for appending nodes and promoting nodes to root in nested sets tree
15+
* structures on SQLite, ensuring correct tree structure, attribute updates, and validation logic for both single-tree
16+
* 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 SQLite.
26+
* - Root promotion and attribute refresh verification.
27+
* - SQLite-specific configuration for database connection and credentials.
28+
* - Validation of strict and non-strict append operations.
29+
* - XML dataset matching after structural changes.
30+
*
31+
* @see AbstractNodeAppend 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+
*/
1136
#[Group('sqlite')]
1237
final class NodeAppendTest extends AbstractNodeAppend
1338
{

tests/sqlite/NodeDeleteTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,31 @@
88
use yii2\extensions\nestedsets\tests\base\AbstractNodeDelete;
99
use yii2\extensions\nestedsets\tests\support\DatabaseConnection;
1010

11+
/**
12+
* Test suite for node deletion in nested sets tree behaviors using SQLite.
13+
*
14+
* Provides comprehensive unit tests for node and subtree deletion operations in nested sets tree structures on SQLite,
15+
* ensuring correct state transitions, affected row counts, and data integrity after deletions for both single-tree and
16+
* 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+
* - SQLite-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+
*/
1136
#[Group('sqlite')]
1237
final class NodeDeleteTest extends AbstractNodeDelete
1338
{

tests/sqlite/NodeInsertTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,30 @@
88
use yii2\extensions\nestedsets\tests\base\AbstractNodeInsert;
99
use yii2\extensions\nestedsets\tests\support\DatabaseConnection;
1010

11+
/**
12+
* Test suite for node insertion in nested sets tree behaviors using SQLite.
13+
*
14+
* Provides comprehensive unit tests for node insertion operations in nested sets tree structures on SQLite, ensuring
15+
* 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 SQLite.
26+
* - SQLite-specific configuration for database connection and credentials.
27+
* - Validation of strict and non-strict insert operations.
28+
* - XML dataset matching after structural changes.
29+
*
30+
* @see AbstractNodeInsert 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+
*/
1135
#[Group('sqlite')]
1236
final class NodeInsertTest extends AbstractNodeInsert
1337
{

tests/sqlite/NodePrependTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,29 @@
88
use yii2\extensions\nestedsets\tests\base\AbstractNodePrepend;
99
use yii2\extensions\nestedsets\tests\support\DatabaseConnection;
1010

11+
/**
12+
* Test suite for node prepend operations in nested sets tree behaviors using SQLite.
13+
*
14+
* Provides comprehensive unit and integration tests for prepending nodes in nested sets tree structures on SQLite,
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 SQLite.
24+
* - SQLite-specific configuration for database connection and credentials.
25+
* - Tests for prepending new and existing nodes, including cross-tree operations.
26+
* - Validation of strict and non-strict prepend operations.
27+
* - XML dataset matching after structural changes.
28+
*
29+
* @see AbstractNodePrepend 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+
*/
1134
#[Group('sqlite')]
1235
final class NodePrependTest extends AbstractNodePrepend
1336
{

tests/sqlite/NodeStateTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@
88
use yii2\extensions\nestedsets\tests\base\AbstractNodeState;
99
use yii2\extensions\nestedsets\tests\support\DatabaseConnection;
1010

11+
/**
12+
* Test suite for node state and relationship in nested sets tree behaviors using SQLite.
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 SQLite.
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+
* - SQLite-specific configuration for database connection and credentials.
25+
* - Tests for `isChildOf()` under different ancestor and boundary scenarios.
26+
* - Validation of `isRoot()` and `isLeaf()` logic for root, leaf, and intermediate nodes.
27+
*
28+
* @see AbstractNodeState 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+
*/
1133
#[Group('sqlite')]
1234
final class NodeStateTest extends AbstractNodeState
1335
{

tests/sqlite/QueryBehaviorTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,29 @@
88
use yii2\extensions\nestedsets\tests\base\AbstractQueryBehavior;
99
use yii2\extensions\nestedsets\tests\support\DatabaseConnection;
1010

11+
/**
12+
* Test suite for query behavior in nested sets tree behaviors using SQLite.
13+
*
14+
* Provides comprehensive unit tests for query methods related to leaf and root node retrieval, ordering, and behavior
15+
* attachment in both single-tree and multi-tree nested sets models on SQLite, ensuring correctness of query methods
16+
* such as `leaves()` and `roots()`, including ordering guarantees, SQL generation, and error handling when the behavior
17+
* is detached or not attached to the owner.
18+
*
19+
* Inherits tests from {@see AbstractQueryBehavior} to validate deterministic ordering, correct node retrieval, SQL
20+
* structure, and exception handling for query behaviors.
21+
*
22+
* Key features.
23+
* - Ensures deterministic ordering of results by left and tree attributes.
24+
* - SQLite-specific configuration for database connection and credentials.
25+
* - Tests for correct leaf and root node retrieval in {@see Tree} and {@see MultipleTree} models.
26+
* - Validates SQL query structure for ordering requirements.
27+
* - Verifies exception handling when the behavior is detached or not attached to the query owner.
28+
*
29+
* @see AbstractQueryBehavior 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+
*/
1134
#[Group('sqlite')]
1235
final class QueryBehaviorTest extends AbstractQueryBehavior
1336
{

tests/sqlite/TreeTraversalTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@
88
use yii2\extensions\nestedsets\tests\base\AbstractTreeTraversal;
99
use yii2\extensions\nestedsets\tests\support\DatabaseConnection;
1010

11+
/**
12+
* Test suite for tree traversal and relationship methods in nested sets tree behaviors using SQLite.
13+
*
14+
* Provides comprehensive unit tests for verifying traversal methods, node ordering, and parent/child/leaf relationships
15+
* in both single-tree and multi-tree nested sets models on SQLite.
16+
*
17+
* Inherits tests from {@see AbstractTreeTraversal} to ensure correctness and determinism of children, leaves, parents,
18+
* next, and previous node retrieval, including order-by requirements and depth constraints, by testing various tree
19+
* structures and update scenarios.
20+
*
21+
* Key features.
22+
* - Covers both {@see Tree} and {@see MultipleTree} model scenarios.
23+
* - Ensures correct node ordering and deterministic traversal for children, leaves, and parents.
24+
* - SQLite-specific configuration for database connection and credentials.
25+
* - Tests for order-by enforcement and depth constraints in traversal queries.
26+
* - Validation of structure updates and relationship methods on SQLite.
27+
*
28+
* @see AbstractTreeTraversal 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+
*/
1133
#[Group('sqlite')]
1234
final class TreeTraversalTest extends AbstractTreeTraversal
1335
{

0 commit comments

Comments
 (0)