summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-11-23 13:29:08 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-11-23 13:29:08 +0100
commitdf906f475bbf22788620ef05a58231639b5423ad (patch)
tree5993395b1bf1c1aea9bd926263a93665e39a1dc7 /tests
parent240cc1c4ead5f89e3c296bfb8f0b34b7c3748316 (diff)
parentaa660ec232a236a9c62e4bf2b1535127bb8521be (diff)
downloadnextcloud-server-df906f475bbf22788620ef05a58231639b5423ad.tar.gz
nextcloud-server-df906f475bbf22788620ef05a58231639b5423ad.zip
Merge pull request #20617 from owncloud/fix-usage-of-lastInsertId
lastInsertId() is properly working with Oracle if the table name is p…
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/repair/cleantags.php16
-rw-r--r--tests/lib/repair/oldgroupmembershipsharestest.php21
-rw-r--r--tests/lib/repair/repairinvalidsharestest.php14
3 files changed, 7 insertions, 44 deletions
diff --git a/tests/lib/repair/cleantags.php b/tests/lib/repair/cleantags.php
index a511daa03d6..896dd333cc2 100644
--- a/tests/lib/repair/cleantags.php
+++ b/tests/lib/repair/cleantags.php
@@ -165,20 +165,6 @@ class CleanTags extends \Test\TestCase {
* @return int
*/
protected function getLastInsertID($tableName, $idName) {
- $id = $this->connection->lastInsertId();
- if ($id) {
- return $id;
- }
-
- // FIXME !!!! ORACLE WORKAROUND DO NOT COPY
- // FIXME INSTEAD HELP FIXING DOCTRINE
- // FIXME https://github.com/owncloud/core/issues/13303
- // FIXME ALSO FIX https://github.com/owncloud/core/commit/2dd85ec984c12d3be401518f22c90d2327bec07a
- $qb = $this->connection->getQueryBuilder();
- $result = $qb->select($qb->createFunction('MAX(`' . $idName . '`)'))
- ->from($tableName)
- ->execute();
-
- return (int) $result->fetchColumn();
+ return $this->connection->lastInsertId("*PREFIX*$tableName");
}
}
diff --git a/tests/lib/repair/oldgroupmembershipsharestest.php b/tests/lib/repair/oldgroupmembershipsharestest.php
index 74f68bd7899..272e1ef09c4 100644
--- a/tests/lib/repair/oldgroupmembershipsharestest.php
+++ b/tests/lib/repair/oldgroupmembershipsharestest.php
@@ -72,7 +72,7 @@ class OldGroupMembershipSharesTest extends \Test\TestCase {
->orderBy('id', 'ASC')
->execute();
$rows = $result->fetchAll();
- $this->assertSame([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member], ['id' => $notAMember]], $rows);
+ $this->assertEquals([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member], ['id' => $notAMember]], $rows);
$result->closeCursor();
$repair->run();
@@ -83,7 +83,7 @@ class OldGroupMembershipSharesTest extends \Test\TestCase {
->orderBy('id', 'ASC')
->execute();
$rows = $result->fetchAll();
- $this->assertSame([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member]], $rows);
+ $this->assertEquals([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member]], $rows);
$result->closeCursor();
}
@@ -118,21 +118,6 @@ class OldGroupMembershipSharesTest extends \Test\TestCase {
->values($shareValues)
->execute();
- return $this->getLastShareId();
- }
-
- /**
- * @return int
- */
- protected function getLastShareId() {
- // select because lastInsertId does not work with OCI
- $query = $this->connection->getQueryBuilder();
- $result = $query->select('id')
- ->from('share')
- ->orderBy('id', 'DESC')
- ->execute();
- $row = $result->fetch();
- $result->closeCursor();
- return $row['id'];
+ return $this->connection->lastInsertId('*PREFIX*share');
}
}
diff --git a/tests/lib/repair/repairinvalidsharestest.php b/tests/lib/repair/repairinvalidsharestest.php
index 005a2db2344..e8dcaa4da97 100644
--- a/tests/lib/repair/repairinvalidsharestest.php
+++ b/tests/lib/repair/repairinvalidsharestest.php
@@ -162,7 +162,7 @@ class RepairInvalidSharesTest extends TestCase {
->orderBy('id', 'ASC')
->execute();
$rows = $result->fetchAll();
- $this->assertSame([['id' => $parent], ['id' => $validChild], ['id' => $invalidChild]], $rows);
+ $this->assertEquals([['id' => $parent], ['id' => $validChild], ['id' => $invalidChild]], $rows);
$result->closeCursor();
$this->repair->run();
@@ -173,7 +173,7 @@ class RepairInvalidSharesTest extends TestCase {
->orderBy('id', 'ASC')
->execute();
$rows = $result->fetchAll();
- $this->assertSame([['id' => $parent], ['id' => $validChild]], $rows);
+ $this->assertEquals([['id' => $parent], ['id' => $validChild]], $rows);
$result->closeCursor();
}
@@ -181,15 +181,7 @@ class RepairInvalidSharesTest extends TestCase {
* @return int
*/
protected function getLastShareId() {
- // select because lastInsertId does not work with OCI
- $query = $this->connection->getQueryBuilder();
- $result = $query->select('id')
- ->from('share')
- ->orderBy('id', 'DESC')
- ->execute();
- $row = $result->fetch();
- $result->closeCursor();
- return $row['id'];
+ return $this->connection->lastInsertId('*PREFIX*share');
}
}