|
@@ 119-129 (lines=11) @@
|
| 116 |
|
$this->assertInstanceOf(ElasticsearchModel::class, $product); |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
public function testUpdate() |
| 120 |
|
{ |
| 121 |
|
$product = Product::find(1); |
| 122 |
|
$product->name = 'Product 2'; |
| 123 |
|
$this->sleep(3); |
| 124 |
|
$product->save(); |
| 125 |
|
|
| 126 |
|
$res = $this->es->get($product->getPath()->toArray()); |
| 127 |
|
$this->assertEquals('Product 2', $res['_source']['name']); |
| 128 |
|
$this->assertNotSame($res['_source']['created_at'], $res['_source']['updated_at']); |
| 129 |
|
} |
| 130 |
|
|
| 131 |
|
public function testFindOrFail() |
| 132 |
|
{ |
|
@@ 182-192 (lines=11) @@
|
| 179 |
|
$this->assertNull($product); |
| 180 |
|
} |
| 181 |
|
|
| 182 |
|
public function testPartialUpdate() |
| 183 |
|
{ |
| 184 |
|
$product = Product::find(1, ['name']); |
| 185 |
|
$product->name = 'Product 3'; |
| 186 |
|
$product->save('name'); |
| 187 |
|
|
| 188 |
|
$res = $this->es->get($product->getPath()->toArray()); |
| 189 |
|
|
| 190 |
|
$this->assertEquals('Product 3', $res['_source']['name']); |
| 191 |
|
$this->assertEquals(20, $res['_source']['price']); |
| 192 |
|
} |
| 193 |
|
|
| 194 |
|
public function testBasicSearch() |
| 195 |
|
{ |