@@ -234,17 +234,25 @@ public function testPush()
234234 DB ::collection ('users ' )->where ('_id ' , $ id )->push ('messages ' , $ message );
235235 $ user = DB ::collection ('users ' )->find ($ id );
236236 $ this ->assertTrue (is_array ($ user ['messages ' ]));
237+ $ this ->assertEquals (1 , count ($ user ['messages ' ]));
237238 $ this ->assertEquals ($ message , $ user ['messages ' ][0 ]);
239+
240+ // Raw
241+ DB ::collection ('users ' )->where ('_id ' , $ id )->push (array ('tags ' => 'tag3 ' , 'messages ' => array ('from ' => 'Mark ' , 'body ' => 'Hi John ' )));
242+ $ user = DB ::collection ('users ' )->find ($ id );
243+ $ this ->assertEquals (4 , count ($ user ['tags ' ]));
244+ $ this ->assertEquals (2 , count ($ user ['messages ' ]));
238245 }
239246
240247 public function testPull ()
241248 {
242- $ message = array ('from ' => 'Jane ' , 'body ' => 'Hi John ' );
249+ $ message1 = array ('from ' => 'Jane ' , 'body ' => 'Hi John ' );
250+ $ message2 = array ('from ' => 'Mark ' , 'body ' => 'Hi John ' );
243251
244252 $ id = DB ::collection ('users ' )->insertGetId (array (
245253 'name ' => 'John Doe ' ,
246254 'tags ' => array ('tag1 ' , 'tag2 ' , 'tag3 ' , 'tag4 ' ),
247- 'messages ' => array ($ message )
255+ 'messages ' => array ($ message1 , $ message2 )
248256 ));
249257
250258 DB ::collection ('users ' )->where ('_id ' , $ id )->pull ('tags ' , 'tag3 ' );
@@ -254,10 +262,16 @@ public function testPull()
254262 $ this ->assertEquals (3 , count ($ user ['tags ' ]));
255263 $ this ->assertEquals ('tag4 ' , $ user ['tags ' ][2 ]);
256264
257- DB ::collection ('users ' )->where ('_id ' , $ id )->pull ('messages ' , $ message );
265+ DB ::collection ('users ' )->where ('_id ' , $ id )->pull ('messages ' , $ message1 );
258266
259267 $ user = DB ::collection ('users ' )->find ($ id );
260268 $ this ->assertTrue (is_array ($ user ['messages ' ]));
269+ $ this ->assertEquals (1 , count ($ user ['messages ' ]));
270+
271+ // Raw
272+ DB ::collection ('users ' )->where ('_id ' , $ id )->pull (array ('tags ' => 'tag2 ' , 'messages ' => $ message2 ));
273+ $ user = DB ::collection ('users ' )->find ($ id );
274+ $ this ->assertEquals (2 , count ($ user ['tags ' ]));
261275 $ this ->assertEquals (0 , count ($ user ['messages ' ]));
262276 }
263277
0 commit comments