Taufan Aditya | c386b2a | 2012-05-05 00:42:02 +0700 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | class Count_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_count_all() |
| 24 | { |
| 25 | $job_count = $this->db->count_all('job'); |
| 26 | |
| 27 | // Check the result |
| 28 | $this->assertEquals(4, $job_count); |
| 29 | } |
| 30 | |
| 31 | // ------------------------------------------------------------------------ |
| 32 | |
| 33 | /** |
| 34 | * @see ./mocks/schema/skeleton.php |
| 35 | */ |
| 36 | public function test_count_all_results() |
| 37 | { |
| 38 | $job_count = $this->db->like('name', 'ian') |
| 39 | ->count_all_results('job'); |
| 40 | |
| 41 | // Check the result |
| 42 | $this->assertEquals(2, $job_count); |
| 43 | } |
| 44 | } |