|
8 | 8 | use Illuminate\Database\Eloquent\Model;
|
9 | 9 | use ScoutEngines\Postgres\PostgresEngine;
|
10 | 10 | use Illuminate\Database\Eloquent\Collection;
|
| 11 | +use Illuminate\Database\Eloquent\SoftDeletes; |
11 | 12 | use Illuminate\Database\ConnectionResolverInterface;
|
12 | 13 |
|
13 | 14 | class PostgresEngineTest extends AbstractTestCase
|
@@ -40,6 +41,7 @@ public function test_update_adds_object_to_index()
|
40 | 41 | $table->shouldReceive('where')
|
41 | 42 | ->with('id', '=', 1)
|
42 | 43 | ->andReturnSelf();
|
| 44 | + |
43 | 45 | $table->shouldReceive('update')
|
44 | 46 | ->with(['searchable' => 'foo']);
|
45 | 47 |
|
@@ -152,6 +154,25 @@ public function test_search_with_model_config()
|
152 | 154 | $engine->search($builder);
|
153 | 155 | }
|
154 | 156 |
|
| 157 | + public function test_search_with_soft_delete() |
| 158 | + { |
| 159 | + list($engine, $db) = $this->getEngine(); |
| 160 | + |
| 161 | + $table = $this->setDbExpectations($db); |
| 162 | + |
| 163 | + $table->shouldReceive('skip')->with(0)->andReturnSelf() |
| 164 | + ->shouldReceive('limit')->with(5)->andReturnSelf() |
| 165 | + ->shouldReceive('where')->with('bar', 1)->andReturnSelf() |
| 166 | + ->shouldReceive('where')->with('deleted_at', null); |
| 167 | + |
| 168 | + $db->shouldReceive('select')->with(null, [null, 'foo', 1]); |
| 169 | + |
| 170 | + $builder = new Builder(new SoftDeletableTestModel(), 'foo'); |
| 171 | + $builder->where('bar', 1)->take(5); |
| 172 | + |
| 173 | + $engine->search($builder); |
| 174 | + } |
| 175 | + |
155 | 176 | public function test_map_correctly_maps_results_to_models()
|
156 | 177 | {
|
157 | 178 | list($engine) = $this->getEngine();
|
@@ -244,8 +265,6 @@ class TestModel extends Model
|
244 | 265 | {
|
245 | 266 | public $id = 1;
|
246 | 267 |
|
247 |
| -// public $text = 'Foo'; |
248 |
| - |
249 | 268 | public $searchableOptions = [
|
250 | 269 | 'rank' => [
|
251 | 270 | 'fields' => [
|
@@ -296,3 +315,8 @@ public function searchableAdditionalArray()
|
296 | 315 | return $this->searchableAdditionalArray;
|
297 | 316 | }
|
298 | 317 | }
|
| 318 | + |
| 319 | +class SoftDeletableTestModel extends TestModel |
| 320 | +{ |
| 321 | + use SoftDeletes; |
| 322 | +} |
0 commit comments