Skip to content

Commit b45d303

Browse files
committed
Tweaked tests
1 parent e44534d commit b45d303

File tree

2 files changed

+40
-16
lines changed

2 files changed

+40
-16
lines changed

tests/ModelTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public function tearDown()
1010
User::truncate();
1111
Soft::truncate();
1212
Book::truncate();
13+
Item::truncate();
1314
}
1415

1516
public function testNewModel()
@@ -120,6 +121,31 @@ public function testFind()
120121
$this->assertEquals(35, $check->age);
121122
}
122123

124+
public function testGet()
125+
{
126+
User::insert(array(
127+
array('name' => 'John Doe'),
128+
array('name' => 'Jane Doe')
129+
));
130+
131+
$users = User::get();
132+
$this->assertEquals(2, count($users));
133+
$this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $users);
134+
$this->assertInstanceOf('Jenssegers\Mongodb\Model', $users[0]);
135+
}
136+
137+
public function testFirst()
138+
{
139+
User::insert(array(
140+
array('name' => 'John Doe'),
141+
array('name' => 'Jane Doe')
142+
));
143+
144+
$user = User::get()->first();
145+
$this->assertInstanceOf('Jenssegers\Mongodb\Model', $user);
146+
$this->assertEquals('John Doe', $user->name);
147+
}
148+
123149
/**
124150
* @expectedException Illuminate\Database\Eloquent\ModelNotFoundException
125151
*/
@@ -225,4 +251,18 @@ public function testScope()
225251
$this->assertEquals(1, $sharp->count());
226252
}
227253

254+
public function testToArray()
255+
{
256+
$original = array(
257+
array('name' => 'knife', 'type' => 'sharp'),
258+
array('name' => 'spoon', 'type' => 'round')
259+
);
260+
261+
Item::insert($original);
262+
263+
$items = Item::all();
264+
$this->assertEquals($original, $items->toArray());
265+
$this->assertEquals($original[0], $items[0]->toArray());
266+
}
267+
228268
}

tests/QueryTest.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,6 @@ public static function tearDownAfterClass()
2121
User::truncate();
2222
}
2323

24-
public function testGet()
25-
{
26-
$users = User::get();
27-
28-
$this->assertEquals(9, count($users));
29-
$this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $users);
30-
$this->assertInstanceOf('Jenssegers\Mongodb\Model', $users[0]);
31-
}
32-
33-
public function testFirst()
34-
{
35-
$user = User::get()->first();
36-
$this->assertInstanceOf('Jenssegers\Mongodb\Model', $user);
37-
$this->assertEquals('John Doe', $user->name);
38-
}
39-
4024
public function testWhere()
4125
{
4226
$users = User::where('age', 35)->get();

0 commit comments

Comments
 (0)