summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2018-08-09 13:43:00 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2018-08-09 13:43:00 +0200
commit85bc5edb5e8dbbf6bbebf4637ac9e05cc9399f78 (patch)
tree495379c875716a24afdc58b5998e6eab5a8efa3c
parent0757c5298035eebb1b304bff1f1bc2025aa2bf91 (diff)
downloadnextcloud-server-85bc5edb5e8dbbf6bbebf4637ac9e05cc9399f78.tar.gz
nextcloud-server-85bc5edb5e8dbbf6bbebf4637ac9e05cc9399f78.zip
Add integration/unit test for the double-insert of same values
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
index 6323c2f0aa4..2f74a81503d 100644
--- a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
@@ -112,4 +112,23 @@ class ProviderUserAssignmentDaoTest extends TestCase {
$this->assertCount(1, $data);
}
+ public function testPersistSameStateTwice() {
+ $qb = $this->dbConn->getQueryBuilder();
+
+ $this->dao->persist('twofactor_totp', 'user123', 0);
+ $this->dao->persist('twofactor_totp', 'user123', 0);
+
+ $q = $qb
+ ->select('*')
+ ->from(ProviderUserAssignmentDao::TABLE_NAME)
+ ->where($qb->expr()->eq('provider_id', $qb->createNamedParameter('twofactor_totp')))
+ ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter('user123')))
+ ->andWhere($qb->expr()->eq('enabled', $qb->createNamedParameter(1)));
+ $res = $q->execute();
+ $data = $res->fetchAll();
+ $res->closeCursor();
+
+ $this->assertCount(1, $data);
+ }
+
}