[Pkg-owncloud-commits] [owncloud] 52/118: Add test for UniqueConstraintViolationException on wrong key

David Prévot taffit at moszumanska.debian.org
Fri Mar 27 22:13:11 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 03ef085a4c47183f596d97b36ceb61c8a62bc9b9
Author: Joas Schilling <nickvergessen at owncloud.com>
Date:   Tue Mar 10 09:26:45 2015 +0100

    Add test for UniqueConstraintViolationException on  wrong key
---
 tests/lib/db.php | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/tests/lib/db.php b/tests/lib/db.php
index 056ce53..1fb384c 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";

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list