Commit 593b4a52 authored by Jens Segers's avatar Jens Segers

Use short array notations in tests

parent 96039491
...@@ -12,13 +12,13 @@ class AuthTest extends TestCase { ...@@ -12,13 +12,13 @@ class AuthTest extends TestCase {
public function testAuthAttempt() public function testAuthAttempt()
{ {
$user = User::create(array( $user = User::create([
'name' => 'John Doe', 'name' => 'John Doe',
'email' => 'john@doe.com', 'email' => 'john@doe.com',
'password' => Hash::make('foobar') 'password' => Hash::make('foobar')
)); ]);
$this->assertTrue(Auth::attempt(array('email' => 'john@doe.com', 'password' => 'foobar'), true)); $this->assertTrue(Auth::attempt(['email' => 'john@doe.com', 'password' => 'foobar'], true));
$this->assertTrue(Auth::check()); $this->assertTrue(Auth::check());
} }
...@@ -30,14 +30,14 @@ class AuthTest extends TestCase { ...@@ -30,14 +30,14 @@ class AuthTest extends TestCase {
$broker = new PasswordBroker($tokens, $users, $mailer, ''); $broker = new PasswordBroker($tokens, $users, $mailer, '');
$user = User::create(array( $user = User::create([
'name' => 'John Doe', 'name' => 'John Doe',
'email' => 'john@doe.com', 'email' => 'john@doe.com',
'password' => Hash::make('foobar') 'password' => Hash::make('foobar')
)); ]);
$mailer->shouldReceive('send')->once(); $mailer->shouldReceive('send')->once();
$broker->sendResetLink(array('email' => 'john@doe.com')); $broker->sendResetLink(['email' => 'john@doe.com']);
$this->assertEquals(1, DB::collection('password_resets')->count()); $this->assertEquals(1, DB::collection('password_resets')->count());
$reminder = DB::collection('password_resets')->first(); $reminder = DB::collection('password_resets')->first();
...@@ -45,12 +45,12 @@ class AuthTest extends TestCase { ...@@ -45,12 +45,12 @@ class AuthTest extends TestCase {
$this->assertNotNull($reminder['token']); $this->assertNotNull($reminder['token']);
$this->assertInstanceOf('MongoDate', $reminder['created_at']); $this->assertInstanceOf('MongoDate', $reminder['created_at']);
$credentials = array( $credentials = [
'email' => 'john@doe.com', 'email' => 'john@doe.com',
'password' => 'foobar', 'password' => 'foobar',
'password_confirmation' => 'foobar', 'password_confirmation' => 'foobar',
'token' => $reminder['token'] 'token' => $reminder['token']
); ];
$response = $broker->reset($credentials, function($user, $password) $response = $broker->reset($credentials, function($user, $password)
{ {
......
...@@ -71,13 +71,13 @@ class ConnectionTest extends TestCase { ...@@ -71,13 +71,13 @@ class ConnectionTest extends TestCase {
DB::collection('items')->get(); DB::collection('items')->get();
$this->assertEquals(1, count(DB::getQueryLog())); $this->assertEquals(1, count(DB::getQueryLog()));
DB::collection('items')->insert(array('name' => 'test')); DB::collection('items')->insert(['name' => 'test']);
$this->assertEquals(2, count(DB::getQueryLog())); $this->assertEquals(2, count(DB::getQueryLog()));
DB::collection('items')->count(); DB::collection('items')->count();
$this->assertEquals(3, count(DB::getQueryLog())); $this->assertEquals(3, count(DB::getQueryLog()));
DB::collection('items')->where('name', 'test')->update(array('name' => 'test')); DB::collection('items')->where('name', 'test')->update(['name' => 'test']);
$this->assertEquals(4, count(DB::getQueryLog())); $this->assertEquals(4, count(DB::getQueryLog()));
DB::collection('items')->where('name', 'test')->delete(); DB::collection('items')->where('name', 'test')->delete();
......
This diff is collapsed.
...@@ -69,7 +69,7 @@ class ModelTest extends TestCase { ...@@ -69,7 +69,7 @@ class ModelTest extends TestCase {
$this->assertEquals('John Doe', $check->name); $this->assertEquals('John Doe', $check->name);
$this->assertEquals(36, $check->age); $this->assertEquals(36, $check->age);
$user->update(array('age' => 20)); $user->update(['age' => 20]);
$raw = $user->getAttributes(); $raw = $user->getAttributes();
$this->assertInstanceOf('MongoId', $raw['_id']); $this->assertInstanceOf('MongoId', $raw['_id']);
...@@ -180,10 +180,10 @@ class ModelTest extends TestCase { ...@@ -180,10 +180,10 @@ class ModelTest extends TestCase {
public function testGet() public function testGet()
{ {
User::insert(array( User::insert([
array('name' => 'John Doe'), ['name' => 'John Doe'],
array('name' => 'Jane Doe') ['name' => 'Jane Doe']
)); ]);
$users = User::get(); $users = User::get();
$this->assertEquals(2, count($users)); $this->assertEquals(2, count($users));
...@@ -193,10 +193,10 @@ class ModelTest extends TestCase { ...@@ -193,10 +193,10 @@ class ModelTest extends TestCase {
public function testFirst() public function testFirst()
{ {
User::insert(array( User::insert([
array('name' => 'John Doe'), ['name' => 'John Doe'],
array('name' => 'Jane Doe') ['name' => 'Jane Doe']
)); ]);
$user = User::first(); $user = User::first();
$this->assertInstanceOf('Jenssegers\Mongodb\Model', $user); $this->assertInstanceOf('Jenssegers\Mongodb\Model', $user);
...@@ -224,7 +224,7 @@ class ModelTest extends TestCase { ...@@ -224,7 +224,7 @@ class ModelTest extends TestCase {
public function testCreate() public function testCreate()
{ {
$user = User::create(array('name' => 'Jane Poe')); $user = User::create(['name' => 'Jane Poe']);
$this->assertInstanceOf('Jenssegers\Mongodb\Model', $user); $this->assertInstanceOf('Jenssegers\Mongodb\Model', $user);
$this->assertEquals(true, $user->exists); $this->assertEquals(true, $user->exists);
...@@ -266,8 +266,8 @@ class ModelTest extends TestCase { ...@@ -266,8 +266,8 @@ class ModelTest extends TestCase {
public function testSoftDelete() public function testSoftDelete()
{ {
Soft::create(array('name' => 'John Doe')); Soft::create(['name' => 'John Doe']);
Soft::create(array('name' => 'Jane Doe')); Soft::create(['name' => 'Jane Doe']);
$this->assertEquals(2, Soft::count()); $this->assertEquals(2, Soft::count());
...@@ -317,10 +317,10 @@ class ModelTest extends TestCase { ...@@ -317,10 +317,10 @@ class ModelTest extends TestCase {
public function testScope() public function testScope()
{ {
Item::insert(array( Item::insert([
array('name' => 'knife', 'type' => 'sharp'), ['name' => 'knife', 'type' => 'sharp'],
array('name' => 'spoon', 'type' => 'round') ['name' => 'spoon', 'type' => 'round']
)); ]);
$sharp = Item::sharp()->get(); $sharp = Item::sharp()->get();
$this->assertEquals(1, $sharp->count()); $this->assertEquals(1, $sharp->count());
...@@ -328,11 +328,11 @@ class ModelTest extends TestCase { ...@@ -328,11 +328,11 @@ class ModelTest extends TestCase {
public function testToArray() public function testToArray()
{ {
$item = Item::create(array('name' => 'fork', 'type' => 'sharp')); $item = Item::create(['name' => 'fork', 'type' => 'sharp']);
$array = $item->toArray(); $array = $item->toArray();
$keys = array_keys($array); sort($keys); $keys = array_keys($array); sort($keys);
$this->assertEquals(array('_id', 'created_at', 'name', 'type', 'updated_at'), $keys); $this->assertEquals(['_id', 'created_at', 'name', 'type', 'updated_at'], $keys);
$this->assertTrue(is_string($array['created_at'])); $this->assertTrue(is_string($array['created_at']));
$this->assertTrue(is_string($array['updated_at'])); $this->assertTrue(is_string($array['updated_at']));
$this->assertTrue(is_string($array['_id'])); $this->assertTrue(is_string($array['_id']));
...@@ -340,8 +340,8 @@ class ModelTest extends TestCase { ...@@ -340,8 +340,8 @@ class ModelTest extends TestCase {
public function testUnset() public function testUnset()
{ {
$user1 = User::create(array('name' => 'John Doe', 'note1' => 'ABC', 'note2' => 'DEF')); $user1 = User::create(['name' => 'John Doe', 'note1' => 'ABC', 'note2' => 'DEF']);
$user2 = User::create(array('name' => 'Jane Doe', 'note1' => 'ABC', 'note2' => 'DEF')); $user2 = User::create(['name' => 'Jane Doe', 'note1' => 'ABC', 'note2' => 'DEF']);
$user1->unset('note1'); $user1->unset('note1');
...@@ -359,7 +359,7 @@ class ModelTest extends TestCase { ...@@ -359,7 +359,7 @@ class ModelTest extends TestCase {
$this->assertTrue(isset($user2->note1)); $this->assertTrue(isset($user2->note1));
$this->assertTrue(isset($user2->note2)); $this->assertTrue(isset($user2->note2));
$user2->unset(array('note1', 'note2')); $user2->unset(['note1', 'note2']);
$this->assertFalse(isset($user2->note1)); $this->assertFalse(isset($user2->note1));
$this->assertFalse(isset($user2->note2)); $this->assertFalse(isset($user2->note2));
...@@ -368,7 +368,7 @@ class ModelTest extends TestCase { ...@@ -368,7 +368,7 @@ class ModelTest extends TestCase {
public function testDates() public function testDates()
{ {
$birthday = new DateTime('1980/1/1'); $birthday = new DateTime('1980/1/1');
$user = User::create(array('name' => 'John Doe', 'birthday' => $birthday)); $user = User::create(['name' => 'John Doe', 'birthday' => $birthday]);
$this->assertInstanceOf('Carbon\Carbon', $user->birthday); $this->assertInstanceOf('Carbon\Carbon', $user->birthday);
$check = User::find($user->_id); $check = User::find($user->_id);
...@@ -384,20 +384,20 @@ class ModelTest extends TestCase { ...@@ -384,20 +384,20 @@ class ModelTest extends TestCase {
$this->assertEquals((string) $user->created_at, $json['created_at']); $this->assertEquals((string) $user->created_at, $json['created_at']);
// test default date format for json output // test default date format for json output
$item = Item::create(array('name' => 'sword')); $item = Item::create(['name' => 'sword']);
$json = $item->toArray(); $json = $item->toArray();
$this->assertEquals($item->created_at->format('Y-m-d H:i:s'), $json['created_at']); $this->assertEquals($item->created_at->format('Y-m-d H:i:s'), $json['created_at']);
$user = User::create(array('name' => 'Jane Doe', 'birthday' => time())); $user = User::create(['name' => 'Jane Doe', 'birthday' => time()]);
$this->assertInstanceOf('Carbon\Carbon', $user->birthday); $this->assertInstanceOf('Carbon\Carbon', $user->birthday);
$user = User::create(array('name' => 'Jane Doe', 'birthday' => 'Monday 8th of August 2005 03:12:46 PM')); $user = User::create(['name' => 'Jane Doe', 'birthday' => 'Monday 8th of August 2005 03:12:46 PM']);
$this->assertInstanceOf('Carbon\Carbon', $user->birthday); $this->assertInstanceOf('Carbon\Carbon', $user->birthday);
$user = User::create(array('name' => 'Jane Doe', 'birthday' => '2005-08-08')); $user = User::create(['name' => 'Jane Doe', 'birthday' => '2005-08-08']);
$this->assertInstanceOf('Carbon\Carbon', $user->birthday); $this->assertInstanceOf('Carbon\Carbon', $user->birthday);
$user = User::create(array('name' => 'Jane Doe', 'entry' => array('date' => '2005-08-08'))); $user = User::create(['name' => 'Jane Doe', 'entry' => ['date' => '2005-08-08']]);
$this->assertInstanceOf('Carbon\Carbon', $user->getAttribute('entry.date')); $this->assertInstanceOf('Carbon\Carbon', $user->getAttribute('entry.date'));
$user->setAttribute('entry.date', new DateTime); $user->setAttribute('entry.date', new DateTime);
...@@ -406,55 +406,55 @@ class ModelTest extends TestCase { ...@@ -406,55 +406,55 @@ class ModelTest extends TestCase {
public function testIdAttribute() public function testIdAttribute()
{ {
$user = User::create(array('name' => 'John Doe')); $user = User::create(['name' => 'John Doe']);
$this->assertEquals($user->id, $user->_id); $this->assertEquals($user->id, $user->_id);
$user = User::create(array('id' => 'custom_id', 'name' => 'John Doe')); $user = User::create(['id' => 'custom_id', 'name' => 'John Doe']);
$this->assertNotEquals($user->id, $user->_id); $this->assertNotEquals($user->id, $user->_id);
} }
public function testPushPull() public function testPushPull()
{ {
$user = User::create(array('name' => 'John Doe')); $user = User::create(['name' => 'John Doe']);
$user->push('tags', 'tag1'); $user->push('tags', 'tag1');
$user->push('tags', array('tag1', 'tag2')); $user->push('tags', ['tag1', 'tag2']);
$user->push('tags', 'tag2', true); $user->push('tags', 'tag2', true);
$this->assertEquals(array('tag1', 'tag1', 'tag2'), $user->tags); $this->assertEquals(['tag1', 'tag1', 'tag2'], $user->tags);
$user = User::where('_id', $user->_id)->first(); $user = User::where('_id', $user->_id)->first();
$this->assertEquals(array('tag1', 'tag1', 'tag2'), $user->tags); $this->assertEquals(['tag1', 'tag1', 'tag2'], $user->tags);
$user->pull('tags', 'tag1'); $user->pull('tags', 'tag1');
$this->assertEquals(array('tag2'), $user->tags); $this->assertEquals(['tag2'], $user->tags);
$user = User::where('_id', $user->_id)->first(); $user = User::where('_id', $user->_id)->first();
$this->assertEquals(array('tag2'), $user->tags); $this->assertEquals(['tag2'], $user->tags);
$user->push('tags', 'tag3'); $user->push('tags', 'tag3');
$user->pull('tags', array('tag2', 'tag3')); $user->pull('tags', ['tag2', 'tag3']);
$this->assertEquals(array(), $user->tags); $this->assertEquals([], $user->tags);
$user = User::where('_id', $user->_id)->first(); $user = User::where('_id', $user->_id)->first();
$this->assertEquals(array(), $user->tags); $this->assertEquals([], $user->tags);
} }
public function testRaw() public function testRaw()
{ {
User::create(array('name' => 'John Doe', 'age' => 35)); User::create(['name' => 'John Doe', 'age' => 35]);
User::create(array('name' => 'Jane Doe', 'age' => 35)); User::create(['name' => 'Jane Doe', 'age' => 35]);
User::create(array('name' => 'Harry Hoe', 'age' => 15)); User::create(['name' => 'Harry Hoe', 'age' => 15]);
$users = User::raw(function($collection) $users = User::raw(function($collection)
{ {
return $collection->find(array('age' => 35)); return $collection->find(['age' => 35]);
}); });
$this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $users); $this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $users);
$this->assertInstanceOf('Jenssegers\Mongodb\Model', $users[0]); $this->assertInstanceOf('Jenssegers\Mongodb\Model', $users[0]);
$user = User::raw(function($collection) $user = User::raw(function($collection)
{ {
return $collection->findOne(array('age' => 35)); return $collection->findOne(['age' => 35]);
}); });
$this->assertInstanceOf('Jenssegers\Mongodb\Model', $user); $this->assertInstanceOf('Jenssegers\Mongodb\Model', $user);
...@@ -466,20 +466,20 @@ class ModelTest extends TestCase { ...@@ -466,20 +466,20 @@ class ModelTest extends TestCase {
$result = User::raw(function($collection) $result = User::raw(function($collection)
{ {
return $collection->insert(array('name' => 'Yvonne Yoe', 'age' => 35)); return $collection->insert(['name' => 'Yvonne Yoe', 'age' => 35]);
}); });
$this->assertTrue(is_array($result)); $this->assertTrue(is_array($result));
} }
public function testDotNotation() public function testDotNotation()
{ {
$user = User::create(array( $user = User::create([
'name' => 'John Doe', 'name' => 'John Doe',
'address' => [ 'address' => [
'city' => 'Paris', 'city' => 'Paris',
'country' => 'France', 'country' => 'France',
] ]
)); ]);
$this->assertEquals('Paris', $user->getAttribute('address.city')); $this->assertEquals('Paris', $user->getAttribute('address.city'));
$this->assertEquals('Paris', $user['address.city']); $this->assertEquals('Paris', $user['address.city']);
......
...@@ -30,7 +30,7 @@ class MysqlRelationsTest extends TestCase { ...@@ -30,7 +30,7 @@ class MysqlRelationsTest extends TestCase {
$this->assertTrue(is_int($user->id)); $this->assertTrue(is_int($user->id));
// SQL has many // SQL has many
$book = new Book(array('title' => 'Game of Thrones')); $book = new Book(['title' => 'Game of Thrones']);
$user->books()->save($book); $user->books()->save($book);
$user = MysqlUser::find($user->id); // refetch $user = MysqlUser::find($user->id); // refetch
$this->assertEquals(1, count($user->books)); $this->assertEquals(1, count($user->books));
...@@ -40,7 +40,7 @@ class MysqlRelationsTest extends TestCase { ...@@ -40,7 +40,7 @@ class MysqlRelationsTest extends TestCase {
$this->assertEquals('John Doe', $book->mysqlAuthor->name); $this->assertEquals('John Doe', $book->mysqlAuthor->name);
// SQL has one // SQL has one
$role = new Role(array('type' => 'admin')); $role = new Role(['type' => 'admin']);
$user->role()->save($role); $user->role()->save($role);
$user = MysqlUser::find($user->id); // refetch $user = MysqlUser::find($user->id); // refetch
$this->assertEquals('admin', $user->role->type); $this->assertEquals('admin', $user->role->type);
...@@ -55,7 +55,7 @@ class MysqlRelationsTest extends TestCase { ...@@ -55,7 +55,7 @@ class MysqlRelationsTest extends TestCase {
$user->save(); $user->save();
// MongoDB has many // MongoDB has many
$book = new MysqlBook(array('title' => 'Game of Thrones')); $book = new MysqlBook(['title' => 'Game of Thrones']);
$user->mysqlBooks()->save($book); $user->mysqlBooks()->save($book);
$user = User::find($user->_id); // refetch $user = User::find($user->_id); // refetch
$this->assertEquals(1, count($user->mysqlBooks)); $this->assertEquals(1, count($user->mysqlBooks));
...@@ -65,7 +65,7 @@ class MysqlRelationsTest extends TestCase { ...@@ -65,7 +65,7 @@ class MysqlRelationsTest extends TestCase {
$this->assertEquals('John Doe', $book->author->name); $this->assertEquals('John Doe', $book->author->name);
// MongoDB has one // MongoDB has one
$role = new MysqlRole(array('type' => 'admin')); $role = new MysqlRole(['type' => 'admin']);
$user->mysqlRole()->save($role); $user->mysqlRole()->save($role);
$user = User::find($user->_id); // refetch $user = User::find($user->_id); // refetch
$this->assertEquals('admin', $user->mysqlRole->type); $this->assertEquals('admin', $user->mysqlRole->type);
......
This diff is collapsed.
...@@ -7,15 +7,15 @@ class QueryTest extends TestCase { ...@@ -7,15 +7,15 @@ class QueryTest extends TestCase {
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
User::create(array('name' => 'John Doe', 'age' => 35, 'title' => 'admin')); User::create(['name' => 'John Doe', 'age' => 35, 'title' => 'admin']);
User::create(array('name' => 'Jane Doe', 'age' => 33, 'title' => 'admin')); User::create(['name' => 'Jane Doe', 'age' => 33, 'title' => 'admin']);
User::create(array('name' => 'Harry Hoe', 'age' => 13, 'title' => 'user')); User::create(['name' => 'Harry Hoe', 'age' => 13, 'title' => 'user']);
User::create(array('name' => 'Robert Roe', 'age' => 37, 'title' => 'user')); User::create(['name' => 'Robert Roe', 'age' => 37, 'title' => 'user']);
User::create(array('name' => 'Mark Moe', 'age' => 23, 'title' => 'user')); User::create(['name' => 'Mark Moe', 'age' => 23, 'title' => 'user']);
User::create(array('name' => 'Brett Boe', 'age' => 35, 'title' => 'user')); User::create(['name' => 'Brett Boe', 'age' => 35, 'title' => 'user']);
User::create(array('name' => 'Tommy Toe', 'age' => 33, 'title' => 'user')); User::create(['name' => 'Tommy Toe', 'age' => 33, 'title' => 'user']);
User::create(array('name' => 'Yvonne Yoe', 'age' => 35, 'title' => 'admin')); User::create(['name' => 'Yvonne Yoe', 'age' => 35, 'title' => 'admin']);
User::create(array('name' => 'Error', 'age' => null, 'title' => null)); User::create(['name' => 'Error', 'age' => null, 'title' => null]);
} }
public function tearDown() public function tearDown()
...@@ -83,13 +83,13 @@ class QueryTest extends TestCase { ...@@ -83,13 +83,13 @@ class QueryTest extends TestCase {
$this->assertEquals('admin', $user->title); $this->assertEquals('admin', $user->title);
$this->assertEquals(null, $user->age); $this->assertEquals(null, $user->age);
$user = User::where('name', 'John Doe')->select(array('name', 'title'))->get()->first(); $user = User::where('name', 'John Doe')->select(['name', 'title'])->get()->first();
$this->assertEquals('John Doe', $user->name); $this->assertEquals('John Doe', $user->name);
$this->assertEquals('admin', $user->title); $this->assertEquals('admin', $user->title);
$this->assertEquals(null, $user->age); $this->assertEquals(null, $user->age);
$user = User::where('name', 'John Doe')->get(array('name'))->first(); $user = User::where('name', 'John Doe')->get(['name'])->first();
$this->assertEquals('John Doe', $user->name); $this->assertEquals('John Doe', $user->name);
$this->assertEquals(null, $user->age); $this->assertEquals(null, $user->age);
...@@ -106,30 +106,30 @@ class QueryTest extends TestCase { ...@@ -106,30 +106,30 @@ class QueryTest extends TestCase {
public function testBetween() public function testBetween()
{ {
$users = User::whereBetween('age', array(0, 25))->get(); $users = User::whereBetween('age', [0, 25])->get();
$this->assertEquals(2, count($users)); $this->assertEquals(2, count($users));
$users = User::whereBetween('age', array(13, 23))->get(); $users = User::whereBetween('age', [13, 23])->get();
$this->assertEquals(2, count($users)); $this->assertEquals(2, count($users));
// testing whereNotBetween for version 4.1 // testing whereNotBetween for version 4.1
$users = User::whereBetween('age', array(0, 25), 'and', true)->get(); $users = User::whereBetween('age', [0, 25], 'and', true)->get();
$this->assertEquals(6, count($users)); $this->assertEquals(6, count($users));
} }
public function testIn() public function testIn()
{ {
$users = User::whereIn('age', array(13, 23))->get(); $users = User::whereIn('age', [13, 23])->get();
$this->assertEquals(2, count($users)); $this->assertEquals(2, count($users));
$users = User::whereIn('age', array(33, 35, 13))->get(); $users = User::whereIn('age', [33, 35, 13])->get();
$this->assertEquals(6, count($users)); $this->assertEquals(6, count($users));
$users = User::whereNotIn('age', array(33, 35))->get(); $users = User::whereNotIn('age', [33, 35])->get();
$this->assertEquals(4, count($users)); $this->assertEquals(4, count($users));
$users = User::whereNotNull('age') $users = User::whereNotNull('age')
->whereNotIn('age', array(33, 35))->get(); ->whereNotIn('age', [33, 35])->get();
$this->assertEquals(3, count($users)); $this->assertEquals(3, count($users));
} }
...@@ -263,13 +263,13 @@ class QueryTest extends TestCase { ...@@ -263,13 +263,13 @@ class QueryTest extends TestCase {
public function testWhereRaw() public function testWhereRaw()
{ {
$where = array('age' => array('$gt' => 30, '$lt' => 40)); $where = ['age' => ['$gt' => 30, '$lt' => 40]];
$users = User::whereRaw($where)->get(); $users = User::whereRaw($where)->get();
$this->assertEquals(6, count($users)); $this->assertEquals(6, count($users));
$where1 = array('age' => array('$gt' => 30, '$lte' => 35)); $where1 = ['age' => ['$gt' => 30, '$lte' => 35]];
$where2 = array('age' => array('$gt' => 35, '$lt' => 40)); $where2 = ['age' => ['$gt' => 35, '$lt' => 40]];
$users = User::whereRaw($where1)->orWhereRaw($where2)->get(); $users = User::whereRaw($where1)->orWhereRaw($where2)->get();
$this->assertEquals(6, count($users)); $this->assertEquals(6, count($users));
...@@ -307,7 +307,7 @@ class QueryTest extends TestCase { ...@@ -307,7 +307,7 @@ class QueryTest extends TestCase {
$this->assertNotNull($results->first()->title); $this->assertNotNull($results->first()->title);
$this->assertEquals(9, $results->total()); $this->assertEquals(9, $results->total());
$results = User::paginate(2, array('name', 'age')); $results = User::paginate(2, ['name', 'age']);
$this->assertEquals(2, $results->count()); $this->assertEquals(2, $results->count());
$this->assertNull($results->first()->title); $this->assertNull($results->first()->title);
$this->assertEquals(9, $results->total()); $this->assertEquals(9, $results->total());
......
This diff is collapsed.
...@@ -60,7 +60,7 @@ class SchemaTest extends TestCase { ...@@ -60,7 +60,7 @@ class SchemaTest extends TestCase {
Schema::collection('newcollection', function($collection) Schema::collection('newcollection', function($collection)
{ {
$collection->index(array('mykey')); $collection->index(['mykey']);
}); });
$index = $this->getIndex('newcollection', 'mykey'); $index = $this->getIndex('newcollection', 'mykey');
...@@ -92,7 +92,7 @@ class SchemaTest extends TestCase { ...@@ -92,7 +92,7 @@ class SchemaTest extends TestCase {
Schema::collection('newcollection', function($collection) Schema::collection('newcollection', function($collection)
{ {
$collection->unique('uniquekey'); $collection->unique('uniquekey');
$collection->dropIndex(array('uniquekey')); $collection->dropIndex(['uniquekey']);
}); });
$index = $this->getIndex('newcollection', 'uniquekey'); $index = $this->getIndex('newcollection', 'uniquekey');
......
...@@ -10,10 +10,10 @@ class TestCase extends Orchestra\Testbench\TestCase { ...@@ -10,10 +10,10 @@ class TestCase extends Orchestra\Testbench\TestCase {
*/ */
protected function getPackageProviders($app) protected function getPackageProviders($app)
{ {
return array( return [
'Jenssegers\Mongodb\MongodbServiceProvider', 'Jenssegers\Mongodb\MongodbServiceProvider',
'Jenssegers\Mongodb\Auth\PasswordResetServiceProvider', 'Jenssegers\Mongodb\Auth\PasswordResetServiceProvider',
); ];
} }
/** /**
......
...@@ -10,16 +10,16 @@ class ValidationTest extends TestCase { ...@@ -10,16 +10,16 @@ class ValidationTest extends TestCase {
public function testUnique() public function testUnique()
{ {
$validator = Validator::make( $validator = Validator::make(
array('name' => 'John Doe'), ['name' => 'John Doe'],
array('name' => 'required|unique:users') ['name' => 'required|unique:users']
); );
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
User::create(array('name' => 'John Doe')); User::create(['name' => 'John Doe']);
$validator = Validator::make( $validator = Validator::make(
array('name' => 'John Doe'), ['name' => 'John Doe'],
array('name' => 'required|unique:users') ['name' => 'required|unique:users']
); );
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());
} }
......
<?php <?php
return array( return [
'connections' => array( 'connections' => [
'mongodb' => array( 'mongodb' => [
'name' => 'mongodb', 'name' => 'mongodb',
'driver' => 'mongodb', 'driver' => 'mongodb',
'host' => 'localhost', 'host' => 'localhost',
'database' => 'unittest', 'database' => 'unittest',
), ],
'mysql' => array( 'mysql' => [
'driver' => 'mysql', 'driver' => 'mysql',
'host' => 'localhost', 'host' => 'localhost',
'database' => 'unittest', 'database' => 'unittest',
...@@ -20,7 +20,7 @@ return array( ...@@ -20,7 +20,7 @@ return array(
'charset' => 'utf8', 'charset' => 'utf8',
'collation' => 'utf8_unicode_ci', 'collation' => 'utf8_unicode_ci',
'prefix' => '', 'prefix' => '',
), ],
) ]
); ];
...@@ -9,6 +9,6 @@ class Soft extends Eloquent { ...@@ -9,6 +9,6 @@ class Soft extends Eloquent {
protected $collection = 'soft'; protected $collection = 'soft';
protected static $unguarded = true; protected static $unguarded = true;
protected $dates = array('deleted_at'); protected $dates = ['deleted_at'];
} }
...@@ -11,7 +11,7 @@ class User extends Eloquent implements AuthenticatableContract, CanResetPassword ...@@ -11,7 +11,7 @@ class User extends Eloquent implements AuthenticatableContract, CanResetPassword
use Authenticatable, CanResetPassword; use Authenticatable, CanResetPassword;
protected $dates = array('birthday', 'entry.date'); protected $dates = ['birthday', 'entry.date'];
protected static $unguarded = true; protected static $unguarded = true;
public function books() public function books()
......
...@@ -9,6 +9,6 @@ class UserTableSeeder extends Seeder { ...@@ -9,6 +9,6 @@ class UserTableSeeder extends Seeder {
{ {
DB::collection('users')->delete(); DB::collection('users')->delete();
DB::collection('users')->insert(array('name' => 'John Doe', 'seed' => true)); DB::collection('users')->insert(['name' => 'John Doe', 'seed' => true]);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment