Commit 18a1010c authored by Jens Segers's avatar Jens Segers

Unittest for distinct

parent e3f8c872
......@@ -212,4 +212,20 @@ class QueryTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('tag1', $user['tags'][0]);
}
public function testDistinct()
{
DB::collection('items')->insert(array(
array('name' => 'knife', 'type' => 'sharp', 'amount' => 34),
array('name' => 'fork', 'type' => 'sharp', 'amount' => 20),
array('name' => 'spoon', 'type' => 'round', 'amount' => 3),
array('name' => 'spoon', 'type' => 'round', 'amount' => 14)
));
$items = DB::collection('items')->distinct('name')->get();
$this->assertEquals(array('knife', 'fork', 'spoon'), $items);
$types = DB::collection('items')->distinct('type')->get();
$this->assertEquals(array('sharp', 'round'), $types);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment