summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortianhe1986 <w1s2j3229@163.com>2017-02-13 10:10:50 +0100
committertianhe1986 <w1s2j3229@163.com>2017-02-13 10:10:50 +0100
commit6e3384b012aec7a54b531aecdafd7aeeecd25e04 (patch)
tree2da8c571ca703403bc1e1a384dad731e4e432570
parent975d5cfca6248c55496b3e15b37fb2c81fb85f4c (diff)
Add unit test.
Signed-off-by: tianhe1986 <w1s2j3229@163.com>
-rw-r--r--tests/codeigniter/database/query_builder/group_test.php70
1 files changed, 70 insertions, 0 deletions
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