|
2 | 2 |
|
3 | 3 | declare(strict_types=1); |
4 | 4 |
|
| 5 | +use Elastic\Elasticsearch\Client; |
5 | 6 | use Illuminate\Support\Facades\DB; |
6 | 7 | use PDPhilip\Elasticsearch\Connection; |
7 | 8 | use PDPhilip\Elasticsearch\Schema\Builder as SchemaBuilder; |
8 | | -use Elastic\Elasticsearch\Client; |
9 | 9 |
|
10 | 10 | test('Connection', function () { |
11 | 11 | $connection = DB::connection('elasticsearch'); |
|
27 | 27 | }); |
28 | 28 |
|
29 | 29 | test('Disconnect And Create New Connection', function () { |
30 | | - $connection = DB::connection('elasticsearch'); |
31 | | - expect($connection)->toBeInstanceOf(Connection::class); |
32 | | - $client = $connection->getClient(); |
33 | | - expect($client)->toBeInstanceOf(Client::class); |
| 30 | + $connection = DB::connection('elasticsearch'); |
| 31 | + expect($connection)->toBeInstanceOf(Connection::class); |
| 32 | + $client = $connection->getClient(); |
| 33 | + expect($client)->toBeInstanceOf(Client::class); |
34 | 34 |
|
35 | | - $connection->disconnect(); |
36 | | - $client = $connection->getClient(); |
37 | | - expect($client)->toBeNull(); |
38 | | - DB::purge('elasticsearch'); |
| 35 | + $connection->disconnect(); |
| 36 | + $client = $connection->getClient(); |
| 37 | + expect($client)->toBeNull(); |
| 38 | + DB::purge('elasticsearch'); |
39 | 39 |
|
40 | | - $connection = DB::connection('elasticsearch'); |
41 | | - expect($connection)->toBeInstanceOf(Connection::class); |
42 | | - $client = $connection->getClient(); |
43 | | - expect($client)->toBeInstanceOf(Client::class); |
| 40 | + $connection = DB::connection('elasticsearch'); |
| 41 | + expect($connection)->toBeInstanceOf(Connection::class); |
| 42 | + $client = $connection->getClient(); |
| 43 | + expect($client)->toBeInstanceOf(Client::class); |
44 | 44 |
|
45 | 45 | }); |
46 | 46 |
|
47 | 47 | test('DB', function () { |
48 | | - $connection = DB::connection('elasticsearch'); |
49 | | - expect($connection->getClient())->toBeInstanceOf(Client::class); |
| 48 | + $connection = DB::connection('elasticsearch'); |
| 49 | + expect($connection->getClient())->toBeInstanceOf(Client::class); |
50 | 50 | }); |
51 | 51 |
|
52 | 52 | test('Connection Without auth_type', function () { |
53 | | - new Connection(['name' => 'test']); |
| 53 | + new Connection(['name' => 'test']); |
54 | 54 | })->throws(RuntimeException::class, 'Invalid [auth_type] in database config. Must be: http or cloud'); |
55 | 55 |
|
56 | 56 | test('Cloud Connection Without cloud_id', function () { |
57 | | - $this->expectException(RuntimeException::class); |
| 57 | + $this->expectException(RuntimeException::class); |
58 | 58 |
|
59 | | - new Connection(['name' => 'test', 'auth_type' => 'cloud']); |
| 59 | + new Connection(['name' => 'test', 'auth_type' => 'cloud']); |
60 | 60 | })->throws(RuntimeException::class, 'auth_type of `cloud` requires `cloud_id` to be set'); |
61 | 61 |
|
62 | 62 | test('Http Connection Without hosts', function () { |
63 | | - $this->expectException(RuntimeException::class); |
64 | | - $this->expectExceptionMessage('auth_type of `http` requires `hosts` to be set'); |
| 63 | + $this->expectException(RuntimeException::class); |
| 64 | + $this->expectExceptionMessage('auth_type of `http` requires `hosts` to be set'); |
65 | 65 |
|
66 | | - new Connection(['name' => 'test', 'auth_type' => 'http']); |
| 66 | + new Connection(['name' => 'test', 'auth_type' => 'http']); |
67 | 67 | })->throws(RuntimeException::class, 'auth_type of `http` requires `hosts` to be set and be an array'); |
68 | 68 |
|
69 | 69 | test('Prefix', function () { |
70 | | - $config = [ |
71 | | - 'name' => 'test', |
72 | | - 'auth_type' => 'http', |
73 | | - 'hosts' => ['http://localhost:9200'], |
74 | | - 'index_prefix' => 'prefix_', |
75 | | - ]; |
| 70 | + $config = [ |
| 71 | + 'name' => 'test', |
| 72 | + 'auth_type' => 'http', |
| 73 | + 'hosts' => ['http://localhost:9200'], |
| 74 | + 'index_prefix' => 'prefix_', |
| 75 | + ]; |
76 | 76 |
|
77 | | - $connection = new Connection($config); |
| 77 | + $connection = new Connection($config); |
78 | 78 |
|
79 | | - expect($connection->getIndexPrefix())->toBe('prefix_'); |
| 79 | + expect($connection->getIndexPrefix())->toBe('prefix_'); |
80 | 80 | }); |
81 | 81 |
|
82 | 82 | test('Schema Builder', function () { |
|
92 | 92 | test('Info', function () { |
93 | 93 | $info = DB::connection('elasticsearch')->getClientInfo(); |
94 | 94 | expect($info['cluster_name'])->toBe('elasticsearch') |
95 | | - ->and($info['tagline'])->toBe('You Know, for Search'); |
| 95 | + ->and($info['tagline'])->toBe('You Know, for Search'); |
96 | 96 | }); |
0 commit comments