Skip to content
Snippets Groups Projects
Commit 87431605 authored by Joas Schilling's avatar Joas Schilling
Browse files

Add test for UniqueConstraintViolationException on wrong key

parent 89be55a6
No related branches found
No related tags found
No related merge requests found
......@@ -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";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment