summaryrefslogtreecommitdiffstats
path: root/tests/lib/db.php
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2013-07-09 12:31:46 +0200
committerAndreas Fischer <bantu@owncloud.com>2013-07-29 01:57:30 +0200
commit7e5ae8d78082891386f170d2d3db9b7ca7436e4c (patch)
tree73d5872dcafbecd6328c4831e3694bfffe78b642 /tests/lib/db.php
parent48621115c10f62f776dbe41ad9a51c1ac360fc8c (diff)
downloadnextcloud-server-7e5ae8d78082891386f170d2d3db9b7ca7436e4c.tar.gz
nextcloud-server-7e5ae8d78082891386f170d2d3db9b7ca7436e4c.zip
test lastinsertid
Diffstat (limited to 'tests/lib/db.php')
-rw-r--r--tests/lib/db.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/lib/db.php b/tests/lib/db.php
index e817a2db5ed..e965ce8e1cb 100644
--- a/tests/lib/db.php
+++ b/tests/lib/db.php
@@ -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),