|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +use PDPhilip\Elasticsearch\Tests\Models\IdGenerated\Product; |
| 6 | + |
| 7 | +beforeEach(function () { |
| 8 | + Product::executeSchema(); |
| 9 | + |
| 10 | + Product::insert([ |
| 11 | + ['product' => 'chocolate', 'price' => 5], |
| 12 | + ['product' => 'pumpkin', 'price' => 30], |
| 13 | + ['product' => 'apple', 'price' => 10], |
| 14 | + ['product' => 'orange juice', 'price' => 5], |
| 15 | + ['product' => 'coffee', 'price' => 15], |
| 16 | + ['product' => 'tea', 'price' => 12], |
| 17 | + ['product' => 'cookies', 'price' => 5], |
| 18 | + ['product' => 'ice cream', 'price' => 22], |
| 19 | + ['product' => 'bagel', 'price' => 8], |
| 20 | + ['product' => 'salad', 'price' => 14], |
| 21 | + ['product' => 'sandwich', 'price' => 5], |
| 22 | + ['product' => 'pizza', 'price' => 45], |
| 23 | + ['product' => 'water', 'price' => 5], |
| 24 | + ['product' => 'soda', 'price' => 5], |
| 25 | + ]); |
| 26 | +}); |
| 27 | + |
| 28 | +it('tests where clause', function () { |
| 29 | + |
| 30 | + class ProductWithLimit extends Product |
| 31 | + { |
| 32 | + protected $defaultLimit = 7; |
| 33 | + } |
| 34 | + |
| 35 | + class ProductWithDefaultConnectionLimit extends Product |
| 36 | + { |
| 37 | + protected $connection = 'elasticsearch_with_default_limit'; |
| 38 | + } |
| 39 | + |
| 40 | + $products = ProductWithLimit::all(); |
| 41 | + expect($products)->toHaveCount(7); |
| 42 | + |
| 43 | + $products = ProductWithDefaultConnectionLimit::all(); |
| 44 | + expect($products)->toHaveCount(4); |
| 45 | + |
| 46 | + $products = ProductWithLimit::limit(3)->get(); |
| 47 | + expect($products)->toHaveCount(3); |
| 48 | +}); |
0 commit comments