diff --git a/Model/Model/ElasticSearchIndexer.php b/Model/Model/ElasticSearchIndexer.php index d18d838..08f7ddb 100644 --- a/Model/Model/ElasticSearchIndexer.php +++ b/Model/Model/ElasticSearchIndexer.php @@ -26,7 +26,7 @@ public function reindexOne($model, array $relations = null) $this->reindexMany($this->getRelationItems($model, $relation), []); } - return $model->updateIndex(); + return $model->addToIndex(); } /** diff --git a/Model/Model/IndexedModel.php b/Model/Model/IndexedModel.php index 341dc18..d0a5126 100644 --- a/Model/Model/IndexedModel.php +++ b/Model/Model/IndexedModel.php @@ -196,7 +196,7 @@ function (IndexedModel $model) { static::updated( function (IndexedModel $model) { - $model->updateIndex(); + $model->addToIndex(); return true; }, PHP_INT_MAX diff --git a/tests/ElasticSearchIndexerTest.php b/tests/ElasticSearchIndexerTest.php index 1551e28..2e1e195 100644 --- a/tests/ElasticSearchIndexerTest.php +++ b/tests/ElasticSearchIndexerTest.php @@ -33,7 +33,7 @@ public function testReindexOneWithAllRelations() /** @var IndexedModel $related */ $related = \Mockery::mock(IndexedModel::class)->makePartial(); - $related->shouldReceive('updateIndex')->twice(); + $related->shouldReceive('addToIndex')->twice(); $relation = \Mockery::mock(Relation::class)->makePartial(); $relation->shouldReceive('getResults')->once()->andReturn([$related]); // Relation returns collection @@ -41,11 +41,11 @@ public function testReindexOneWithAllRelations() $entity = $this->makeEntityMock(); - $entity->shouldReceive('updateIndex')->once()->andReturn([]); + $entity->shouldReceive('addToIndex')->once()->andReturn([]); $entity->shouldReceive('secondTestEntities')->once()->andReturn($relation); $entity->shouldReceive('testMany')->once()->andReturn($relation); - $this->assertIsArray($esi->reindexOne($entity)); // Assert method returns result of $entity->updateIndex() + $this->assertIsArray($esi->reindexOne($entity)); // Assert method returns result of $entity->addToIndex() } public function testReindexOneWithSpecifiedRelations() @@ -56,7 +56,7 @@ public function testReindexOneWithSpecifiedRelations() $relation = \Mockery::mock(Relation::class)->makePartial(); $relation->shouldReceive('getResults')->once()->andReturn([]); - $entity->shouldReceive('updateIndex')->once(); + $entity->shouldReceive('addToIndex')->once(); $entity->shouldReceive('secondTestEntities')->once()->andReturn($relation); $esi->reindexOne($entity, ['secondTestEntities', 'nonexistantRelation']); @@ -67,7 +67,7 @@ public function testReindexOneWithDisabledRelations() $esi = $this->makeIndexer(); $entity = $this->makeEntityMock(); - $entity->shouldReceive('updateIndex')->once(); + $entity->shouldReceive('addToIndex')->once(); $esi->reindexOne($entity, []); } @@ -84,7 +84,7 @@ public function testReindexOneNotInConfig() $esi = new ElasticSearchIndexer([]); $entity = $this->makeEntityMock(); - $entity->shouldReceive('updateIndex')->once(); + $entity->shouldReceive('addToIndex')->once(); $esi->reindexOne($entity); } @@ -116,7 +116,7 @@ public function testDeleteOne() $esi = $this->makeIndexer(); $related = $this->makeEntityMock(); - $related->shouldReceive('updateIndex')->once(); + $related->shouldReceive('addToIndex')->once(); $relation = \Mockery::mock(Relation::class); $relation->shouldReceive('getResults')->once()->andReturn([$related]);