summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <morris.jobke@gmail.com>2013-07-31 00:03:29 -0700
committerMorris Jobke <morris.jobke@gmail.com>2013-07-31 00:03:29 -0700
commit50101a85a63f29c47abe325aecb3af26bc8a96d1 (patch)
tree32c32b4ddbc89e0db3d429589544500411bc8300 /tests
parent761f40328cdfee6a91c18fdf78e154e36000c251 (diff)
parentb8bd1e5a81080a756913e5804b877aafd770f6e3 (diff)
downloadnextcloud-server-50101a85a63f29c47abe325aecb3af26bc8a96d1.tar.gz
nextcloud-server-50101a85a63f29c47abe325aecb3af26bc8a96d1.zip
Merge pull request #3982 from owncloud/test_lastinsertid
test lastinsertid
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/db.php16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/lib/db.php b/tests/lib/db.php
index e817a2db5ed..79e05f30a1c 100644
--- a/tests/lib/db.php
+++ b/tests/lib/db.php
@@ -71,7 +71,21 @@ 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 (?,?)');
+ $result1 = OC_DB::executeAudited($query, array('insertid 1','uri_1'));
+ $id1 = OC_DB::insertid('*PREFIX*'.$this->table2);
+ $this->assertInternalType('int', $id1);
+
+ // we don't know the id we should expect, so insert another row
+ $result2 = 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->assertInternalType('int', $id2);
+ $this->assertGreaterThan($id1, $id2);
+ }
+
public function testinsertIfNotExist() {
$categoryentries = array(
array('user' => 'test', 'type' => 'contact', 'category' => 'Family', 'expectedResult' => 1),