Skip to content

Commit 68bf475

Browse files
committed
Use pluck instead of lists
1 parent cd571fe commit 68bf475

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tests/NodeTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -258,42 +258,42 @@ public function testWithoutRootWorks()
258258
public function testAncestorsReturnsAncestorsWithoutNodeItself()
259259
{
260260
$node = $this->findCategory('apple');
261-
$path = all($node->ancestors()->lists('name'));
261+
$path = all($node->ancestors()->pluck('name'));
262262

263263
$this->assertEquals(array('store', 'notebooks'), $path);
264264
}
265265

266266
public function testGetsAncestorsByStatic()
267267
{
268-
$path = all(Category::ancestorsOf(3)->lists('name'));
268+
$path = all(Category::ancestorsOf(3)->pluck('name'));
269269

270270
$this->assertEquals(array('store', 'notebooks'), $path);
271271
}
272272

273273
public function testGetsAncestorsDirect()
274274
{
275-
$path = all(Category::find(8)->getAncestors()->lists('id'));
275+
$path = all(Category::find(8)->getAncestors()->pluck('id'));
276276

277277
$this->assertEquals(array(1, 5, 7), $path);
278278
}
279279

280280
public function testDescendants()
281281
{
282282
$node = $this->findCategory('mobile');
283-
$descendants = all($node->descendants()->lists('name'));
283+
$descendants = all($node->descendants()->pluck('name'));
284284
$expected = array('nokia', 'samsung', 'galaxy', 'sony', 'lenovo');
285285

286286
$this->assertEquals($expected, $descendants);
287287

288-
$descendants = all($node->getDescendants()->lists('name'));
288+
$descendants = all($node->getDescendants()->pluck('name'));
289289

290290
$this->assertEquals(count($descendants), $node->getDescendantCount());
291291
$this->assertEquals($expected, $descendants);
292292
}
293293

294294
public function testWithDepthWorks()
295295
{
296-
$nodes = all(Category::withDepth()->limit(4)->lists('depth'));
296+
$nodes = all(Category::withDepth()->limit(4)->pluck('depth'));
297297

298298
$this->assertEquals(array(0, 1, 2, 2), $nodes);
299299
}
@@ -408,17 +408,17 @@ public function testFailsToSaveNodeUntilParentIsSaved()
408408
public function testSiblings()
409409
{
410410
$node = $this->findCategory('samsung');
411-
$siblings = all($node->siblings()->lists('id'));
412-
$next = all($node->nextSiblings()->lists('id'));
413-
$prev = all($node->prevSiblings()->lists('id'));
411+
$siblings = all($node->siblings()->pluck('id'));
412+
$next = all($node->nextSiblings()->pluck('id'));
413+
$prev = all($node->prevSiblings()->pluck('id'));
414414

415415
$this->assertEquals(array(6, 9, 10), $siblings);
416416
$this->assertEquals(array(9, 10), $next);
417417
$this->assertEquals(array(6), $prev);
418418

419-
$siblings = all($node->getSiblings()->lists('id'));
420-
$next = all($node->getNextSiblings()->lists('id'));
421-
$prev = all($node->getPrevSiblings()->lists('id'));
419+
$siblings = all($node->getSiblings()->pluck('id'));
420+
$next = all($node->getNextSiblings()->pluck('id'));
421+
$prev = all($node->getPrevSiblings()->pluck('id'));
422422

423423
$this->assertEquals(array(6, 9, 10), $siblings);
424424
$this->assertEquals(array(9, 10), $next);
@@ -641,15 +641,15 @@ public function testWhereDescendantsOf()
641641
public function testAncestorsByNode()
642642
{
643643
$category = $this->findCategory('apple');
644-
$ancestors = all(Category::whereAncestorOf($category)->lists('id'));
644+
$ancestors = all(Category::whereAncestorOf($category)->pluck('id'));
645645

646646
$this->assertEquals([ 1, 2 ], $ancestors);
647647
}
648648

649649
public function testDescendantsByNode()
650650
{
651651
$category = $this->findCategory('notebooks');
652-
$res = all(Category::whereDescendantOf($category)->lists('id'));
652+
$res = all(Category::whereDescendantOf($category)->pluck('id'));
653653

654654
$this->assertEquals([ 3, 4 ], $res);
655655
}

0 commit comments

Comments
 (0)