blob: da312d866f9e183ac586a9dac21b22aec1d95897 [file] [log] [blame]
Taufan Adityac386b2a2012-05-05 00:42:02 +07001<?php
2
3class 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 {
Andrey Andreevc1862882012-06-09 23:16:58 +030025 $this->assertEquals(4, $this->db->count_all('job'));
Taufan Adityac386b2a2012-05-05 00:42:02 +070026 }
27
28 // ------------------------------------------------------------------------
29
30 /**
31 * @see ./mocks/schema/skeleton.php
32 */
33 public function test_count_all_results()
34 {
Andrey Andreevc1862882012-06-09 23:16:58 +030035 $this->assertEquals(2, $this->db->like('name', 'ian')->count_all_results('job'));
Taufan Adityac386b2a2012-05-05 00:42:02 +070036 }
Andrey Andreevc1862882012-06-09 23:16:58 +030037
Andrey Andreev2c1b3d92017-06-15 14:22:49 +030038 // ------------------------------------------------------------------------
39
40 /**
41 * @see ./mocks/schema/skeleton.php
42 */
43 public function test_count_all_results_limit()
44 {
45 $this->assertEquals(1, $this->db->like('name', 'ian')->limit(1)->count_all_results('job'));
46 }
47
Taufan Adityac386b2a2012-05-05 00:42:02 +070048}