public function testIteration() { $i = 0; $loop = new Loop(); $loop->execute(function () use($loop, &$i) { $i++; if ($i > 1) { $loop->end(); } }); $this->assertEquals(2, $i); }