blob: a1976d4570c2305822e1c6bf0a8bd29c591b7e91 [file] [log] [blame]
Taufan Adityabe6fb422012-05-05 00:35:41 +07001<?php
2
3class Limit_test extends CI_TestCase {
4
5 /**
6 * @var object Database/Query Builder holder
7 */
8 protected $db;
9
10 public function set_up()
11 {
12 $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
13
14 Mock_Database_Schema_Skeleton::create_tables();
15 Mock_Database_Schema_Skeleton::create_data();
16 }
17
18 // ------------------------------------------------------------------------
19
20 /**
21 * @see ./mocks/schema/skeleton.php
22 */
23 public function test_limit()
24 {
25 $jobs = $this->db->limit(2)
26 ->get('job')
27 ->result_array();
Andrey Andreevc1862882012-06-09 23:16:58 +030028
Andrey Andreev20d9b0a2017-12-20 19:57:39 +020029 $this->assertCount(2, $jobs);
Taufan Adityabe6fb422012-05-05 00:35:41 +070030 }
31
32 // ------------------------------------------------------------------------
33
34 /**
35 * @see ./mocks/schema/skeleton.php
36 */
37 public function test_limit_and_offset()
38 {
39 $jobs = $this->db->limit(2, 2)
40 ->get('job')
41 ->result_array();
Andrey Andreevc1862882012-06-09 23:16:58 +030042
Andrey Andreev20d9b0a2017-12-20 19:57:39 +020043 $this->assertCount(2, $jobs);
Taufan Adityabe6fb422012-05-05 00:35:41 +070044 $this->assertEquals('Accountant', $jobs[0]['name']);
45 $this->assertEquals('Musician', $jobs[1]['name']);
46 }
Andrey Andreevc1862882012-06-09 23:16:58 +030047
Andrey Andreev20d9b0a2017-12-20 19:57:39 +020048}