Skip to content

Commit

Permalink
Support SQLServer
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Oct 4, 2021
1 parent 2055cee commit cded7d3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/Functional/DeferrableConstraintsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\UniqueConstraint;
use Doctrine\DBAL\Tests\FunctionalTestCase;
Expand Down Expand Up @@ -187,7 +188,7 @@ public function testCommitWithNonDeferredConstraintAndTransactionNesting(): void
} catch (Throwable $t) {
$this->connection->rollBack();

$this->expectException(UniqueConstraintViolationException::class);
$this->expectUniqueConstraintViolation();

throw $t;
}
Expand All @@ -209,6 +210,17 @@ private function skipIfDeferrableIsNotSupported(): void
self::markTestSkipped('Only databases supporting deferrable constraints are eligible for this test.');
}

private function expectUniqueConstraintViolation(): void
{
if ($this->connection->getDatabasePlatform() instanceof SQLServerPlatform) {
$this->expectExceptionMessage(sprintf("Violation of UNIQUE KEY constraint '%s'", $this->constraintName));

return;
}

$this->expectException(UniqueConstraintViolationException::class);
}

protected function tearDown(): void
{
$schemaManager = $this->connection->createSchemaManager();
Expand Down

0 comments on commit cded7d3

Please sign in to comment.