From 04a316aa671a2581fae7780c85af8a3d934ebdec Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Tue, 6 Nov 2018 21:29:20 +0100 Subject: Add test that unique constraint is working Signed-off-by: Daniel Kesselberg --- tests/lib/DB/ConnectionTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') diff --git a/tests/lib/DB/ConnectionTest.php b/tests/lib/DB/ConnectionTest.php index 62b168fbb53..857bb3cd79f 100644 --- a/tests/lib/DB/ConnectionTest.php +++ b/tests/lib/DB/ConnectionTest.php @@ -336,4 +336,17 @@ class ConnectionTest extends \Test\TestCase { $this->assertEquals(0, $result); } + /** + * @expectedException \Doctrine\DBAL\Exception\UniqueConstraintViolationException + */ + public function testUniqueConstraintViolating() { + $this->makeTestTable(); + + $testQuery = 'INSERT INTO `*PREFIX*table` (`integerfield`, `textfield`) VALUES(?, ?)'; + $testParams = [1, 'hello']; + + $this->connection->executeUpdate($testQuery, $testParams); + $this->connection->executeUpdate($testQuery, $testParams); + } + } -- cgit v1.2.3