/** * Test the collect method. */ public function testCollect() { $instance = new Stream([1, 2, 3, 4]); $collector = $this->getMockBuilder('phpstreams\\Collector')->getMock(); $collector->expects($this->exactly(4))->method('add'); $collector->expects($this->once())->method('get')->willReturn(42); $this->assertEquals(42, $instance->collect($collector)); }