public function test_map_correctly_maps_results_to_models() { $client = Mockery::mock('Elasticsearch\\Client'); $engine = new ElasticsearchEngine($client, 'scout'); $model = Mockery::mock('Illuminate\\Database\\Eloquent\\Model'); $model->shouldReceive('getKeyName')->andReturn('id'); $model->shouldReceive('whereIn')->once()->with('id', ['1'])->andReturn($model); $model->shouldReceive('get')->once()->andReturn(Collection::make([new ElasticsearchEngineTestModel()])); $results = $engine->map(['hits' => ['total' => '1', 'hits' => [['_id' => '1']]]], $model); $this->assertEquals(1, count($results)); }