blob: 84ea7616ff5ad68a7fcc14529df924c3a9368a17 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<?php
class Delete_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_delete()
{
// Check initial record
$job1 = $this->db->where('id', 1)
->get('job')
->row();
$this->assertEquals('Developer', $job1->name);
// Do the delete
$this->db->delete('job', array('id' => 1));
// Check the record
$job1 = $this->db->where('id', 1)
->get('job');
$this->assertEmpty($job1->result_array());
}
// ------------------------------------------------------------------------
/**
* @see ./mocks/schema/skeleton.php
*/
public function test_delete_several_tables()
{
// Check initial record
$user4 = $this->db->where('id', 4)
->get('user')
->row();
$job4 = $this->db->where('id', 4)
->get('job')
->row();
$this->assertEquals('Musician', $job4->name);
$this->assertEquals('Chris Martin', $user4->name);
// Do the delete
$this->db->delete(array('job', 'user'), array('id' => 4));
// Check the record
$job4 = $this->db->where('id', 4)->get('job');
$user4 = $this->db->where('id', 4)->get('user');
$this->assertEmpty($job4->result_array());
$this->assertEmpty($user4->result_array());
}
}
|