|
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 | {
|
@@ -192,39 +192,39 @@ public function testAggregationBuilderUnwind(): void
|
192 | 192 |
|
193 | 193 | Sale::insert([
|
194 | 194 | [
|
195 |
| - '_id' => "1", |
| 195 | + '_id' => '1', |
196 | 196 | 'items' => [
|
197 | 197 | [
|
198 | 198 | 'name' => 'pens',
|
199 | 199 | 'tags' => ['writing', 'office', 'school', 'stationary'],
|
200 | 200 | 'price' => new Decimal128('12.00'),
|
201 |
| - 'quantity' => 5 |
| 201 | + 'quantity' => 5, |
202 | 202 | ],
|
203 | 203 | [
|
204 | 204 | 'name' => 'envelopes',
|
205 | 205 | 'tags' => ['stationary', 'office'],
|
206 | 206 | 'price' => new Decimal128('19.95'),
|
207 |
| - 'quantity' => 8 |
208 |
| - ] |
209 |
| - ] |
| 207 | + 'quantity' => 8, |
| 208 | + ], |
| 209 | + ], |
210 | 210 | ],
|
211 | 211 | [
|
212 |
| - '_id' => "2", |
| 212 | + '_id' => '2', |
213 | 213 | 'items' => [
|
214 | 214 | [
|
215 | 215 | 'name' => 'laptop',
|
216 | 216 | 'tags' => ['office', 'electronics'],
|
217 | 217 | 'price' => new Decimal128('800.00'),
|
218 |
| - 'quantity' => 1 |
| 218 | + 'quantity' => 1, |
219 | 219 | ],
|
220 | 220 | [
|
221 | 221 | 'name' => 'notepad',
|
222 | 222 | 'tags' => ['stationary', 'school'],
|
223 | 223 | 'price' => new Decimal128('14.95'),
|
224 |
| - 'quantity' => 3 |
225 |
| - ] |
226 |
| - ] |
227 |
| - ] |
| 224 | + 'quantity' => 3, |
| 225 | + ], |
| 226 | + ], |
| 227 | + ], |
228 | 228 | ]);
|
229 | 229 |
|
230 | 230 | // start-builder-unwind
|
@@ -258,52 +258,52 @@ public function testAggregationBuilderLookup(): void
|
258 | 258 | '_id' => 1,
|
259 | 259 | 'item' => 'almonds',
|
260 | 260 | 'price' => 12,
|
261 |
| - 'quantity' => 2 |
| 261 | + 'quantity' => 2, |
262 | 262 | ],
|
263 | 263 | [
|
264 | 264 | '_id' => 2,
|
265 | 265 | 'item' => 'pecans',
|
266 | 266 | 'price' => 20,
|
267 |
| - 'quantity' => 1 |
| 267 | + 'quantity' => 1, |
268 | 268 | ],
|
269 | 269 | [
|
270 |
| - '_id' => 3 |
271 |
| - ] |
| 270 | + '_id' => 3, |
| 271 | + ], |
272 | 272 | ]);
|
273 | 273 |
|
274 | 274 | Inventory::insert([
|
275 | 275 | [
|
276 | 276 | '_id' => 1,
|
277 | 277 | 'sku' => 'almonds',
|
278 | 278 | 'description' => 'product 1',
|
279 |
| - 'instock' => 120 |
| 279 | + 'instock' => 120, |
280 | 280 | ],
|
281 | 281 | [
|
282 | 282 | '_id' => 2,
|
283 | 283 | 'sku' => 'bread',
|
284 | 284 | 'description' => 'product 2',
|
285 |
| - 'instock' => 80 |
| 285 | + 'instock' => 80, |
286 | 286 | ],
|
287 | 287 | [
|
288 | 288 | '_id' => 3,
|
289 | 289 | 'sku' => 'cashews',
|
290 | 290 | 'description' => 'product 3',
|
291 |
| - 'instock' => 60 |
| 291 | + 'instock' => 60, |
292 | 292 | ],
|
293 | 293 | [
|
294 | 294 | '_id' => 4,
|
295 | 295 | 'sku' => 'pecans',
|
296 | 296 | 'description' => 'product 4',
|
297 |
| - 'instock' => 70 |
| 297 | + 'instock' => 70, |
298 | 298 | ],
|
299 | 299 | [
|
300 | 300 | '_id' => 5,
|
301 | 301 | 'sku' => null,
|
302 |
| - 'description' => 'Incomplete' |
| 302 | + 'description' => 'Incomplete', |
303 | 303 | ],
|
304 | 304 | [
|
305 |
| - '_id' => 6 |
306 |
| - ] |
| 305 | + '_id' => 6, |
| 306 | + ], |
307 | 307 | ]);
|
308 | 308 |
|
309 | 309 | // start-builder-lookup
|
|
0 commit comments