@@ -236,14 +236,14 @@ public function testAncestorsReturnsAncestorsWithoutNodeItself()
236236
237237 public function testGetsAncestorsByStatic ()
238238 {
239- $ path = Category::ancestorsOf (3 )->lists ('name ' )-> all ( );
239+ $ path = all ( Category::ancestorsOf (3 )->lists ('name ' ));
240240
241241 $ this ->assertEquals (array ('store ' , 'notebooks ' ), $ path );
242242 }
243243
244244 public function testGetsAncestorsDirect ()
245245 {
246- $ path = Category::find (8 )->getAncestors ()->lists ('id ' )-> all ( );
246+ $ path = all ( Category::find (8 )->getAncestors ()->lists ('id ' ));
247247
248248 $ this ->assertEquals (array (1 , 5 , 7 ), $ path );
249249 }
@@ -264,7 +264,7 @@ public function testDescendants()
264264
265265 public function testWithDepthWorks ()
266266 {
267- $ nodes = Category::withDepth ()->limit (4 )->lists ('depth ' )-> all ( );
267+ $ nodes = all ( Category::withDepth ()->limit (4 )->lists ('depth ' ));
268268
269269 $ this ->assertEquals (array (0 , 1 , 2 , 2 ), $ nodes );
270270 }
@@ -592,15 +592,15 @@ public function testWhereDescendantsOf()
592592 public function testAncestorsByNode ()
593593 {
594594 $ category = $ this ->findCategory ('apple ' );
595- $ ancestors = Category::whereAncestorOf ($ category )->lists ('id ' )-> all ( );
595+ $ ancestors = all ( Category::whereAncestorOf ($ category )->lists ('id ' ));
596596
597597 $ this ->assertEquals ([ 1 , 2 ], $ ancestors );
598598 }
599599
600600 public function testDescendantsByNode ()
601601 {
602602 $ category = $ this ->findCategory ('notebooks ' );
603- $ res = Category::whereDescendantOf ($ category )->lists ('id ' )-> all ( );
603+ $ res = all ( Category::whereDescendantOf ($ category )->lists ('id ' ));
604604
605605 $ this ->assertEquals ([ 3 , 4 ], $ res );
606606 }
@@ -616,4 +616,9 @@ public function testMultipleDeletionsDoNotBrakeTree()
616616
617617 $ this ->assertTreeNotBroken ();
618618 }
619+ }
620+
621+ function all ($ items )
622+ {
623+ return is_array ($ items ) ? $ items : $ items ->all ();
619624}
0 commit comments