@@ -196,7 +196,8 @@ public function testPush()
196196 {
197197 $id = DB::collection('users')->insertGetId(array(
198198 'name' => 'John Doe',
199- 'tags' => array()
199+ 'tags' => array(),
200+ 'messages' => array(),
200201 ));
201202
202203 DB::collection('users')->where('_id', $id)->push('tags', 'tag1');
@@ -213,19 +214,22 @@ public function testPush()
213214 $this->assertEquals(2, count($user['tags']));
214215 $this->assertEquals('tag2', $user['tags'][1]);
215216
216- DB::collection('users')->where('_id', $id)->push('tags', array('tag3', 'tag4'));
217-
217+ $message = array('from' => 'Jane', 'body' => 'Hi John');
218+ DB::collection('users')->where('_id', $id)->push('messages', $message);
219+
218220 $user = DB::collection('users')->find($id);
219- $this->assertTrue(is_array($user['tags']));
220- $this->assertEquals(4, count($user['tags']));
221- $this->assertEquals('tag4', $user['tags'][3]);
221+ $this->assertTrue(is_array($user['messages']));
222+ $this->assertEquals($message, $user['messages'][0]);
222223 }
223224
224225 public function testPull()
225226 {
227+ $message = array('from' => 'Jane', 'body' => 'Hi John');
228+
226229 $id = DB::collection('users')->insertGetId(array(
227230 'name' => 'John Doe',
228- 'tags' => array('tag1', 'tag2', 'tag3', 'tag4')
231+ 'tags' => array('tag1', 'tag2', 'tag3', 'tag4'),
232+ 'messages' => array($message)
229233 ));
230234
231235 DB::collection('users')->where('_id', $id)->pull('tags', 'tag3');
@@ -235,12 +239,11 @@ public function testPull()
235239 $this->assertEquals(3, count($user['tags']));
236240 $this->assertEquals('tag4', $user['tags'][2]);
237241
238- DB::collection('users')->where('_id', $id)->pull('tags ', array('tag2', 'tag4') );
239-
242+ DB::collection('users')->where('_id', $id)->pull('messages ', $message );
243+
240244 $user = DB::collection('users')->find($id);
241- $this->assertTrue(is_array($user['tags']));
242- $this->assertEquals(1, count($user['tags']));
243- $this->assertEquals('tag1', $user['tags'][0]);
245+ $this->assertTrue(is_array($user['messages']));
246+ $this->assertEquals(0, count($user['messages']));
244247 }
245248
246249 public function testDistinct()
0 commit comments