summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTaufan Aditya <toopay@taufanaditya.com>2012-04-05 14:08:00 +0200
committerTaufan Aditya <toopay@taufanaditya.com>2012-04-05 14:08:00 +0200
commitfdc0ea8802c48a5f74df97c013f683d4b264218a (patch)
tree0d1735d3e8d2270dfaa2e014fc78116d882e0379 /tests
parent55f622f76371949ae615ccdff76ed1e4bab55170 (diff)
Min, Max, Avg and Sum
Diffstat (limited to 'tests')
-rw-r--r--tests/codeigniter/database/query_builder/select_test.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/codeigniter/database/query_builder/select_test.php b/tests/codeigniter/database/query_builder/select_test.php
index ba2f21b64..50a062c9f 100644
--- a/tests/codeigniter/database/query_builder/select_test.php
+++ b/tests/codeigniter/database/query_builder/select_test.php
@@ -33,5 +33,65 @@ class Select_test extends CI_TestCase {
$this->assertFalse(array_key_exists('id', $jobs_name[0]));
$this->assertFalse(array_key_exists('description', $jobs_name[0]));
}
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_select_min()
+ {
+ $job_min = $this->query_builder->select_min('id')
+ ->get('job')
+ ->result_array();
+
+ // Minimum id was 1
+ $this->assertEquals('1', $job_min[0]['id']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_select_max()
+ {
+ $job_max = $this->query_builder->select_max('id')
+ ->get('job')
+ ->result_array();
+
+ // Maximum id was 4
+ $this->assertEquals('4', $job_max[0]['id']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_select_avg()
+ {
+ $job_avg = $this->query_builder->select_avg('id')
+ ->get('job')
+ ->result_array();
+
+ // Average should be 2.5
+ $this->assertEquals('2.5', $job_avg[0]['id']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_select_sum()
+ {
+ $job_sum = $this->query_builder->select_sum('id')
+ ->get('job')
+ ->result_array();
+
+ // Sum of ids should be 10
+ $this->assertEquals('10', $job_sum[0]['id']);
+ }
} \ No newline at end of file