Taufan Aditya | 5b42166 | 2012-04-05 01:24:50 +0700 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | class Get_test extends CI_TestCase { |
| 4 | |
| 5 | /** |
| 6 | * @var object Database/Query Builder holder |
| 7 | */ |
| 8 | protected $query_builder; |
| 9 | |
| 10 | public function set_up() |
| 11 | { |
Taufan Aditya | 55f622f | 2012-04-05 19:01:34 +0700 | [diff] [blame^] | 12 | $db = Mock_Database_Schema_Skeleton::init(DB_DRIVER); |
Taufan Aditya | 5b42166 | 2012-04-05 01:24:50 +0700 | [diff] [blame] | 13 | |
Taufan Aditya | 55f622f | 2012-04-05 19:01:34 +0700 | [diff] [blame^] | 14 | Mock_Database_Schema_Skeleton::create_tables(); |
| 15 | Mock_Database_Schema_Skeleton::create_data(); |
Taufan Aditya | 5b42166 | 2012-04-05 01:24:50 +0700 | [diff] [blame] | 16 | |
| 17 | $this->query_builder = $db; |
| 18 | } |
| 19 | |
| 20 | // ------------------------------------------------------------------------ |
| 21 | |
| 22 | /** |
| 23 | * @see ./mocks/schema/skeleton.php |
| 24 | */ |
| 25 | public function test_get_simple() |
| 26 | { |
| 27 | $jobs = $this->query_builder->get('job')->result_array(); |
| 28 | |
| 29 | // Dummy jobs contain 4 rows |
| 30 | $this->assertCount(4, $jobs); |
| 31 | |
| 32 | // Check rows item |
| 33 | $this->assertEquals('Developer', $jobs[0]['name']); |
| 34 | $this->assertEquals('Politician', $jobs[1]['name']); |
| 35 | $this->assertEquals('Accountant', $jobs[2]['name']); |
| 36 | $this->assertEquals('Musician', $jobs[3]['name']); |
| 37 | } |
Taufan Aditya | 55f622f | 2012-04-05 19:01:34 +0700 | [diff] [blame^] | 38 | |
| 39 | // ------------------------------------------------------------------------ |
| 40 | |
| 41 | /** |
| 42 | * @see ./mocks/schema/skeleton.php |
| 43 | */ |
| 44 | public function test_get_where() |
| 45 | { |
| 46 | $job1 = $this->query_builder->get('job', array('id' => 1))->result_array(); |
| 47 | |
| 48 | // Dummy jobs contain 1 rows |
| 49 | $this->assertCount(1, $job1); |
| 50 | |
| 51 | // Check rows item |
| 52 | $this->assertEquals('Developer', $job1[0]['name']); |
| 53 | } |
Taufan Aditya | 5b42166 | 2012-04-05 01:24:50 +0700 | [diff] [blame] | 54 | |
| 55 | } |