Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-03-10 11:26:45 +0300
committerJoas Schilling <nickvergessen@owncloud.com>2015-03-16 13:45:29 +0300
commit03ef085a4c47183f596d97b36ceb61c8a62bc9b9 (patch)
tree091cb4bb104cc690395b92280e3fa2f063825e82 /tests
parentd9f6971d0b42ab20a5f5284d673da962ccbb5fe2 (diff)
Add test for UniqueConstraintViolationException on wrong key
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/db.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/lib/db.php b/tests/lib/db.php
index 056ce535436..1fb384ca9c6 100644
--- a/tests/lib/db.php
+++ b/tests/lib/db.php
@@ -217,6 +217,38 @@ class Test_DB extends \Test\TestCase {
$this->assertEquals(0, $result);
}
+ public function insertIfNotExistsViolatingThrows() {
+ return [
+ [null],
+ [['etag']],
+ ];
+ }
+
+ /**
+ * @dataProvider insertIfNotExistsViolatingThrows
+ * @expectedException \Doctrine\DBAL\Exception\UniqueConstraintViolationException
+ *
+ * @param array $compareKeys
+ */
+ public function testInsertIfNotExistsViolatingThrows($compareKeys) {
+ $result = \OCP\DB::insertIfNotExist('*PREFIX*'.$this->table5,
+ array(
+ 'storage' => 1,
+ 'path_hash' => md5('welcome.txt'),
+ 'etag' => $this->getUniqueID()
+ ));
+ $this->assertEquals(1, $result);
+
+ $result = \OCP\DB::insertIfNotExist('*PREFIX*'.$this->table5,
+ array(
+ 'storage' => 1,
+ 'path_hash' => md5('welcome.txt'),
+ 'etag' => $this->getUniqueID()
+ ), $compareKeys);
+
+ $this->assertEquals(0, $result);
+ }
+
public function testUtf8Data() {
$table = "*PREFIX*{$this->table2}";
$expected = "ะ‹รถ้›™ๅ–œ\xE2\x80\xA2";