From 033c1130b7501b15eda49c6490c94b5baf150091 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Tue, 8 Jul 2025 11:21:41 -0400 Subject: [PATCH] feat: Add docs test suites for `PostgreSQL` nested sets behavior, covering cache management, exception handling, extensibility, node operations, and validation. --- tests/pgsql/CacheManagementTest.php | 21 ++++++++++++++++++ tests/pgsql/ExceptionHandlingTest.php | 22 +++++++++++++++++++ tests/pgsql/ExtensibilityTest.php | 22 +++++++++++++++++++ tests/pgsql/MutationTest.php | 16 ++++++++++++++ tests/pgsql/NodeAppendTest.php | 25 ++++++++++++++++++++++ tests/pgsql/NodeDeleteTest.php | 25 ++++++++++++++++++++++ tests/pgsql/NodeInsertTest.php | 24 +++++++++++++++++++++ tests/pgsql/NodePrependTest.php | 23 ++++++++++++++++++++ tests/pgsql/NodeStateTest.php | 22 +++++++++++++++++++ tests/pgsql/QueryBehaviorTest.php | 23 ++++++++++++++++++++ tests/pgsql/TreeTraversalTest.php | 22 +++++++++++++++++++ tests/pgsql/ValidationAndStructureTest.php | 23 ++++++++++++++++++++ 12 files changed, 268 insertions(+) diff --git a/tests/pgsql/CacheManagementTest.php b/tests/pgsql/CacheManagementTest.php index 16934e2..846b259 100644 --- a/tests/pgsql/CacheManagementTest.php +++ b/tests/pgsql/CacheManagementTest.php @@ -8,6 +8,27 @@ use yii2\extensions\nestedsets\tests\base\AbstractCacheManagement; use yii2\extensions\nestedsets\tests\support\DatabaseConnection; +/** + * Test suite for cache invalidation in nested sets tree behaviors using PostgreSQL. + * + * Verifies correct cache management, invalidation, and memoization for nested sets tree structures in PostgreSQL + * 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 PostgreSQL platform. + * - Full coverage of cache population, invalidation, and memoization for nested sets behaviors. + * - PostgreSQL-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('pgsql')] final class CacheManagementTest extends AbstractCacheManagement { diff --git a/tests/pgsql/ExceptionHandlingTest.php b/tests/pgsql/ExceptionHandlingTest.php index 1818b6d..5583538 100644 --- a/tests/pgsql/ExceptionHandlingTest.php +++ b/tests/pgsql/ExceptionHandlingTest.php @@ -8,6 +8,28 @@ use yii2\extensions\nestedsets\tests\base\AbstractExceptionHandling; use yii2\extensions\nestedsets\tests\support\DatabaseConnection; +/** + * Test suite for exception handling in nested sets tree behaviors using PostgreSQL. + * + * Verifies correct exception throwing and error messages for invalid node operations and edge cases in nested sets tree + * structures on PostgreSQL, 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 PostgreSQL. + * - Full coverage for invalid append, insert, delete, and makeRoot operations. + * - PostgreSQL-specific configuration for database connection and credentials. + * - 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('pgsql')] final class ExceptionHandlingTest extends AbstractExceptionHandling { diff --git a/tests/pgsql/ExtensibilityTest.php b/tests/pgsql/ExtensibilityTest.php index b624436..80a8f33 100644 --- a/tests/pgsql/ExtensibilityTest.php +++ b/tests/pgsql/ExtensibilityTest.php @@ -8,6 +8,28 @@ use yii2\extensions\nestedsets\tests\base\AbstractExtensibility; use yii2\extensions\nestedsets\tests\support\DatabaseConnection; +/** + * Test suite for extensibility in nested sets tree behaviors using PostgreSQL. + * + * Verifies that protected methods in the nested sets behavior remain accessible and customizable for subclassing + * scenarios on PostgreSQL, 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. + * - PostgreSQL-specific configuration for database connection and credentials. + * - 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('pgsql')] final class ExtensibilityTest extends AbstractExtensibility { diff --git a/tests/pgsql/MutationTest.php b/tests/pgsql/MutationTest.php index 8aa5b63..763af1e 100644 --- a/tests/pgsql/MutationTest.php +++ b/tests/pgsql/MutationTest.php @@ -8,6 +8,22 @@ use yii2\extensions\nestedsets\tests\support\DatabaseConnection; use yii2\extensions\nestedsets\tests\TestCase; +/** + * Test suite for mutation operations in nested sets tree behaviors using PostgreSQL. + * + * Verifies correct node ordering and tree traversal logic for children queries in PostgreSQL-based nested sets trees. + * + * Ensures that the children retrieval method respects left/right boundaries and ordering requirements, validating that + * tree traversal produces the expected node order after manual updates to the tree structure. + * + * Key features. + * - Ensures correct handling of left/right attribute updates. + * - PostgreSQL-specific configuration for database connection and credentials. + * - Validates children node ordering for tree traversal. + * + * @copyright Copyright (C) 2023 Terabytesoftw. + * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. + */ #[Group('mutation')] final class MutationTest extends TestCase { diff --git a/tests/pgsql/NodeAppendTest.php b/tests/pgsql/NodeAppendTest.php index 1055210..46b8418 100644 --- a/tests/pgsql/NodeAppendTest.php +++ b/tests/pgsql/NodeAppendTest.php @@ -8,6 +8,31 @@ use yii2\extensions\nestedsets\tests\base\AbstractNodeAppend; use yii2\extensions\nestedsets\tests\support\DatabaseConnection; +/** + * Test suite for node append and root promotion in nested sets tree behaviors using PostgreSQL. + * + * Provides comprehensive unit and integration tests for appending nodes and promoting nodes to root in nested sets tree + * structures on PostgreSQL, 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 PostgreSQL. + * - PostgreSQL-specific configuration for database connection and credentials. + * - 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('pgsql')] final class NodeAppendTest extends AbstractNodeAppend { diff --git a/tests/pgsql/NodeDeleteTest.php b/tests/pgsql/NodeDeleteTest.php index 21b4cff..2850a95 100644 --- a/tests/pgsql/NodeDeleteTest.php +++ b/tests/pgsql/NodeDeleteTest.php @@ -8,6 +8,31 @@ use yii2\extensions\nestedsets\tests\base\AbstractNodeDelete; use yii2\extensions\nestedsets\tests\support\DatabaseConnection; +/** + * Test suite for node deletion in nested sets tree behaviors using PostgreSQL. + * + * Provides comprehensive unit tests for node and subtree deletion operations in nested sets tree structures on + * PostgreSQL, 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. + * - PostgreSQL-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('pgsql')] final class NodeDeleteTest extends AbstractNodeDelete { diff --git a/tests/pgsql/NodeInsertTest.php b/tests/pgsql/NodeInsertTest.php index f1ff34c..b60096b 100644 --- a/tests/pgsql/NodeInsertTest.php +++ b/tests/pgsql/NodeInsertTest.php @@ -8,6 +8,30 @@ use yii2\extensions\nestedsets\tests\base\AbstractNodeInsert; use yii2\extensions\nestedsets\tests\support\DatabaseConnection; +/** + * Test suite for node insertion in nested sets tree behaviors using PostgreSQL. + * + * Provides comprehensive unit tests for node insertion operations in nested sets tree structures on PostgreSQL, + * 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 PostgreSQL. + * - PostgreSQL-specific configuration for database connection and credentials. + * - 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('pgsql')] final class NodeInsertTest extends AbstractNodeInsert { diff --git a/tests/pgsql/NodePrependTest.php b/tests/pgsql/NodePrependTest.php index 3a90818..cbe858f 100644 --- a/tests/pgsql/NodePrependTest.php +++ b/tests/pgsql/NodePrependTest.php @@ -8,6 +8,29 @@ use yii2\extensions\nestedsets\tests\base\AbstractNodePrepend; use yii2\extensions\nestedsets\tests\support\DatabaseConnection; +/** + * Test suite for node prepend operations in nested sets tree behaviors using PostgreSQL. + * + * Provides comprehensive unit and integration tests for prepending nodes in nested sets tree structures on PostgreSQL, + * 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 PostgreSQL. + * - PostgreSQL-specific configuration for database connection and credentials. + * - 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('pgsql')] final class NodePrependTest extends AbstractNodePrepend { diff --git a/tests/pgsql/NodeStateTest.php b/tests/pgsql/NodeStateTest.php index 4f786db..767bed0 100644 --- a/tests/pgsql/NodeStateTest.php +++ b/tests/pgsql/NodeStateTest.php @@ -8,6 +8,28 @@ use yii2\extensions\nestedsets\tests\base\AbstractNodeState; use yii2\extensions\nestedsets\tests\support\DatabaseConnection; +/** + * Test suite for node state and relationship in nested sets tree behaviors using PostgreSQL. + * + * 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 PostgreSQL. + * + * 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. + * - PostgreSQL-specific configuration for database connection and credentials. + * - 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('pgsql')] final class NodeStateTest extends AbstractNodeState { diff --git a/tests/pgsql/QueryBehaviorTest.php b/tests/pgsql/QueryBehaviorTest.php index 274f101..53d28f3 100644 --- a/tests/pgsql/QueryBehaviorTest.php +++ b/tests/pgsql/QueryBehaviorTest.php @@ -8,6 +8,29 @@ use yii2\extensions\nestedsets\tests\base\AbstractQueryBehavior; use yii2\extensions\nestedsets\tests\support\DatabaseConnection; +/** + * Test suite for query behavior in nested sets tree behaviors using PostgreSQL. + * + * 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 PostgreSQL, 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. + * - PostgreSQL-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('pgsql')] final class QueryBehaviorTest extends AbstractQueryBehavior { diff --git a/tests/pgsql/TreeTraversalTest.php b/tests/pgsql/TreeTraversalTest.php index 4f4f04e..c2e68d4 100644 --- a/tests/pgsql/TreeTraversalTest.php +++ b/tests/pgsql/TreeTraversalTest.php @@ -8,6 +8,28 @@ use yii2\extensions\nestedsets\tests\base\AbstractTreeTraversal; use yii2\extensions\nestedsets\tests\support\DatabaseConnection; +/** + * Test suite for tree traversal and relationship methods in nested sets tree behaviors using PostgreSQL. + * + * 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 PostgreSQL. + * + * 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. + * - PostgreSQL-specific configuration for database connection and credentials. + * - Tests for order-by enforcement and depth constraints in traversal queries. + * - Validation of structure updates and relationship methods on PostgreSQL. + * + * @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('pgsql')] final class TreeTraversalTest extends AbstractTreeTraversal { diff --git a/tests/pgsql/ValidationAndStructureTest.php b/tests/pgsql/ValidationAndStructureTest.php index a172193..dc06dbf 100644 --- a/tests/pgsql/ValidationAndStructureTest.php +++ b/tests/pgsql/ValidationAndStructureTest.php @@ -8,6 +8,29 @@ use yii2\extensions\nestedsets\tests\base\AbstractValidationAndStructure; use yii2\extensions\nestedsets\tests\support\DatabaseConnection; +/** + * Test suite for validation and structural integrity in nested sets tree behaviors using PostgreSQL. + * + * Provides focused unit tests for validating node creation, root assignment, and structural attribute correctness in + * nested sets tree models on PostgreSQL, 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. + * - PostgreSQL-specific configuration for database connection and credentials. + * - 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('pgsql')] final class ValidationAndStructureTest extends AbstractValidationAndStructure {