@@ -69,7 +69,7 @@ public function testUpdate()
69
69
$ this ->assertEquals ('John Doe ' , $ check ->name );
70
70
$ this ->assertEquals (36 , $ check ->age );
71
71
72
- $ user ->update (array ( 'age ' => 20 ) );
72
+ $ user ->update ([ 'age ' => 20 ] );
73
73
74
74
$ raw = $ user ->getAttributes ();
75
75
$ this ->assertInstanceOf ('MongoId ' , $ raw ['_id ' ]);
@@ -180,10 +180,10 @@ public function testFind()
180
180
181
181
public function testGet ()
182
182
{
183
- User::insert (array (
184
- array ( 'name ' => 'John Doe ' ) ,
185
- array ( 'name ' => 'Jane Doe ' )
186
- ) );
183
+ User::insert ([
184
+ [ 'name ' => 'John Doe ' ] ,
185
+ [ 'name ' => 'Jane Doe ' ]
186
+ ] );
187
187
188
188
$ users = User::get ();
189
189
$ this ->assertEquals (2 , count ($ users ));
@@ -193,10 +193,10 @@ public function testGet()
193
193
194
194
public function testFirst ()
195
195
{
196
- User::insert (array (
197
- array ( 'name ' => 'John Doe ' ) ,
198
- array ( 'name ' => 'Jane Doe ' )
199
- ) );
196
+ User::insert ([
197
+ [ 'name ' => 'John Doe ' ] ,
198
+ [ 'name ' => 'Jane Doe ' ]
199
+ ] );
200
200
201
201
$ user = User::first ();
202
202
$ this ->assertInstanceOf ('Jenssegers\Mongodb\Model ' , $ user );
@@ -224,7 +224,7 @@ public function testFindOrfail()
224
224
225
225
public function testCreate ()
226
226
{
227
- $ user = User::create (array ( 'name ' => 'Jane Poe ' ) );
227
+ $ user = User::create ([ 'name ' => 'Jane Poe ' ] );
228
228
229
229
$ this ->assertInstanceOf ('Jenssegers\Mongodb\Model ' , $ user );
230
230
$ this ->assertEquals (true , $ user ->exists );
@@ -266,8 +266,8 @@ public function testTouch()
266
266
267
267
public function testSoftDelete ()
268
268
{
269
- Soft::create (array ( 'name ' => 'John Doe ' ) );
270
- Soft::create (array ( 'name ' => 'Jane Doe ' ) );
269
+ Soft::create ([ 'name ' => 'John Doe ' ] );
270
+ Soft::create ([ 'name ' => 'Jane Doe ' ] );
271
271
272
272
$ this ->assertEquals (2 , Soft::count ());
273
273
@@ -317,31 +317,31 @@ public function testPrimaryKey()
317
317
318
318
public function testScope ()
319
319
{
320
- Item::insert (array (
321
- array ( 'name ' => 'knife ' , 'type ' => 'sharp ' ) ,
322
- array ( 'name ' => 'spoon ' , 'type ' => 'round ' )
323
- ) );
320
+ Item::insert ([
321
+ [ 'name ' => 'knife ' , 'type ' => 'sharp ' ] ,
322
+ [ 'name ' => 'spoon ' , 'type ' => 'round ' ]
323
+ ] );
324
324
325
325
$ sharp = Item::sharp ()->get ();
326
326
$ this ->assertEquals (1 , $ sharp ->count ());
327
327
}
328
328
329
329
public function testToArray ()
330
330
{
331
- $ item = Item::create (array ( 'name ' => 'fork ' , 'type ' => 'sharp ' ) );
331
+ $ item = Item::create ([ 'name ' => 'fork ' , 'type ' => 'sharp ' ] );
332
332
333
333
$ array = $ item ->toArray ();
334
334
$ keys = array_keys ($ array ); sort ($ keys );
335
- $ this ->assertEquals (array ( '_id ' , 'created_at ' , 'name ' , 'type ' , 'updated_at ' ) , $ keys );
335
+ $ this ->assertEquals ([ '_id ' , 'created_at ' , 'name ' , 'type ' , 'updated_at ' ] , $ keys );
336
336
$ this ->assertTrue (is_string ($ array ['created_at ' ]));
337
337
$ this ->assertTrue (is_string ($ array ['updated_at ' ]));
338
338
$ this ->assertTrue (is_string ($ array ['_id ' ]));
339
339
}
340
340
341
341
public function testUnset ()
342
342
{
343
- $ user1 = User::create (array ( 'name ' => 'John Doe ' , 'note1 ' => 'ABC ' , 'note2 ' => 'DEF ' ) );
344
- $ user2 = User::create (array ( 'name ' => 'Jane Doe ' , 'note1 ' => 'ABC ' , 'note2 ' => 'DEF ' ) );
343
+ $ user1 = User::create ([ 'name ' => 'John Doe ' , 'note1 ' => 'ABC ' , 'note2 ' => 'DEF ' ] );
344
+ $ user2 = User::create ([ 'name ' => 'Jane Doe ' , 'note1 ' => 'ABC ' , 'note2 ' => 'DEF ' ] );
345
345
346
346
$ user1 ->unset ('note1 ' );
347
347
@@ -359,7 +359,7 @@ public function testUnset()
359
359
$ this ->assertTrue (isset ($ user2 ->note1 ));
360
360
$ this ->assertTrue (isset ($ user2 ->note2 ));
361
361
362
- $ user2 ->unset (array ( 'note1 ' , 'note2 ' ) );
362
+ $ user2 ->unset ([ 'note1 ' , 'note2 ' ] );
363
363
364
364
$ this ->assertFalse (isset ($ user2 ->note1 ));
365
365
$ this ->assertFalse (isset ($ user2 ->note2 ));
@@ -368,7 +368,7 @@ public function testUnset()
368
368
public function testDates ()
369
369
{
370
370
$ birthday = new DateTime ('1980/1/1 ' );
371
- $ user = User::create (array ( 'name ' => 'John Doe ' , 'birthday ' => $ birthday) );
371
+ $ user = User::create ([ 'name ' => 'John Doe ' , 'birthday ' => $ birthday] );
372
372
$ this ->assertInstanceOf ('Carbon\Carbon ' , $ user ->birthday );
373
373
374
374
$ check = User::find ($ user ->_id );
@@ -384,20 +384,20 @@ public function testDates()
384
384
$ this ->assertEquals ((string ) $ user ->created_at , $ json ['created_at ' ]);
385
385
386
386
// test default date format for json output
387
- $ item = Item::create (array ( 'name ' => 'sword ' ) );
387
+ $ item = Item::create ([ 'name ' => 'sword ' ] );
388
388
$ json = $ item ->toArray ();
389
389
$ this ->assertEquals ($ item ->created_at ->format ('Y-m-d H:i:s ' ), $ json ['created_at ' ]);
390
390
391
- $ user = User::create (array ( 'name ' => 'Jane Doe ' , 'birthday ' => time ()) );
391
+ $ user = User::create ([ 'name ' => 'Jane Doe ' , 'birthday ' => time ()] );
392
392
$ this ->assertInstanceOf ('Carbon\Carbon ' , $ user ->birthday );
393
393
394
- $ user = User::create (array ( 'name ' => 'Jane Doe ' , 'birthday ' => 'Monday 8th of August 2005 03:12:46 PM ' ) );
394
+ $ user = User::create ([ 'name ' => 'Jane Doe ' , 'birthday ' => 'Monday 8th of August 2005 03:12:46 PM ' ] );
395
395
$ this ->assertInstanceOf ('Carbon\Carbon ' , $ user ->birthday );
396
396
397
- $ user = User::create (array ( 'name ' => 'Jane Doe ' , 'birthday ' => '2005-08-08 ' ) );
397
+ $ user = User::create ([ 'name ' => 'Jane Doe ' , 'birthday ' => '2005-08-08 ' ] );
398
398
$ this ->assertInstanceOf ('Carbon\Carbon ' , $ user ->birthday );
399
399
400
- $ user = User::create (array ( 'name ' => 'Jane Doe ' , 'entry ' => array ( 'date ' => '2005-08-08 ' )) );
400
+ $ user = User::create ([ 'name ' => 'Jane Doe ' , 'entry ' => [ 'date ' => '2005-08-08 ' ]] );
401
401
$ this ->assertInstanceOf ('Carbon\Carbon ' , $ user ->getAttribute ('entry.date ' ));
402
402
403
403
$ user ->setAttribute ('entry.date ' , new DateTime );
@@ -406,55 +406,55 @@ public function testDates()
406
406
407
407
public function testIdAttribute ()
408
408
{
409
- $ user = User::create (array ( 'name ' => 'John Doe ' ) );
409
+ $ user = User::create ([ 'name ' => 'John Doe ' ] );
410
410
$ this ->assertEquals ($ user ->id , $ user ->_id );
411
411
412
- $ user = User::create (array ( 'id ' => 'custom_id ' , 'name ' => 'John Doe ' ) );
412
+ $ user = User::create ([ 'id ' => 'custom_id ' , 'name ' => 'John Doe ' ] );
413
413
$ this ->assertNotEquals ($ user ->id , $ user ->_id );
414
414
}
415
415
416
416
public function testPushPull ()
417
417
{
418
- $ user = User::create (array ( 'name ' => 'John Doe ' ) );
418
+ $ user = User::create ([ 'name ' => 'John Doe ' ] );
419
419
420
420
$ user ->push ('tags ' , 'tag1 ' );
421
- $ user ->push ('tags ' , array ( 'tag1 ' , 'tag2 ' ) );
421
+ $ user ->push ('tags ' , [ 'tag1 ' , 'tag2 ' ] );
422
422
$ user ->push ('tags ' , 'tag2 ' , true );
423
423
424
- $ this ->assertEquals (array ( 'tag1 ' , 'tag1 ' , 'tag2 ' ) , $ user ->tags );
424
+ $ this ->assertEquals ([ 'tag1 ' , 'tag1 ' , 'tag2 ' ] , $ user ->tags );
425
425
$ user = User::where ('_id ' , $ user ->_id )->first ();
426
- $ this ->assertEquals (array ( 'tag1 ' , 'tag1 ' , 'tag2 ' ) , $ user ->tags );
426
+ $ this ->assertEquals ([ 'tag1 ' , 'tag1 ' , 'tag2 ' ] , $ user ->tags );
427
427
428
428
$ user ->pull ('tags ' , 'tag1 ' );
429
429
430
- $ this ->assertEquals (array ( 'tag2 ' ) , $ user ->tags );
430
+ $ this ->assertEquals ([ 'tag2 ' ] , $ user ->tags );
431
431
$ user = User::where ('_id ' , $ user ->_id )->first ();
432
- $ this ->assertEquals (array ( 'tag2 ' ) , $ user ->tags );
432
+ $ this ->assertEquals ([ 'tag2 ' ] , $ user ->tags );
433
433
434
434
$ user ->push ('tags ' , 'tag3 ' );
435
- $ user ->pull ('tags ' , array ( 'tag2 ' , 'tag3 ' ) );
435
+ $ user ->pull ('tags ' , [ 'tag2 ' , 'tag3 ' ] );
436
436
437
- $ this ->assertEquals (array () , $ user ->tags );
437
+ $ this ->assertEquals ([] , $ user ->tags );
438
438
$ user = User::where ('_id ' , $ user ->_id )->first ();
439
- $ this ->assertEquals (array () , $ user ->tags );
439
+ $ this ->assertEquals ([] , $ user ->tags );
440
440
}
441
441
442
442
public function testRaw ()
443
443
{
444
- User::create (array ( 'name ' => 'John Doe ' , 'age ' => 35 ) );
445
- User::create (array ( 'name ' => 'Jane Doe ' , 'age ' => 35 ) );
446
- User::create (array ( 'name ' => 'Harry Hoe ' , 'age ' => 15 ) );
444
+ User::create ([ 'name ' => 'John Doe ' , 'age ' => 35 ] );
445
+ User::create ([ 'name ' => 'Jane Doe ' , 'age ' => 35 ] );
446
+ User::create ([ 'name ' => 'Harry Hoe ' , 'age ' => 15 ] );
447
447
448
448
$ users = User::raw (function ($ collection )
449
449
{
450
- return $ collection ->find (array ( 'age ' => 35 ) );
450
+ return $ collection ->find ([ 'age ' => 35 ] );
451
451
});
452
452
$ this ->assertInstanceOf ('Illuminate\Database\Eloquent\Collection ' , $ users );
453
453
$ this ->assertInstanceOf ('Jenssegers\Mongodb\Model ' , $ users [0 ]);
454
454
455
455
$ user = User::raw (function ($ collection )
456
456
{
457
- return $ collection ->findOne (array ( 'age ' => 35 ) );
457
+ return $ collection ->findOne ([ 'age ' => 35 ] );
458
458
});
459
459
$ this ->assertInstanceOf ('Jenssegers\Mongodb\Model ' , $ user );
460
460
@@ -466,20 +466,20 @@ public function testRaw()
466
466
467
467
$ result = User::raw (function ($ collection )
468
468
{
469
- return $ collection ->insert (array ( 'name ' => 'Yvonne Yoe ' , 'age ' => 35 ) );
469
+ return $ collection ->insert ([ 'name ' => 'Yvonne Yoe ' , 'age ' => 35 ] );
470
470
});
471
471
$ this ->assertTrue (is_array ($ result ));
472
472
}
473
473
474
474
public function testDotNotation ()
475
475
{
476
- $ user = User::create (array (
476
+ $ user = User::create ([
477
477
'name ' => 'John Doe ' ,
478
478
'address ' => [
479
479
'city ' => 'Paris ' ,
480
480
'country ' => 'France ' ,
481
481
]
482
- ) );
482
+ ] );
483
483
484
484
$ this ->assertEquals ('Paris ' , $ user ->getAttribute ('address.city ' ));
485
485
$ this ->assertEquals ('Paris ' , $ user ['address.city ' ]);
0 commit comments