/** * @dataProvider casesForEach */ public function testChainedEach($collection, $expected) { $self = $this; $iterated = array(); $iteratee = function ($value, $key, $collection2) use($self, $collection, &$iterated) { $self->assertSame($collection, $collection2); $iterated[] = $key . ' is ' . $value; }; $container = new Container($collection); $container->each($iteratee)->value(); $this->assertEquals($expected, $iterated); }