|
4 | 4 |
|
5 | 5 | namespace App\Http\Controllers;
|
6 | 6 |
|
| 7 | +use App\Models\Inventory; |
| 8 | +use App\Models\Order; |
| 9 | +use App\Models\Sale; |
7 | 10 | use DateTimeImmutable;
|
8 | 11 | use MongoDB\BSON\UTCDateTime;
|
9 | 12 | use MongoDB\Builder\Accumulator;
|
|
13 | 16 | use MongoDB\Builder\Type\Sort;
|
14 | 17 | use MongoDB\Laravel\Tests\Models\User;
|
15 | 18 | use MongoDB\Laravel\Tests\TestCase;
|
16 |
| -use App\Models\Sale; |
17 |
| -use App\Models\Order; |
18 |
| -use App\Models\Inventory; |
19 | 19 |
|
20 | 20 | class AggregationsBuilderTest extends TestCase
|
21 | 21 | {
|
@@ -188,39 +188,39 @@ public function testAggregationBuilderUnwind(): void
|
188 | 188 |
|
189 | 189 | Sale::insert([
|
190 | 190 | [
|
191 |
| - '_id' => "1", |
| 191 | + '_id' => '1', |
192 | 192 | 'items' => [
|
193 | 193 | [
|
194 | 194 | 'name' => 'pens',
|
195 | 195 | 'tags' => ['writing', 'office', 'school', 'stationary'],
|
196 | 196 | 'price' => new Decimal128('12.00'),
|
197 |
| - 'quantity' => 5 |
| 197 | + 'quantity' => 5, |
198 | 198 | ],
|
199 | 199 | [
|
200 | 200 | 'name' => 'envelopes',
|
201 | 201 | 'tags' => ['stationary', 'office'],
|
202 | 202 | 'price' => new Decimal128('19.95'),
|
203 |
| - 'quantity' => 8 |
204 |
| - ] |
205 |
| - ] |
| 203 | + 'quantity' => 8, |
| 204 | + ], |
| 205 | + ], |
206 | 206 | ],
|
207 | 207 | [
|
208 |
| - '_id' => "2", |
| 208 | + '_id' => '2', |
209 | 209 | 'items' => [
|
210 | 210 | [
|
211 | 211 | 'name' => 'laptop',
|
212 | 212 | 'tags' => ['office', 'electronics'],
|
213 | 213 | 'price' => new Decimal128('800.00'),
|
214 |
| - 'quantity' => 1 |
| 214 | + 'quantity' => 1, |
215 | 215 | ],
|
216 | 216 | [
|
217 | 217 | 'name' => 'notepad',
|
218 | 218 | 'tags' => ['stationary', 'school'],
|
219 | 219 | 'price' => new Decimal128('14.95'),
|
220 |
| - 'quantity' => 3 |
221 |
| - ] |
222 |
| - ] |
223 |
| - ] |
| 220 | + 'quantity' => 3, |
| 221 | + ], |
| 222 | + ], |
| 223 | + ], |
224 | 224 | ]);
|
225 | 225 |
|
226 | 226 | // start-builder-unwind
|
@@ -254,52 +254,52 @@ public function testAggregationBuilderLookup(): void
|
254 | 254 | '_id' => 1,
|
255 | 255 | 'item' => 'almonds',
|
256 | 256 | 'price' => 12,
|
257 |
| - 'quantity' => 2 |
| 257 | + 'quantity' => 2, |
258 | 258 | ],
|
259 | 259 | [
|
260 | 260 | '_id' => 2,
|
261 | 261 | 'item' => 'pecans',
|
262 | 262 | 'price' => 20,
|
263 |
| - 'quantity' => 1 |
| 263 | + 'quantity' => 1, |
264 | 264 | ],
|
265 | 265 | [
|
266 |
| - '_id' => 3 |
267 |
| - ] |
| 266 | + '_id' => 3, |
| 267 | + ], |
268 | 268 | ]);
|
269 | 269 |
|
270 | 270 | Inventory::insert([
|
271 | 271 | [
|
272 | 272 | '_id' => 1,
|
273 | 273 | 'sku' => 'almonds',
|
274 | 274 | 'description' => 'product 1',
|
275 |
| - 'instock' => 120 |
| 275 | + 'instock' => 120, |
276 | 276 | ],
|
277 | 277 | [
|
278 | 278 | '_id' => 2,
|
279 | 279 | 'sku' => 'bread',
|
280 | 280 | 'description' => 'product 2',
|
281 |
| - 'instock' => 80 |
| 281 | + 'instock' => 80, |
282 | 282 | ],
|
283 | 283 | [
|
284 | 284 | '_id' => 3,
|
285 | 285 | 'sku' => 'cashews',
|
286 | 286 | 'description' => 'product 3',
|
287 |
| - 'instock' => 60 |
| 287 | + 'instock' => 60, |
288 | 288 | ],
|
289 | 289 | [
|
290 | 290 | '_id' => 4,
|
291 | 291 | 'sku' => 'pecans',
|
292 | 292 | 'description' => 'product 4',
|
293 |
| - 'instock' => 70 |
| 293 | + 'instock' => 70, |
294 | 294 | ],
|
295 | 295 | [
|
296 | 296 | '_id' => 5,
|
297 | 297 | 'sku' => null,
|
298 |
| - 'description' => 'Incomplete' |
| 298 | + 'description' => 'Incomplete', |
299 | 299 | ],
|
300 | 300 | [
|
301 |
| - '_id' => 6 |
302 |
| - ] |
| 301 | + '_id' => 6, |
| 302 | + ], |
303 | 303 | ]);
|
304 | 304 |
|
305 | 305 | // start-builder-lookup
|
|
0 commit comments