summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/database/query_builder/insert_test.php
blob: 5607e8ce1334bbd414f9ba6e9fb42ef4858111b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

class Insert_test extends CI_TestCase {

	/**
	 * @var object Database/Query Builder holder
	 */
	protected $db;

	public function set_up()
	{
		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);

		Mock_Database_Schema_Skeleton::create_tables();
		Mock_Database_Schema_Skeleton::create_data();
	}

	// ------------------------------------------------------------------------

	/**
	 * @see ./mocks/schema/skeleton.php
	 */
	public function test_insert()
	{
		$job_data = array('name' => 'Grocery Sales', 'description' => 'Discount!');
		
		// Do normal insert
		$this->assertTrue($this->db->insert('job', $job_data));
	}

	// ------------------------------------------------------------------------

	/**
	 * @see ./mocks/schema/skeleton.php
	 */
	public function test_insert_batch()
	{
		$job_datas = array(
			array('name' => 'Commedian', 'description' => 'Theres something in your teeth'), 
			array('name' => 'Cab Driver', 'description' => 'Iam yellow'),
		);
		
		// Do insert batch
		$this->assertTrue($this->db->insert_batch('job', $job_datas));
	}
	
}