@@ -49,9 +49,9 @@ protected function setUp() {
4949 */
5050 public function testFindDescendants() {
5151
52- $leaf = $this->nestedSet->getNode(7, 1);
52+ $node = $this->nestedSet->getNode(7, 1);
5353
54- $descendants = $this->nestedSet->findDescendants($leaf );
54+ $descendants = $this->nestedSet->findDescendants($node );
5555
5656 $this->assertCount(2, $descendants);
5757
@@ -74,14 +74,14 @@ public function testFindDescendants() {
7474 }
7575
7676 /**
77- * Tests finding descendants with depth .
77+ * Tests finding children .
7878 */
79- public function testFindDescendantsWithDepth () {
79+ public function testFindChildren () {
8080
81- $leaf = $this->nestedSet->getNode(3, 1);
81+ $node = $this->nestedSet->getNode(3, 1);
8282
8383 // Limit to 1 level deep to exclude grandchildren.
84- $descendants = $this->nestedSet->findDescendants($leaf, 1 );
84+ $descendants = $this->nestedSet->findChildren($node );
8585
8686 $this->assertCount(3, $descendants);
8787
@@ -119,9 +119,9 @@ public function testFindDescendantsWithDepth() {
119119 */
120120 public function testFindAncestors() {
121121
122- $leaf = $this->nestedSet->getNode(7, 1);
122+ $node = $this->nestedSet->getNode(7, 1);
123123
124- $ancestors = $this->nestedSet->findAncestors($leaf );
124+ $ancestors = $this->nestedSet->findAncestors($node );
125125
126126 $this->assertCount(3, $ancestors);
127127
@@ -144,177 +144,177 @@ public function testFindAncestors() {
144144 }
145145
146146 /**
147- * Tests adding a leaf .
147+ * Tests adding a node .
148148 */
149- public function testAddLeafWithExistingChildren () {
149+ public function testAddNodeWithExistingChildren () {
150150
151151 $parent = $this->nestedSet->getNode(3, 1);
152152 $child = new Node(12, 1);
153153
154- $newLeaf = $this->nestedSet->addNode($parent, $child);
154+ $newNode = $this->nestedSet->addNode($parent, $child);
155155
156156 // Should be inserted in right-most spot.
157- $this->assertEquals(21, $newLeaf ->getLeft());
158- $this->assertEquals(22, $newLeaf ->getRight());
157+ $this->assertEquals(21, $newNode ->getLeft());
158+ $this->assertEquals(22, $newNode ->getRight());
159159
160160 $tree = $this->nestedSet->getTree();
161161
162- // Parent leaf right should have incremented.
162+ // Parent node right should have incremented.
163163 $newParent = $this->nestedSet->getNode(3, 1);
164164 $this->assertEquals(10, $newParent->getLeft());
165165 $this->assertEquals(23, $newParent->getRight());
166166 }
167167
168168 /**
169- * Tests adding a leaf .
169+ * Tests adding a node .
170170 */
171- public function testAddLeafWithNoChildren () {
171+ public function testAddNodeWithNoChildren () {
172172
173173 $parent = $this->nestedSet->getNode(6, 1);
174174 $child = new Node(13, 1);
175175
176- $newLeaf = $this->nestedSet->addNode($parent, $child);
176+ $newNode = $this->nestedSet->addNode($parent, $child);
177177
178178 // Should be inserted below 6 with depth 4.
179- $this->assertEquals(7, $newLeaf ->getLeft());
180- $this->assertEquals(8, $newLeaf ->getRight());
181- $this->assertEquals(4, $newLeaf ->getDepth());
179+ $this->assertEquals(7, $newNode ->getLeft());
180+ $this->assertEquals(8, $newNode ->getRight());
181+ $this->assertEquals(4, $newNode ->getDepth());
182182
183- // Parent leaf right should have incremented.
183+ // Parent node right should have incremented.
184184 $newParent = $this->nestedSet->getNode(6, 1);
185185 $this->assertEquals(6, $newParent->getLeft());
186186 $this->assertEquals(9, $newParent->getRight());
187187 }
188188
189189 /**
190- * Tests deleting a leaf .
190+ * Tests deleting a node .
191191 */
192- public function testDeleteLeaf () {
193- $leaf = $this->nestedSet->getNode(4, 1);
192+ public function testDeleteNode () {
193+ $node = $this->nestedSet->getNode(4, 1);
194194
195- $this->nestedSet->deleteNode($leaf );
195+ $this->nestedSet->deleteNode($node );
196196
197- // Leaf should be deleted.
198- $leaf = $this->nestedSet->getNode(4, 1);
199- $this->assertNull($leaf );
197+ // Node should be deleted.
198+ $node = $this->nestedSet->getNode(4, 1);
199+ $this->assertNull($node );
200200
201201 // Children should be moved up.
202- $leaf = $this->nestedSet->getNode(5, 1);
203- $this->assertEquals(3, $leaf ->getLeft());
204- $this->assertEquals(4, $leaf ->getRight());
205- $this->assertEquals(2, $leaf ->getDepth());
202+ $node = $this->nestedSet->getNode(5, 1);
203+ $this->assertEquals(3, $node ->getLeft());
204+ $this->assertEquals(4, $node ->getRight());
205+ $this->assertEquals(2, $node ->getDepth());
206206
207- $leaf = $this->nestedSet->getNode(6, 1);
208- $this->assertEquals(5, $leaf ->getLeft());
209- $this->assertEquals(6, $leaf ->getRight());
210- $this->assertEquals(2, $leaf ->getDepth());
207+ $node = $this->nestedSet->getNode(6, 1);
208+ $this->assertEquals(5, $node ->getLeft());
209+ $this->assertEquals(6, $node ->getRight());
210+ $this->assertEquals(2, $node ->getDepth());
211211
212212 $tree = $this->nestedSet->getTree();
213213 $this->printTree($tree);
214214 }
215215
216216 /**
217- * Tests deleting a leaf and its sub-tree.
217+ * Tests deleting a node and its sub-tree.
218218 */
219219 public function testDeleteSubTree() {
220220
221- $leaf = $this->nestedSet->getNode(4, 1);
221+ $node = $this->nestedSet->getNode(4, 1);
222222
223- $this->nestedSet->deleteSubTree($leaf );
223+ $this->nestedSet->deleteSubTree($node );
224224
225- // Leaf should be deleted.
226- $leaf = $this->nestedSet->getNode(4, 1);
227- $this->assertNull($leaf );
225+ // Node should be deleted.
226+ $node = $this->nestedSet->getNode(4, 1);
227+ $this->assertNull($node );
228228
229229 // Children should be deleted.
230- $leaf = $this->nestedSet->getNode(5, 1);
231- $this->assertNull($leaf );
230+ $node = $this->nestedSet->getNode(5, 1);
231+ $this->assertNull($node );
232232
233- $leaf = $this->nestedSet->getNode(6, 1);
234- $this->assertNull($leaf );
233+ $node = $this->nestedSet->getNode(6, 1);
234+ $this->assertNull($node );
235235 }
236236
237237 /**
238- * Tests moving a sub-tree under a parent leaf .
238+ * Tests moving a sub-tree under a parent node .
239239 */
240240 public function testMoveSubTreeBelow() {
241241 print "BEFORE:" . PHP_EOL;
242242 $tree = $this->nestedSet->getTree();
243243 $this->printTree($tree);
244244
245245 $parent = $this->nestedSet->getNode(1, 1);
246- $leaf = $this->nestedSet->getNode(7, 1);
246+ $node = $this->nestedSet->getNode(7, 1);
247247
248- $this->nestedSet->moveSubTreeBelow($parent, $leaf );
248+ $this->nestedSet->moveSubTreeBelow($parent, $node );
249249
250250 print "AFTER:" . PHP_EOL;
251251 $tree = $this->nestedSet->getTree();
252252 $this->printTree($tree);
253253
254- // Check leaf is in new position.
255- $leaf = $this->nestedSet->getNode(7, 1);
256- $this->assertEquals(2, $leaf ->getLeft());
257- $this->assertEquals(7, $leaf ->getRight());
258- $this->assertEquals(1, $leaf ->getDepth());
254+ // Check node is in new position.
255+ $node = $this->nestedSet->getNode(7, 1);
256+ $this->assertEquals(2, $node ->getLeft());
257+ $this->assertEquals(7, $node ->getRight());
258+ $this->assertEquals(1, $node ->getDepth());
259259
260260 // Check children are in new position.
261- $leaf = $this->nestedSet->getNode(10, 1);
262- $this->assertEquals(3, $leaf ->getLeft());
263- $this->assertEquals(4, $leaf ->getRight());
264- $this->assertEquals(2, $leaf ->getDepth());
261+ $node = $this->nestedSet->getNode(10, 1);
262+ $this->assertEquals(3, $node ->getLeft());
263+ $this->assertEquals(4, $node ->getRight());
264+ $this->assertEquals(2, $node ->getDepth());
265265
266- $leaf = $this->nestedSet->getNode(11, 1);
267- $this->assertEquals(5, $leaf ->getLeft());
268- $this->assertEquals(6, $leaf ->getRight());
269- $this->assertEquals(2, $leaf ->getDepth());
266+ $node = $this->nestedSet->getNode(11, 1);
267+ $this->assertEquals(5, $node ->getLeft());
268+ $this->assertEquals(6, $node ->getRight());
269+ $this->assertEquals(2, $node ->getDepth());
270270
271271 // Check old parent is updated.
272- $leaf = $this->nestedSet->getNode(3, 1);
273- $this->assertEquals(16, $leaf ->getLeft());
274- $this->assertEquals(21, $leaf ->getRight());
275- $this->assertEquals(1, $leaf ->getDepth());
272+ $node = $this->nestedSet->getNode(3, 1);
273+ $this->assertEquals(16, $node ->getLeft());
274+ $this->assertEquals(21, $node ->getRight());
275+ $this->assertEquals(1, $node ->getDepth());
276276
277277 }
278278
279279 /**
280- * Tests moving a sub-tree before a target leaf .
280+ * Tests moving a sub-tree before a target node .
281281 */
282282 public function testMoveSubTreeBefore() {
283283 print "BEFORE:" . PHP_EOL;
284284 $tree = $this->nestedSet->getTree();
285285 $this->printTree($tree);
286286
287287 $target = $this->nestedSet->getNode(4, 1);
288- $leaf = $this->nestedSet->getNode(7, 1);
288+ $node = $this->nestedSet->getNode(7, 1);
289289
290- $this->nestedSet->moveSubTreeBefore($target, $leaf );
290+ $this->nestedSet->moveSubTreeBefore($target, $node );
291291
292292 print "AFTER:" . PHP_EOL;
293293 $tree = $this->nestedSet->getTree();
294294 $this->printTree($tree);
295295
296- // Check leaf is in new position.
297- $leaf = $this->nestedSet->getNode(7, 1);
298- $this->assertEquals(3, $leaf ->getLeft());
299- $this->assertEquals(8, $leaf ->getRight());
300- $this->assertEquals(2, $leaf ->getDepth());
296+ // Check node is in new position.
297+ $node = $this->nestedSet->getNode(7, 1);
298+ $this->assertEquals(3, $node ->getLeft());
299+ $this->assertEquals(8, $node ->getRight());
300+ $this->assertEquals(2, $node ->getDepth());
301301
302302 // Check children are in new position.
303- $leaf = $this->nestedSet->getNode(10, 1);
304- $this->assertEquals(4, $leaf ->getLeft());
305- $this->assertEquals(5, $leaf ->getRight());
306- $this->assertEquals(3, $leaf ->getDepth());
303+ $node = $this->nestedSet->getNode(10, 1);
304+ $this->assertEquals(4, $node ->getLeft());
305+ $this->assertEquals(5, $node ->getRight());
306+ $this->assertEquals(3, $node ->getDepth());
307307
308- $leaf = $this->nestedSet->getNode(11, 1);
309- $this->assertEquals(6, $leaf ->getLeft());
310- $this->assertEquals(7, $leaf ->getRight());
311- $this->assertEquals(3, $leaf ->getDepth());
308+ $node = $this->nestedSet->getNode(11, 1);
309+ $this->assertEquals(6, $node ->getLeft());
310+ $this->assertEquals(7, $node ->getRight());
311+ $this->assertEquals(3, $node ->getDepth());
312312
313313 // Check old parent is updated.
314- $leaf = $this->nestedSet->getNode(3, 1);
315- $this->assertEquals(16, $leaf ->getLeft());
316- $this->assertEquals(21, $leaf ->getRight());
317- $this->assertEquals(1, $leaf ->getDepth());
314+ $node = $this->nestedSet->getNode(3, 1);
315+ $this->assertEquals(16, $node ->getLeft());
316+ $this->assertEquals(21, $node ->getRight());
317+ $this->assertEquals(1, $node ->getDepth());
318318
319319 }
320320
@@ -440,15 +440,15 @@ public function printTree($tree) {
440440 $table = new Console_Table(CONSOLE_TABLE_ALIGN_RIGHT);
441441 $table->setHeaders(['ID', 'Rev', 'Left', 'Right', 'Depth']);
442442 $table->setAlign(0, CONSOLE_TABLE_ALIGN_LEFT);
443- /** @var Node $leaf */
444- foreach ($tree as $leaf ) {
445- $indent = str_repeat('-', $leaf ->getDepth());
443+ /** @var Node $node */
444+ foreach ($tree as $node ) {
445+ $indent = str_repeat('-', $node ->getDepth());
446446 $table->addRow([
447- $indent . $leaf ->getId(),
448- $leaf ->getRevisionId(),
449- $leaf ->getLeft(),
450- $leaf ->getRight(),
451- $leaf ->getDepth(),
447+ $indent . $node ->getId(),
448+ $node ->getRevisionId(),
449+ $node ->getLeft(),
450+ $node ->getRight(),
451+ $node ->getDepth(),
452452 ]);
453453 }
454454 echo $table->getTable();
0 commit comments