Skip to content

Commit 593b4a5

Browse files
committed
Use short array notations in tests
1 parent 9603949 commit 593b4a5

15 files changed

+515
-515
lines changed

tests/AuthTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ public function tearDown()
1212

1313
public function testAuthAttempt()
1414
{
15-
$user = User::create(array(
15+
$user = User::create([
1616
'name' => 'John Doe',
1717
'email' => '[email protected]',
1818
'password' => Hash::make('foobar')
19-
));
19+
]);
2020

21-
$this->assertTrue(Auth::attempt(array('email' => '[email protected]', 'password' => 'foobar'), true));
21+
$this->assertTrue(Auth::attempt(['email' => '[email protected]', 'password' => 'foobar'], true));
2222
$this->assertTrue(Auth::check());
2323
}
2424

@@ -30,27 +30,27 @@ public function testRemind()
3030

3131
$broker = new PasswordBroker($tokens, $users, $mailer, '');
3232

33-
$user = User::create(array(
33+
$user = User::create([
3434
'name' => 'John Doe',
3535
'email' => '[email protected]',
3636
'password' => Hash::make('foobar')
37-
));
37+
]);
3838

3939
$mailer->shouldReceive('send')->once();
40-
$broker->sendResetLink(array('email' => '[email protected]'));
40+
$broker->sendResetLink(['email' => '[email protected]']);
4141

4242
$this->assertEquals(1, DB::collection('password_resets')->count());
4343
$reminder = DB::collection('password_resets')->first();
4444
$this->assertEquals('[email protected]', $reminder['email']);
4545
$this->assertNotNull($reminder['token']);
4646
$this->assertInstanceOf('MongoDate', $reminder['created_at']);
4747

48-
$credentials = array(
48+
$credentials = [
4949
'email' => '[email protected]',
5050
'password' => 'foobar',
5151
'password_confirmation' => 'foobar',
5252
'token' => $reminder['token']
53-
);
53+
];
5454

5555
$response = $broker->reset($credentials, function($user, $password)
5656
{

tests/ConnectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ public function testQueryLog()
7171
DB::collection('items')->get();
7272
$this->assertEquals(1, count(DB::getQueryLog()));
7373

74-
DB::collection('items')->insert(array('name' => 'test'));
74+
DB::collection('items')->insert(['name' => 'test']);
7575
$this->assertEquals(2, count(DB::getQueryLog()));
7676

7777
DB::collection('items')->count();
7878
$this->assertEquals(3, count(DB::getQueryLog()));
7979

80-
DB::collection('items')->where('name', 'test')->update(array('name' => 'test'));
80+
DB::collection('items')->where('name', 'test')->update(['name' => 'test']);
8181
$this->assertEquals(4, count(DB::getQueryLog()));
8282

8383
DB::collection('items')->where('name', 'test')->delete();

tests/EmbeddedRelationsTest.php

Lines changed: 139 additions & 139 deletions
Large diffs are not rendered by default.

tests/ModelTest.php

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testUpdate()
6969
$this->assertEquals('John Doe', $check->name);
7070
$this->assertEquals(36, $check->age);
7171

72-
$user->update(array('age' => 20));
72+
$user->update(['age' => 20]);
7373

7474
$raw = $user->getAttributes();
7575
$this->assertInstanceOf('MongoId', $raw['_id']);
@@ -180,10 +180,10 @@ public function testFind()
180180

181181
public function testGet()
182182
{
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+
]);
187187

188188
$users = User::get();
189189
$this->assertEquals(2, count($users));
@@ -193,10 +193,10 @@ public function testGet()
193193

194194
public function testFirst()
195195
{
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+
]);
200200

201201
$user = User::first();
202202
$this->assertInstanceOf('Jenssegers\Mongodb\Model', $user);
@@ -224,7 +224,7 @@ public function testFindOrfail()
224224

225225
public function testCreate()
226226
{
227-
$user = User::create(array('name' => 'Jane Poe'));
227+
$user = User::create(['name' => 'Jane Poe']);
228228

229229
$this->assertInstanceOf('Jenssegers\Mongodb\Model', $user);
230230
$this->assertEquals(true, $user->exists);
@@ -266,8 +266,8 @@ public function testTouch()
266266

267267
public function testSoftDelete()
268268
{
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']);
271271

272272
$this->assertEquals(2, Soft::count());
273273

@@ -317,31 +317,31 @@ public function testPrimaryKey()
317317

318318
public function testScope()
319319
{
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+
]);
324324

325325
$sharp = Item::sharp()->get();
326326
$this->assertEquals(1, $sharp->count());
327327
}
328328

329329
public function testToArray()
330330
{
331-
$item = Item::create(array('name' => 'fork', 'type' => 'sharp'));
331+
$item = Item::create(['name' => 'fork', 'type' => 'sharp']);
332332

333333
$array = $item->toArray();
334334
$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);
336336
$this->assertTrue(is_string($array['created_at']));
337337
$this->assertTrue(is_string($array['updated_at']));
338338
$this->assertTrue(is_string($array['_id']));
339339
}
340340

341341
public function testUnset()
342342
{
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']);
345345

346346
$user1->unset('note1');
347347

@@ -359,7 +359,7 @@ public function testUnset()
359359
$this->assertTrue(isset($user2->note1));
360360
$this->assertTrue(isset($user2->note2));
361361

362-
$user2->unset(array('note1', 'note2'));
362+
$user2->unset(['note1', 'note2']);
363363

364364
$this->assertFalse(isset($user2->note1));
365365
$this->assertFalse(isset($user2->note2));
@@ -368,7 +368,7 @@ public function testUnset()
368368
public function testDates()
369369
{
370370
$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]);
372372
$this->assertInstanceOf('Carbon\Carbon', $user->birthday);
373373

374374
$check = User::find($user->_id);
@@ -384,20 +384,20 @@ public function testDates()
384384
$this->assertEquals((string) $user->created_at, $json['created_at']);
385385

386386
// test default date format for json output
387-
$item = Item::create(array('name' => 'sword'));
387+
$item = Item::create(['name' => 'sword']);
388388
$json = $item->toArray();
389389
$this->assertEquals($item->created_at->format('Y-m-d H:i:s'), $json['created_at']);
390390

391-
$user = User::create(array('name' => 'Jane Doe', 'birthday' => time()));
391+
$user = User::create(['name' => 'Jane Doe', 'birthday' => time()]);
392392
$this->assertInstanceOf('Carbon\Carbon', $user->birthday);
393393

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']);
395395
$this->assertInstanceOf('Carbon\Carbon', $user->birthday);
396396

397-
$user = User::create(array('name' => 'Jane Doe', 'birthday' => '2005-08-08'));
397+
$user = User::create(['name' => 'Jane Doe', 'birthday' => '2005-08-08']);
398398
$this->assertInstanceOf('Carbon\Carbon', $user->birthday);
399399

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']]);
401401
$this->assertInstanceOf('Carbon\Carbon', $user->getAttribute('entry.date'));
402402

403403
$user->setAttribute('entry.date', new DateTime);
@@ -406,55 +406,55 @@ public function testDates()
406406

407407
public function testIdAttribute()
408408
{
409-
$user = User::create(array('name' => 'John Doe'));
409+
$user = User::create(['name' => 'John Doe']);
410410
$this->assertEquals($user->id, $user->_id);
411411

412-
$user = User::create(array('id' => 'custom_id', 'name' => 'John Doe'));
412+
$user = User::create(['id' => 'custom_id', 'name' => 'John Doe']);
413413
$this->assertNotEquals($user->id, $user->_id);
414414
}
415415

416416
public function testPushPull()
417417
{
418-
$user = User::create(array('name' => 'John Doe'));
418+
$user = User::create(['name' => 'John Doe']);
419419

420420
$user->push('tags', 'tag1');
421-
$user->push('tags', array('tag1', 'tag2'));
421+
$user->push('tags', ['tag1', 'tag2']);
422422
$user->push('tags', 'tag2', true);
423423

424-
$this->assertEquals(array('tag1', 'tag1', 'tag2'), $user->tags);
424+
$this->assertEquals(['tag1', 'tag1', 'tag2'], $user->tags);
425425
$user = User::where('_id', $user->_id)->first();
426-
$this->assertEquals(array('tag1', 'tag1', 'tag2'), $user->tags);
426+
$this->assertEquals(['tag1', 'tag1', 'tag2'], $user->tags);
427427

428428
$user->pull('tags', 'tag1');
429429

430-
$this->assertEquals(array('tag2'), $user->tags);
430+
$this->assertEquals(['tag2'], $user->tags);
431431
$user = User::where('_id', $user->_id)->first();
432-
$this->assertEquals(array('tag2'), $user->tags);
432+
$this->assertEquals(['tag2'], $user->tags);
433433

434434
$user->push('tags', 'tag3');
435-
$user->pull('tags', array('tag2', 'tag3'));
435+
$user->pull('tags', ['tag2', 'tag3']);
436436

437-
$this->assertEquals(array(), $user->tags);
437+
$this->assertEquals([], $user->tags);
438438
$user = User::where('_id', $user->_id)->first();
439-
$this->assertEquals(array(), $user->tags);
439+
$this->assertEquals([], $user->tags);
440440
}
441441

442442
public function testRaw()
443443
{
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]);
447447

448448
$users = User::raw(function($collection)
449449
{
450-
return $collection->find(array('age' => 35));
450+
return $collection->find(['age' => 35]);
451451
});
452452
$this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $users);
453453
$this->assertInstanceOf('Jenssegers\Mongodb\Model', $users[0]);
454454

455455
$user = User::raw(function($collection)
456456
{
457-
return $collection->findOne(array('age' => 35));
457+
return $collection->findOne(['age' => 35]);
458458
});
459459
$this->assertInstanceOf('Jenssegers\Mongodb\Model', $user);
460460

@@ -466,20 +466,20 @@ public function testRaw()
466466

467467
$result = User::raw(function($collection)
468468
{
469-
return $collection->insert(array('name' => 'Yvonne Yoe', 'age' => 35));
469+
return $collection->insert(['name' => 'Yvonne Yoe', 'age' => 35]);
470470
});
471471
$this->assertTrue(is_array($result));
472472
}
473473

474474
public function testDotNotation()
475475
{
476-
$user = User::create(array(
476+
$user = User::create([
477477
'name' => 'John Doe',
478478
'address' => [
479479
'city' => 'Paris',
480480
'country' => 'France',
481481
]
482-
));
482+
]);
483483

484484
$this->assertEquals('Paris', $user->getAttribute('address.city'));
485485
$this->assertEquals('Paris', $user['address.city']);

tests/MysqlRelationsTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testMysqlRelations()
3030
$this->assertTrue(is_int($user->id));
3131

3232
// SQL has many
33-
$book = new Book(array('title' => 'Game of Thrones'));
33+
$book = new Book(['title' => 'Game of Thrones']);
3434
$user->books()->save($book);
3535
$user = MysqlUser::find($user->id); // refetch
3636
$this->assertEquals(1, count($user->books));
@@ -40,7 +40,7 @@ public function testMysqlRelations()
4040
$this->assertEquals('John Doe', $book->mysqlAuthor->name);
4141

4242
// SQL has one
43-
$role = new Role(array('type' => 'admin'));
43+
$role = new Role(['type' => 'admin']);
4444
$user->role()->save($role);
4545
$user = MysqlUser::find($user->id); // refetch
4646
$this->assertEquals('admin', $user->role->type);
@@ -55,7 +55,7 @@ public function testMysqlRelations()
5555
$user->save();
5656

5757
// MongoDB has many
58-
$book = new MysqlBook(array('title' => 'Game of Thrones'));
58+
$book = new MysqlBook(['title' => 'Game of Thrones']);
5959
$user->mysqlBooks()->save($book);
6060
$user = User::find($user->_id); // refetch
6161
$this->assertEquals(1, count($user->mysqlBooks));
@@ -65,7 +65,7 @@ public function testMysqlRelations()
6565
$this->assertEquals('John Doe', $book->author->name);
6666

6767
// MongoDB has one
68-
$role = new MysqlRole(array('type' => 'admin'));
68+
$role = new MysqlRole(['type' => 'admin']);
6969
$user->mysqlRole()->save($role);
7070
$user = User::find($user->_id); // refetch
7171
$this->assertEquals('admin', $user->mysqlRole->type);

0 commit comments

Comments
 (0)