/** @test */ public function it_can_reindex_the_given_active_query() { $activeRecord1 = new DummyActiveRecordModel(); $activeRecord1->test = 'reindex'; $activeRecord1->otherProperty = 'indexable'; $activeRecord1->save(); $activeRecord2 = new DummyActiveRecordModel(); $activeRecord2->test = 'reindex'; $activeRecord2->otherProperty = 'notIndexable'; $activeRecord2->save(); $indexName = $activeRecord1->getIndices()[0]; $index = $this->algoliaManager->initIndex($indexName); // Add dummy object to the index so it exists for the reindex operation. $response = $index->addObject(['dummy' => 'dummy'], 'dummy'); $index->waitTask($response['taskID']); $activeQuery = DummyActiveRecordModel::find()->where(['otherProperty' => 'indexable']); $response = $this->algoliaManager->reindexByActiveQuery($activeQuery); $index->waitTask($response[$index->indexName]['taskID']); $searchResult = $index->search('reindex'); $this->deleteIndex($index); $this->assertCount(1, $searchResult['hits']); }