Skip to content

Commit

Permalink
Merge pull request #61 from matchish/no-import-unsearchable
Browse files Browse the repository at this point in the history
Test no import unsearchable
  • Loading branch information
matchish authored Oct 9, 2019
2 parents ce0faf4 + 89f1656 commit 27a9c7e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/Engines/ElasticSearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion tests/Feature/ImportCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand All @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions tests/laravel/app/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ public function getScoutKey()
{
return $this->getAttribute($this->getScoutKeyName());
}

public function shouldBeSearchable()
{
return $this->type != 'archive';
}
}
6 changes: 6 additions & 0 deletions tests/laravel/database/factories/ProductFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 27a9c7e

Please sign in to comment.