Taufan Aditya | c0df5a2 | 2012-04-06 17:35:12 +0700 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | class Insert_test extends CI_TestCase { |
| 4 | |
| 5 | /** |
| 6 | * @var object Database/Query Builder holder |
Taufan Aditya | fc92fc2 | 2012-04-06 18:00:55 +0700 | [diff] [blame^] | 7 | * @see ./mocks/schema/skeleton.php |
Taufan Aditya | c0df5a2 | 2012-04-06 17:35:12 +0700 | [diff] [blame] | 8 | */ |
| 9 | protected $db; |
| 10 | |
| 11 | public function set_up() |
| 12 | { |
| 13 | $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER); |
| 14 | |
| 15 | Mock_Database_Schema_Skeleton::create_tables(); |
Taufan Aditya | fc92fc2 | 2012-04-06 18:00:55 +0700 | [diff] [blame^] | 16 | |
| 17 | // Truncate the current datas |
| 18 | $this->db->truncate('job'); |
Taufan Aditya | c0df5a2 | 2012-04-06 17:35:12 +0700 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | // ------------------------------------------------------------------------ |
| 22 | |
| 23 | /** |
| 24 | * @see ./mocks/schema/skeleton.php |
| 25 | */ |
| 26 | public function test_insert() |
| 27 | { |
Taufan Aditya | 81b6b5d | 2012-04-06 17:58:22 +0700 | [diff] [blame] | 28 | $job_data = array('id' => 1, 'name' => 'Grocery Sales', 'description' => 'Discount!'); |
Taufan Aditya | c0df5a2 | 2012-04-06 17:35:12 +0700 | [diff] [blame] | 29 | |
| 30 | // Do normal insert |
| 31 | $this->assertTrue($this->db->insert('job', $job_data)); |
| 32 | } |
| 33 | |
| 34 | // ------------------------------------------------------------------------ |
| 35 | |
| 36 | /** |
| 37 | * @see ./mocks/schema/skeleton.php |
| 38 | */ |
| 39 | public function test_insert_batch() |
| 40 | { |
| 41 | $job_datas = array( |
Taufan Aditya | 81b6b5d | 2012-04-06 17:58:22 +0700 | [diff] [blame] | 42 | array('id' => 2, 'name' => 'Commedian', 'description' => 'Theres something in your teeth'), |
| 43 | array('id' => 3, 'name' => 'Cab Driver', 'description' => 'Iam yellow'), |
Taufan Aditya | c0df5a2 | 2012-04-06 17:35:12 +0700 | [diff] [blame] | 44 | ); |
| 45 | |
| 46 | // Do insert batch |
| 47 | $this->assertTrue($this->db->insert_batch('job', $job_datas)); |
| 48 | } |
| 49 | |
| 50 | } |