diff options
author | Taufan Aditya <toopay@taufanaditya.com> | 2012-05-04 20:06:41 +0200 |
---|---|---|
committer | Taufan Aditya <toopay@taufanaditya.com> | 2012-05-04 20:06:41 +0200 |
commit | 6657cc1672f3f466655b1e476028b9d46a16bd1c (patch) | |
tree | 6e53a22e7fb31e04a4183a71066815c2b3c3f8a1 /tests/codeigniter/database/query_builder | |
parent | 9ec507badf60952750e76b5d83da54874dd19119 (diff) |
DELETE code-coverage
Diffstat (limited to 'tests/codeigniter/database/query_builder')
-rw-r--r-- | tests/codeigniter/database/query_builder/delete_test.php | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/codeigniter/database/query_builder/delete_test.php b/tests/codeigniter/database/query_builder/delete_test.php new file mode 100644 index 000000000..84ea7616f --- /dev/null +++ b/tests/codeigniter/database/query_builder/delete_test.php @@ -0,0 +1,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()); + } + +}
\ No newline at end of file |