5
5
namespace yii2 \extensions \nestedsets \tests \mysql ;
6
6
7
7
use PHPUnit \Framework \Attributes \Group ;
8
+ use yii \db \Exception ;
8
9
use yii2 \extensions \nestedsets \tests \support \DatabaseConnection ;
9
10
use yii2 \extensions \nestedsets \tests \support \model \MultipleTree ;
10
11
use yii2 \extensions \nestedsets \tests \TestCase ;
11
12
13
+ /**
14
+ * Test suite for mutation operations in nested sets tree behaviors using MySQL.
15
+ *
16
+ * Verifies correct handling of leaf node ordering and left attribute consistency in multiple tree models on MySQL.
17
+ *
18
+ * Ensures that the `leaves()` method returns nodes in the expected order after direct manipulation of left and right
19
+ * attributes, maintaining data integrity and predictable query results.
20
+ *
21
+ * Key features.
22
+ * - Ensures consistent results from the `leaves()` method.
23
+ * - MySQL-specific configuration for database connection and credentials.
24
+ * - Uses the multiple tree model for mutation scenarios.
25
+ * - Validates leaf node detection and ordering after manual updates.
26
+ *
27
+ * @copyright Copyright (C) 2023 Terabytesoftw.
28
+ * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
29
+ */
12
30
#[Group('mutation ' )]
13
31
final class MutationTest extends TestCase
14
32
{
@@ -19,6 +37,9 @@ protected function setUp(): void
19
37
parent ::setUp ();
20
38
}
21
39
40
+ /**
41
+ * @throws Exception if an unexpected error occurs during execution.
42
+ */
22
43
public function testLeavesMethodRequiresLeftAttributeOrderingForConsistentResults (): void
23
44
{
24
45
$ this ->createDatabase ();
@@ -51,7 +72,7 @@ public function testLeavesMethodRequiresLeftAttributeOrderingForConsistentResult
51
72
52
73
$ leaves = MultipleTree::find ()->leaves ()->all ();
53
74
54
- /** @phpstan-var array<array{name: string, lft: int}> */
75
+ /** @phpstan-var array<array{name: string, lft: int}> $expectedLeaves */
55
76
$ expectedLeaves = [
56
77
['name ' => 'Leaf B ' , 'lft ' => 3 ],
57
78
['name ' => 'Leaf A ' , 'lft ' => 5 ],
0 commit comments