File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -212,4 +212,20 @@ public function testPull()
212212 $ this ->assertEquals ('tag1 ' , $ user ['tags ' ][0 ]);
213213 }
214214
215+ public function testDistinct ()
216+ {
217+ DB ::collection ('items ' )->insert (array (
218+ array ('name ' => 'knife ' , 'type ' => 'sharp ' , 'amount ' => 34 ),
219+ array ('name ' => 'fork ' , 'type ' => 'sharp ' , 'amount ' => 20 ),
220+ array ('name ' => 'spoon ' , 'type ' => 'round ' , 'amount ' => 3 ),
221+ array ('name ' => 'spoon ' , 'type ' => 'round ' , 'amount ' => 14 )
222+ ));
223+
224+ $ items = DB ::collection ('items ' )->distinct ('name ' )->get ();
225+ $ this ->assertEquals (array ('knife ' , 'fork ' , 'spoon ' ), $ items );
226+
227+ $ types = DB ::collection ('items ' )->distinct ('type ' )->get ();
228+ $ this ->assertEquals (array ('sharp ' , 'round ' ), $ types );
229+ }
230+
215231}
You can’t perform that action at this time.
0 commit comments