From 6e3384b012aec7a54b531aecdafd7aeeecd25e04 Mon Sep 17 00:00:00 2001 From: tianhe1986 Date: Mon, 13 Feb 2017 17:10:50 +0800 Subject: Add unit test. Signed-off-by: tianhe1986 --- .../database/query_builder/group_test.php | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'tests') diff --git a/tests/codeigniter/database/query_builder/group_test.php b/tests/codeigniter/database/query_builder/group_test.php index 5249f7c87..785754ec1 100644 --- a/tests/codeigniter/database/query_builder/group_test.php +++ b/tests/codeigniter/database/query_builder/group_test.php @@ -48,4 +48,74 @@ class Group_test extends CI_TestCase { $this->assertEquals(2, count($jobs)); } + // ------------------------------------------------------------------------ + + /** + * @see ./mocks/schema/skeleton.php + */ + public function test_having_in() + { + $jobs = $this->db->select('name') + ->from('job') + ->group_by('name') + ->having_in('SUM(id)', array(1, 2, 5)) + ->get() + ->result_array(); + + $this->assertEquals(2, count($jobs)); + } + + // ------------------------------------------------------------------------ + + /** + * @see ./mocks/schema/skeleton.php + */ + public function test_or_having_in() + { + $jobs = $this->db->select('name') + ->from('job') + ->group_by('name') + ->or_having_in('SUM(id)', array(1, 5)) + ->or_having_in('SUM(id)', array(2, 6)) + ->get() + ->result_array(); + + $this->assertEquals(2, count($jobs)); + } + + // ------------------------------------------------------------------------ + + /** + * @see ./mocks/schema/skeleton.php + */ + public function test_having_not_in() + { + $jobs = $this->db->select('name') + ->from('job') + ->group_by('name') + ->having_not_in('SUM(id)', array(3, 6)) + ->get() + ->result_array(); + + $this->assertEquals(3, count($jobs)); + } + + // ------------------------------------------------------------------------ + + /** + * @see ./mocks/schema/skeleton.php + */ + public function test_or_having_not_in() + { + $jobs = $this->db->select('name') + ->from('job') + ->group_by('name') + ->or_having_not_in('SUM(id)', array(1, 2, 3)) + ->or_having_not_in('SUM(id)', array(1, 3, 4)) + ->get() + ->result_array(); + + $this->assertEquals(2, count($jobs)); + } + } \ No newline at end of file -- cgit v1.2.3-24-g4f1b