@@ -21,7 +21,7 @@ public function test_construct_trows_on_non_list(): void
2121 new Ltree ([0 => 'a ' , 2 => 'b ' , 3 => 'c ' ]); // @phpstan-ignore argument.type
2222 }
2323
24- public function test_construct_trows_on_empty_string_in_branch (): void
24+ public function test_construct_trows_on_empty_string_in_path_from_root (): void
2525 {
2626 $ this ->expectException (\InvalidArgumentException::class);
2727 new Ltree (['a ' , '' , 'c ' ]); // @phpstan-ignore argument.type
@@ -30,22 +30,22 @@ public function test_construct_trows_on_empty_string_in_branch(): void
3030 public function test_from_string (): void
3131 {
3232 $ ltree = Ltree::fromString ('x.y.z ' );
33- self ::assertSame (['x ' , 'y ' , 'z ' ], $ ltree ->getBranch ());
33+ self ::assertSame (['x ' , 'y ' , 'z ' ], $ ltree ->getPathFromRoot ());
3434 self ::assertSame ('x.y.z ' , (string ) $ ltree );
3535 }
3636
3737 public function test_from_string_empty (): void
3838 {
3939 $ ltree = Ltree::fromString ('' );
40- self ::assertSame ([], $ ltree ->getBranch ());
40+ self ::assertSame ([], $ ltree ->getPathFromRoot ());
4141 self ::assertSame ('' , (string ) $ ltree );
4242 }
4343
4444 public function test_json_serialize (): void
4545 {
46- $ branch = ['a ' , 'b ' , 'c ' ];
47- $ ltree = new Ltree ($ branch );
48- self ::assertSame ($ branch , $ ltree ->jsonSerialize ());
46+ $ pathFromRoot = ['a ' , 'b ' , 'c ' ];
47+ $ ltree = new Ltree ($ pathFromRoot );
48+ self ::assertSame ($ pathFromRoot , $ ltree ->jsonSerialize ());
4949 }
5050
5151 public function test_json_encode (): void
@@ -55,11 +55,11 @@ public function test_json_encode(): void
5555 self ::assertSame ('["a","b","c"] ' , $ json );
5656 }
5757
58- public function test_create_leaf (): void
58+ public function test_with_leaf (): void
5959 {
6060 $ ltree = new Ltree (['root ' ]);
61- $ newLtree = $ ltree ->createLeaf ('leaf ' );
62- self ::assertSame (['root ' , 'leaf ' ], $ newLtree ->getBranch ());
61+ $ newLtree = $ ltree ->withLeaf ('leaf ' );
62+ self ::assertSame (['root ' , 'leaf ' ], $ newLtree ->getPathFromRoot ());
6363 self ::assertSame ('root.leaf ' , (string ) $ newLtree );
6464 }
6565
@@ -75,17 +75,17 @@ public function test_equals(): void
7575 public function test_is_ancestor_of (): void
7676 {
7777 $ ancestor = new Ltree (['a ' , 'b ' ]);
78- $ descendant = new Ltree (['a ' , 'b ' , 'c ' ]);
79- self ::assertTrue ($ ancestor ->isAncestorOf ($ descendant ));
80- self ::assertFalse ($ descendant ->isAncestorOf ($ ancestor ));
78+ $ leaf = new Ltree (['a ' , 'b ' , 'c ' ]);
79+ self ::assertTrue ($ ancestor ->isAncestorOf ($ leaf ));
80+ self ::assertFalse ($ leaf ->isAncestorOf ($ ancestor ));
8181 }
8282
83- public function test_is_descendant_of (): void
83+ public function test_is_leaf_of (): void
8484 {
8585 $ ancestor = new Ltree (['a ' , 'b ' ]);
86- $ descendant = new Ltree (['a ' , 'b ' , 'c ' ]);
87- self ::assertTrue ($ descendant -> isDescendantOf ($ ancestor ));
88- self ::assertFalse ($ ancestor ->isDescendantOf ( $ descendant ));
86+ $ leaf = new Ltree (['a ' , 'b ' , 'c ' ]);
87+ self ::assertTrue ($ leaf -> isLeafOf ($ ancestor ));
88+ self ::assertFalse ($ ancestor ->isLeafOf ( $ leaf ));
8989 }
9090
9191 public function test_is_root (): void
@@ -102,7 +102,7 @@ public function test_get_parent(): void
102102 {
103103 $ ltree = new Ltree (['a ' , 'b ' , 'c ' ]);
104104 $ parent = $ ltree ->getParent ();
105- self ::assertSame (['a ' , 'b ' ], $ parent ->getBranch ());
105+ self ::assertSame (['a ' , 'b ' ], $ parent ->getPathFromRoot ());
106106 self ::assertSame ('a.b ' , (string ) $ parent );
107107 }
108108
@@ -111,15 +111,15 @@ public function test_get_parent_respect_immutability(): void
111111 $ ltree = new Ltree (['a ' , 'b ' , 'c ' ]);
112112 $ parent = $ ltree ->getParent ();
113113 self ::assertNotSame ($ ltree , $ parent );
114- self ::assertSame (['a ' , 'b ' , 'c ' ], $ ltree ->getBranch ());
114+ self ::assertSame (['a ' , 'b ' , 'c ' ], $ ltree ->getPathFromRoot ());
115115 self ::assertSame ('a.b.c ' , (string ) $ ltree );
116116 }
117117
118118 public function test_get_parent_on_root (): void
119119 {
120120 $ ltree = new Ltree (['a ' ]);
121121 $ parent = $ ltree ->getParent ();
122- self ::assertSame ([], $ parent ->getBranch ());
122+ self ::assertSame ([], $ parent ->getPathFromRoot ());
123123 }
124124
125125 public function test_get_parent_throws_on_empty (): void
@@ -128,17 +128,17 @@ public function test_get_parent_throws_on_empty(): void
128128 (new Ltree ([]))->getParent ();
129129 }
130130
131- public function test_create_leaf_empty_throws (): void
131+ public function test_with_leaf_empty_throws (): void
132132 {
133133 $ ltree = new Ltree (['a ' ]);
134134 $ this ->expectException (\InvalidArgumentException::class);
135- $ ltree ->createLeaf ('' ); // @phpstan-ignore argument.type
135+ $ ltree ->withLeaf ('' ); // @phpstan-ignore argument.type
136136 }
137137
138- public function test_create_leaf_with_dot_throws (): void
138+ public function test_with_leaf_with_dot_throws (): void
139139 {
140140 $ ltree = new Ltree (['a ' ]);
141141 $ this ->expectException (\InvalidArgumentException::class);
142- $ ltree ->createLeaf ('foo.bar ' );
142+ $ ltree ->withLeaf ('foo.bar ' );
143143 }
144144}
0 commit comments