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/codeigniter/database/query_builder/group_test.php') 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 From 3e0ad435f13179ed1c590bdeba2fbeeaa7d0f9c2 Mon Sep 17 00:00:00 2001 From: tianhe1986 Date: Tue, 21 Feb 2017 09:38:08 +0800 Subject: Use less indentation. Signed-off-by: tianhe1986 --- .../database/query_builder/group_test.php | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'tests/codeigniter/database/query_builder/group_test.php') diff --git a/tests/codeigniter/database/query_builder/group_test.php b/tests/codeigniter/database/query_builder/group_test.php index 785754ec1..51266e858 100644 --- a/tests/codeigniter/database/query_builder/group_test.php +++ b/tests/codeigniter/database/query_builder/group_test.php @@ -56,11 +56,11 @@ class Group_test extends CI_TestCase { 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(); + ->from('job') + ->group_by('name') + ->having_in('SUM(id)', array(1, 2, 5)) + ->get() + ->result_array(); $this->assertEquals(2, count($jobs)); } @@ -73,12 +73,12 @@ class Group_test extends CI_TestCase { 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(); + ->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)); } @@ -91,11 +91,11 @@ class Group_test extends CI_TestCase { 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(); + ->from('job') + ->group_by('name') + ->having_not_in('SUM(id)', array(3, 6)) + ->get() + ->result_array(); $this->assertEquals(3, count($jobs)); } @@ -108,12 +108,12 @@ class Group_test extends CI_TestCase { 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(); + ->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)); } -- cgit v1.2.3-24-g4f1b