@@ -23,18 +23,18 @@ public function testIndexMethod(): void
23
23
$ this ->assertSame ('test ' , $ builder ->getIndex ());
24
24
}
25
25
26
- public function testWhereMethod (): void
26
+ public function testWhereKeywordMethod (): void
27
27
{
28
- $ builder = Builder::query ()->where ('email ' , 'test@test.com ' );
28
+ $ builder = Builder::query ()->whereKeyword ('email ' , 'test@test.com ' );
29
29
30
30
$ this ->assertSame ([
31
31
'bool ' => ['filter ' => [['term ' => ['email.keyword ' => 'test@test.com ' ]]]]
32
32
], $ builder ->getQuery ());
33
33
}
34
34
35
- public function testWhereLikeMethod (): void
35
+ public function testWhereMethod (): void
36
36
{
37
- $ builder = Builder::query ()->whereLike ('name ' , 'test ' );
37
+ $ builder = Builder::query ()->where ('name ' , 'test ' );
38
38
39
39
$ this ->assertSame ([
40
40
'bool ' => ['filter ' => [['term ' => ['name ' => 'test ' ]]]]
@@ -77,7 +77,7 @@ public function testConditionableTrait(): void
77
77
{
78
78
$ builder = Builder::query ()->when (
79
79
true ,
80
- fn (Builder $ builder ) => $ builder ->where ('email ' , 'test@test.com ' )
80
+ fn (Builder $ builder ) => $ builder ->whereKeyword ('email ' , 'test@test.com ' )
81
81
);
82
82
83
83
$ this ->assertSame ([
@@ -86,7 +86,7 @@ public function testConditionableTrait(): void
86
86
87
87
$ builder = Builder::query ()->when (
88
88
false ,
89
- fn (Builder $ builder ) => $ builder ->where ('email ' , 'test@test.com ' )
89
+ fn (Builder $ builder ) => $ builder ->whereKeyword ('email ' , 'test@test.com ' )
90
90
);
91
91
92
92
$ this ->assertEmpty ($ builder ->getBody ());
@@ -95,9 +95,9 @@ public function testConditionableTrait(): void
95
95
public function testChainedMethods (): void
96
96
{
97
97
$ builder = Builder::query ()
98
- ->where ('email ' , 'test@test.com ' )
99
- ->where ('slug ' , 'test-slug ' )
100
- ->whereLike ('name ' , 'test ' )
98
+ ->whereKeyword ('email ' , 'test@test.com ' )
99
+ ->whereKeyword ('slug ' , 'test-slug ' )
100
+ ->where ('name ' , 'test ' )
101
101
->whereIn ('_id ' , [123 , 321 ])
102
102
->limit (10 );
103
103
@@ -134,12 +134,12 @@ public function testChainedMethods(): void
134
134
);
135
135
}
136
136
137
- public function testOrWhereMethod (): void
137
+ public function testOrWhereKeywordMethod (): void
138
138
{
139
139
$ builder = Builder::query ()
140
140
->index ('test ' )
141
- ->where ('email ' , 'test@test.com ' )
142
- ->orWhere ('username ' , 'tester ' );
141
+ ->whereKeyword ('email ' , 'test@test.com ' )
142
+ ->orWhereKeyword ('username ' , 'tester ' );
143
143
144
144
$ this ->assertSame (
145
145
[
@@ -155,7 +155,7 @@ public function testOrWhereMethod(): void
155
155
$ builder ->getQuery ()
156
156
);
157
157
158
- $ builder ->orWhere ('surname ' , 'tests ' );
158
+ $ builder ->orWhereKeyword ('surname ' , 'tests ' );
159
159
160
160
$ this ->assertSame (
161
161
[
@@ -173,12 +173,12 @@ public function testOrWhereMethod(): void
173
173
);
174
174
}
175
175
176
- public function testOrWhereLikeMethod (): void
176
+ public function testOrWhereMethod (): void
177
177
{
178
178
$ builder = Builder::query ()
179
179
->index ('test ' )
180
- ->whereLike ('email ' , 'test@test.com ' )
181
- ->orWhereLike ('username ' , 'tester ' );
180
+ ->where ('email ' , 'test@test.com ' )
181
+ ->orWhere ('username ' , 'tester ' );
182
182
183
183
$ this ->assertSame (
184
184
[
@@ -194,7 +194,7 @@ public function testOrWhereLikeMethod(): void
194
194
$ builder ->getQuery ()
195
195
);
196
196
197
- $ builder ->orWhereLike ('surname ' , 'tests ' );
197
+ $ builder ->orWhere ('surname ' , 'tests ' );
198
198
199
199
$ this ->assertSame (
200
200
[
@@ -364,4 +364,40 @@ public function testPaginateMethod(): void
364
364
$ this ->assertSame (10 , $ result ->getCurrentPage ());
365
365
$ this ->assertSame (100 , $ result ->getPerPage ());
366
366
}
367
+
368
+ public function testWhereLikeMethod (): void
369
+ {
370
+ $ builder = Builder::query ()->whereLike ('name ' , '*test* ' );
371
+
372
+ $ this ->assertSame ([
373
+ 'bool ' => ['filter ' => [['wildcard ' => ['name ' => '*test* ' ]]]]
374
+ ], $ builder ->getQuery ());
375
+ }
376
+
377
+ public function testOrWhereLikeMethod (): void
378
+ {
379
+ $ builder = Builder::query ()->orWhereLike ('name ' , '*test* ' );
380
+
381
+ $ this ->assertSame ([
382
+ 'bool ' => ['should ' => [['wildcard ' => ['name ' => '*test* ' ]]]]
383
+ ], $ builder ->getQuery ());
384
+ }
385
+
386
+ public function testWhereNotMethod (): void
387
+ {
388
+ $ builder = Builder::query ()->whereNot ('name ' , 'test ' );
389
+
390
+ $ this ->assertSame ([
391
+ 'bool ' => ['must_not ' => [['term ' => ['name ' => 'test ' ]]]]
392
+ ], $ builder ->getQuery ());
393
+ }
394
+
395
+ public function testOrWhereNotMethod (): void
396
+ {
397
+ $ builder = Builder::query ()->orWhereNot ('name ' , 'test ' );
398
+
399
+ $ this ->assertSame ([
400
+ 'bool ' => ['should ' => [['bool ' => ['must_not ' => [['term ' => ['name ' => 'test ' ]]]]]]]
401
+ ], $ builder ->getQuery ());
402
+ }
367
403
}
0 commit comments