| 1 | <?php |
||
| 18 | class PruneCollectionTest extends UnitTestCase |
||
| 19 | { |
||
| 20 | public function testPruneFiltersCollectionInPlace() |
||
| 21 | { |
||
| 22 | $coll = Factory::create($this->fixtures['names']); |
||
| 23 | $this->assertCount(10, $coll); |
||
| 24 | $this->assertSame( |
||
| 25 | $coll, |
||
| 26 | $coll->prune( |
||
| 27 | function ($value, $key) { |
||
| 28 | return $key % 2 == 0; |
||
| 29 | } |
||
| 30 | ) |
||
| 31 | ); |
||
| 32 | $this->assertCount(5, $coll); |
||
| 33 | $this->assertSame( |
||
| 34 | $coll, |
||
| 35 | $coll->prune( |
||
| 36 | function ($value, $key) { |
||
| 37 | return strlen($value) >= 6; |
||
| 38 | } |
||
| 39 | ) |
||
| 40 | ); |
||
| 41 | $this->assertCount(3, $coll); |
||
| 42 | } |
||
| 43 | } |
||
| 44 |