public function find($key, $default = null)
{
return array_first($this->items, function ($key, $model) use($key) {
return $model->getKey() == $key;
}, $default);
}
public function testFindMethodFindsModelById() { $mockModel = m::mock('LMongo\\Eloquent\\Model'); $mockModel->shouldReceive('getKey')->andReturn(1); $c = new Collection(array($mockModel)); $this->assertTrue($mockModel === $c->find(1)); }