diff options
author | Taufan Aditya <toopay@taufanaditya.com> | 2012-05-04 14:22:48 +0200 |
---|---|---|
committer | Taufan Aditya <toopay@taufanaditya.com> | 2012-05-04 14:22:48 +0200 |
commit | 4e607b00b2c56b7fdcc5f1d1a290be2363c74a46 (patch) | |
tree | d280b20041e2de10a3779bde131963202d1c2757 /tests/codeigniter/database/query_builder/group_test.php | |
parent | f78018ec6b081518e4be24934448862a31bda9f8 (diff) |
GROUP BY clause API code-coverage
Diffstat (limited to 'tests/codeigniter/database/query_builder/group_test.php')
-rw-r--r-- | tests/codeigniter/database/query_builder/group_test.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/codeigniter/database/query_builder/group_test.php b/tests/codeigniter/database/query_builder/group_test.php new file mode 100644 index 000000000..ddb2d0d6a --- /dev/null +++ b/tests/codeigniter/database/query_builder/group_test.php @@ -0,0 +1,37 @@ +<?php + +class Group_test extends CI_TestCase { + + /** + * @var object Database/Query Builder holder + */ + protected $db; + + public function set_up() + { + $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER); + + Mock_Database_Schema_Skeleton::create_tables(); + Mock_Database_Schema_Skeleton::create_data(); + } + + // ------------------------------------------------------------------------ + + /** + * @see ./mocks/schema/skeleton.php + */ + public function test_group_by() + { + $jobs = $this->db->select('name') + ->from('job') + ->group_by('name HAVING SUM(id) > 2') + ->get() + ->result_array(); + + // Check the result + $this->assertEquals(2, count($jobs)); + $this->assertEquals('Accountant', $jobs[0]['name']); + $this->assertEquals('Musician', $jobs[1]['name']); + } + +}
\ No newline at end of file |