]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add integration/unit test for the double-insert of same values
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Thu, 9 Aug 2018 11:43:00 +0000 (13:43 +0200)
committerChristoph Wurst <christoph@winzerhof-wurst.at>
Thu, 9 Aug 2018 11:43:00 +0000 (13:43 +0200)
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php

index 6323c2f0aa4d7c49cda67cc298b717abb29d3c7d..2f74a81503d2a9bb830d5040412467b41851bd45 100644 (file)
@@ -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);
+       }
+
 }