Skip to content
Snippets Groups Projects
Commit 7e5ae8d7 authored by Jörn Friedrich Dreyer's avatar Jörn Friedrich Dreyer Committed by Andreas Fischer
Browse files

test lastinsertid

parent 48621115
No related branches found
No related tags found
No related merge requests found
......@@ -71,7 +71,19 @@ class Test_DB extends PHPUnit_Framework_TestCase {
$result = $query->execute(array('uri_3'));
$this->assertTrue((bool)$result);
}
public function testLastInsertId() {
$query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)');
$result = OC_DB::executeAudited($query, array('insertid 1','uri_1'));
$id1 = OC_DB::insertid('*PREFIX*'.$this->table2);
// we don't know the id we should expect, so insert another row
$query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)');
$result = OC_DB::executeAudited($query, array('insertid 2','uri_2'));
$id2 = OC_DB::insertid('*PREFIX*'.$this->table2);
// now we can check if the two ids are in correct order
$this->assertEquals($id1+1, $id2);
}
public function testinsertIfNotExist() {
$categoryentries = array(
array('user' => 'test', 'type' => 'contact', 'category' => 'Family', 'expectedResult' => 1),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment