diff options
author | Timothy Warren <tim@timshomepage.net> | 2012-05-16 14:48:13 +0200 |
---|---|---|
committer | Timothy Warren <tim@timshomepage.net> | 2012-05-16 14:48:13 +0200 |
commit | 351c2e1b0d3fdca80a5483d708d7c71084226e68 (patch) | |
tree | 749c6accebdf6da1c301f9c2ee76c78bfe15954e /tests/codeigniter/database/query_builder/group_test.php | |
parent | 2ed226bd5ed19754c2fb28d4b98ac5423741f039 (diff) | |
parent | 8279420f989a8cda4427c3983ee919c6a1073dd7 (diff) |
Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into errors
Diffstat (limited to 'tests/codeigniter/database/query_builder/group_test.php')
-rw-r--r-- | tests/codeigniter/database/query_builder/group_test.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/codeigniter/database/query_builder/group_test.php b/tests/codeigniter/database/query_builder/group_test.php new file mode 100644 index 000000000..7d8abc33f --- /dev/null +++ b/tests/codeigniter/database/query_builder/group_test.php @@ -0,0 +1,53 @@ +<?php + +class Group_test extends CI_TestCase { + + /** + * @var object Database/Query Builder holder + */ + protected $db; + + public function set_up() + { + $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER); + + Mock_Database_Schema_Skeleton::create_tables(); + Mock_Database_Schema_Skeleton::create_data(); + } + + // ------------------------------------------------------------------------ + + /** + * @see ./mocks/schema/skeleton.php + */ + public function test_group_by() + { + $jobs = $this->db->select('name') + ->from('job') + ->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)); + } + +}
\ No newline at end of file |