diff options
author | Taufan Aditya <toopay@taufanaditya.com> | 2012-05-04 19:35:41 +0200 |
---|---|---|
committer | Taufan Aditya <toopay@taufanaditya.com> | 2012-05-04 19:35:41 +0200 |
commit | be6fb4271ce723376930507dbe534f91344f26c7 (patch) | |
tree | 9c7dc92808ca3be128ab85456f032f3c67a2c4eb | |
parent | d2d329a99f60bebc36eebc1c7b3c1a94b9789b49 (diff) |
LIMIT clause API code-coverage
-rw-r--r-- | tests/codeigniter/database/query_builder/limit_test.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/codeigniter/database/query_builder/limit_test.php b/tests/codeigniter/database/query_builder/limit_test.php new file mode 100644 index 000000000..704f3b651 --- /dev/null +++ b/tests/codeigniter/database/query_builder/limit_test.php @@ -0,0 +1,49 @@ +<?php + +class Limit_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_limit() + { + $jobs = $this->db->limit(2) + ->get('job') + ->result_array(); + + // Check the result + $this->assertEquals(2, count($jobs)); + } + + // ------------------------------------------------------------------------ + + /** + * @see ./mocks/schema/skeleton.php + */ + public function test_limit_and_offset() + { + $jobs = $this->db->limit(2, 2) + ->get('job') + ->result_array(); + + // Check the result + $this->assertEquals(2, count($jobs)); + $this->assertEquals('Accountant', $jobs[0]['name']); + $this->assertEquals('Musician', $jobs[1]['name']); + } +}
\ No newline at end of file |