99use yii \base \NotSupportedException ;
1010use yii \db \{Exception , StaleObjectException };
1111use yii2 \extensions \nestedsets \NestedSetsBehavior ;
12- use yii2 \extensions \nestedsets \tests \support \model \MultipleTree ;
13- use yii2 \extensions \nestedsets \tests \support \model \Tree ;
12+ use yii2 \extensions \nestedsets \tests \support \model \{MultipleTree , Tree };
1413use yii2 \extensions \nestedsets \tests \TestCase ;
1514
15+ /**
16+ * Base class for exception handling tests in nested sets tree behaviors.
17+ *
18+ * Provides a comprehensive suite of unit tests for exception scenarios in nested sets tree structures, ensuring correct
19+ * exception throwing and error messages for invalid node operations and edge cases.
20+ *
21+ * This class validates the robustness of the nested sets behavior by simulating invalid operations such as appending,
22+ * inserting, deleting, and making root nodes under unsupported conditions, covering both single and multiple tree
23+ * models.
24+ *
25+ * The tests ensure that exceptions are thrown with the expected messages for cases like new records, root nodes, child
26+ * nodes, same node operations, and missing primary keys, as well as logic errors when the behavior is not attached.
27+ *
28+ * Key features.
29+ * - Coverage for invalid append, insert, delete, and makeRoot operations.
30+ * - Ensures error handling consistency for unsupported operations.
31+ * - Support for both single-tree and multi-tree models.
32+ * - Tests for exception messages and types in various edge cases.
33+ * - Validation of logic exceptions when the behavior is detached or not attached to the owner.
34+ *
35+ * @see MultipleTree for multi-tree model.
36+ * @see NestedSetsBehavior for behavior implementation.
37+ * @see Tree for single-tree model.
38+ *
39+ * @copyright Copyright (C) 2023 Terabytesoftw.
40+ * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
41+ */
1642abstract class AbstractExceptionHandling extends TestCase
1743{
1844 public function testThrowExceptionWhenAppendToNewNodeTargetIsNewRecord (): void
@@ -84,8 +110,9 @@ public function testThrowExceptionWhenAppendToTargetIsSame(): void
84110 }
85111
86112 /**
87- * @throws StaleObjectException
88- * @throws Throwable
113+ * @throws StaleObjectException if optimistic, locking is enabled and the data to be deleted has been modified by
114+ * another process.
115+ * @throws Throwable if an unexpected error occurs during execution.
89116 */
90117 public function testThrowExceptionWhenDeleteNodeIsNewRecord (): void
91118 {
@@ -442,8 +469,9 @@ public function testThrowLogicExceptionWhenBehaviorIsNotAttachedToOwner(): void
442469 }
443470
444471 /**
445- * @throws StaleObjectException
446- * @throws Throwable
472+ * @throws StaleObjectException if optimistic, locking is enabled and the data to be deleted has been modified by
473+ * another process.
474+ * @throws Throwable if an unexpected error occurs during execution.
447475 */
448476 public function testThrowNotSupportedExceptionWhenDeleteIsCalledOnRootNode (): void
449477 {
@@ -465,7 +493,7 @@ public function testThrowNotSupportedExceptionWhenDeleteIsCalledOnRootNode(): vo
465493 }
466494
467495 /**
468- * @throws Throwable
496+ * @throws Throwable if an unexpected error occurs during execution.
469497 */
470498 public function testThrowNotSupportedExceptionWhenInsertIsCalledOnTree (): void
471499 {
0 commit comments