diff options
author | Taufan Aditya <toopay@taufanaditya.com> | 2012-05-04 15:34:30 +0200 |
---|---|---|
committer | Taufan Aditya <toopay@taufanaditya.com> | 2012-05-04 15:34:30 +0200 |
commit | 1afd479059c3d6f7c46aa0c36aa56cfba7f94226 (patch) | |
tree | de6410dd90b10e73b658b22186ac6ddc0fc574c9 /tests/codeigniter | |
parent | f7377abee2ef1e165a362edc9a1c650373a002ca (diff) |
HAVING clause API code-coverage
Diffstat (limited to 'tests/codeigniter')
-rw-r--r-- | tests/codeigniter/database/query_builder/group_test.php | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/codeigniter/database/query_builder/group_test.php b/tests/codeigniter/database/query_builder/group_test.php index dd248ae9a..7d8abc33f 100644 --- a/tests/codeigniter/database/query_builder/group_test.php +++ b/tests/codeigniter/database/query_builder/group_test.php @@ -22,16 +22,32 @@ class Group_test extends CI_TestCase { */ public function test_group_by() { - $jobs = $this->db->select('job.name as job_name, job.id as job_id') + $jobs = $this->db->select('name') ->from('job') - ->group_by('job_name HAVING SUM(job_id) > 2') + ->group_by('name') + ->get() + ->result_array(); + + // Check the result + $this->assertEquals(4, count($jobs)); + } + + // ------------------------------------------------------------------------ + + /** + * @see ./mocks/schema/skeleton.php + */ + public function test_having_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]['job_name']); - $this->assertEquals('Musician', $jobs[1]['job_name']); } }
\ No newline at end of file |