public function testModels() { $this->search->shouldReceive('config->models')->with([1, 2, 3, 4, 5], ['limit' => 2, 'offset' => 3])->andReturn([[1, 2, 3, 4, 5], 5]); $this->assertEquals(Collection::make([1, 2, 3, 4, 5]), $this->runner->models('test', ['limit' => 2, 'offset' => 3])); $this->assertEquals(5, $this->runner->getCachedCount('test')); $this->assertEquals(0, $this->runner->getCachedCount('other test')); }
/** * Execute the current query and return the total number of results. * * @return int */ public function count() { $this->filter->applyFilters($this->query); $count = $this->runner->getCachedCount($this->query); if ($count === null) { $count = count($this->runner->models($this->query)); } return $count; }