Skip to content

Commit 18a1010

Browse files
committed
Unittest for distinct
1 parent e3f8c87 commit 18a1010

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/QueryTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)