diff --git a/src/Engines/ElasticSearchEngine.php b/src/Engines/ElasticSearchEngine.php index 559fe7be..96c067ba 100644 --- a/src/Engines/ElasticSearchEngine.php +++ b/src/Engines/ElasticSearchEngine.php @@ -8,7 +8,6 @@ use Laravel\Scout\Builder as BaseBuilder; use Illuminate\Database\Eloquent\Collection; use ONGR\ElasticsearchDSL\Query\MatchAllQuery; -use Matchish\ScoutElasticSearch\ElasticSearch\Index; use Matchish\ScoutElasticSearch\ElasticSearch\Params\Bulk; use Matchish\ScoutElasticSearch\ElasticSearch\SearchFactory; use Matchish\ScoutElasticSearch\ElasticSearch\SearchResults; diff --git a/tests/Feature/ImportCommandTest.php b/tests/Feature/ImportCommandTest.php index bcb515b0..1b9516d1 100644 --- a/tests/Feature/ImportCommandTest.php +++ b/tests/Feature/ImportCommandTest.php @@ -22,6 +22,9 @@ public function test_import_entites(): void factory(Product::class, $productsAmount)->create(); + $productsUnsearchableAmount = rand(1, 5); + factory(Product::class, $productsUnsearchableAmount)->states(['archive'])->create(); + Product::setEventDispatcher($dispatcher); Artisan::call('scout:import', [ @@ -47,7 +50,6 @@ public function test_import_entites_in_queue(): void Product::unsetEventDispatcher(); $productsAmount = rand(1, 5); - factory(Product::class, $productsAmount)->create(); Product::setEventDispatcher($dispatcher); diff --git a/tests/laravel/app/Product.php b/tests/laravel/app/Product.php index f48250b9..e815f9d6 100644 --- a/tests/laravel/app/Product.php +++ b/tests/laravel/app/Product.php @@ -27,4 +27,9 @@ public function getScoutKey() { return $this->getAttribute($this->getScoutKeyName()); } + + public function shouldBeSearchable() + { + return $this->type != 'archive'; + } } diff --git a/tests/laravel/database/factories/ProductFactory.php b/tests/laravel/database/factories/ProductFactory.php index da6331d1..c868d759 100644 --- a/tests/laravel/database/factories/ProductFactory.php +++ b/tests/laravel/database/factories/ProductFactory.php @@ -45,6 +45,12 @@ ]; }); +$factory->state(Product::class, 'archive', function (Faker $faker) { + return [ + 'type' => 'archive', + ]; +}); + $factory->state(Product::class, 'new', function (Faker $faker) { return [ 'type' => 'new',