Example #1
0
 /** @test */
 public function it_can_sum_a_collection_by_method_calls()
 {
     $item1 = m::mock('stdClass');
     $item2 = m::mock('stdClass');
     $item1->shouldReceive('getValue')->once()->andReturn(2);
     $item2->shouldReceive('getValue')->once()->andReturn(3);
     $collection = new Collection([$item1, $item2]);
     $this->assertEquals(5, $collection->sum('getValue'));
 }