/** * Test that paged results are what we expect. * * @dataProvider file_indexing_provider */ public function test_manager_paged_search($fileindexing) { $this->engine->test_set_config('fileindexing', $fileindexing); $user = self::getDataGenerator()->create_user(); $this->setup_user_hidden_docs($user); $this->search->index(); // Check that user 1 sees all their results. $this->setUser($user); $querydata = new stdClass(); $querydata->q = 'Something1 Something2 Something3 Something4'; // On this first page, it should have determined the first 10 of 40 are bad, so there could be up to 30 left. $results = $this->search->paged_search($querydata, 0); $this->assertEquals(30, $results->totalcount); $this->assertCount(10, $results->results); $this->assertEquals(0, $results->actualpage); // On the second page, it should have found the next 10 bad ones, so we no know there are only 20 total. $results = $this->search->paged_search($querydata, 1); $this->assertEquals(20, $results->totalcount); $this->assertCount(10, $results->results); $this->assertEquals(1, $results->actualpage); // Try to get an additional page - we should get back page 1 results, since that is the last page with valid results. $results = $this->search->paged_search($querydata, 2); $this->assertEquals(20, $results->totalcount); $this->assertCount(10, $results->results); $this->assertEquals(1, $results->actualpage); }
public function test_delete() { $this->search->index(); $querydata = new stdClass(); $querydata->q = 'message'; $this->assertCount(2, $this->search->search($querydata)); $areaid = \core_search\manager::generate_areaid('core_mocksearch', 'role_capabilities'); $this->search->delete_index($areaid); cache_helper::purge_by_definition('core', 'search_results'); $this->assertCount(0, $this->search->search($querydata)); }