Refactor driver exception conversion tests

parent ec291a12
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Driver\API;
use Doctrine\DBAL\Driver\AbstractException;
use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Exception\DriverException;
use PHPUnit\Framework\TestCase;
use function array_merge;
abstract class ExceptionConverterTest extends TestCase
{
/** @var ExceptionConverter */
private $converter;
protected function setUp(): void
{
parent::setUp();
$this->converter = $this->createConverter();
}
abstract protected function createConverter(): ExceptionConverter;
/**
* @dataProvider exceptionConversionProvider
*/
public function testConvertsException(
string $expectedClass,
int $errorCode,
?string $sqlState = null,
string $message = ''
): void {
$driverException = $this->getMockForAbstractClass(
AbstractException::class,
[$message, $sqlState, $errorCode]
);
$dbalMessage = 'DBAL exception message';
$dbalException = $this->converter->convert($dbalMessage, $driverException);
self::assertInstanceOf($expectedClass, $dbalException);
self::assertSame($driverException->getCode(), $dbalException->getCode());
self::assertSame($driverException->getSQLState(), $dbalException->getSQLState());
self::assertSame($driverException, $dbalException->getPrevious());
self::assertSame($dbalMessage, $dbalException->getMessage());
}
/**
* @return iterable<mixed[]>
*/
public static function exceptionConversionProvider(): iterable
{
foreach (static::getExceptionConversionData() as $expectedClass => $items) {
foreach ($items as $item) {
yield array_merge([$expectedClass], $item);
}
}
yield [DriverException::class, 1, 'HY000', 'The message'];
}
/**
* @return array<string,mixed[][]>
*/
abstract protected static function getExceptionConversionData(): array;
}
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Driver\API\MySQL;
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
use Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter;
use Doctrine\DBAL\Exception\ConnectionException;
use Doctrine\DBAL\Exception\DeadlockException;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Doctrine\DBAL\Exception\InvalidFieldNameException;
use Doctrine\DBAL\Exception\LockWaitTimeoutException;
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
use Doctrine\DBAL\Exception\SyntaxErrorException;
use Doctrine\DBAL\Exception\TableExistsException;
use Doctrine\DBAL\Exception\TableNotFoundException;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\DBAL\Tests\Driver\API\ExceptionConverterTest as BaseExceptionConverterTest;
final class ExceptionConverterTest extends BaseExceptionConverterTest
{
protected function createConverter(): ExceptionConverterInterface
{
return new ExceptionConverter();
}
/**
* {@inheritDoc}
*/
protected static function getExceptionConversionData(): array
{
return [
ConnectionException::class => [
[1044],
[1045],
[1046],
[1049],
[1095],
[1142],
[1143],
[1227],
[1370],
[2002],
[2005],
],
ForeignKeyConstraintViolationException::class => [
[1216],
[1217],
[1451],
[1452],
],
InvalidFieldNameException::class => [
[1054],
[1166],
[1611],
],
NonUniqueFieldNameException::class => [
[1052],
[1060],
[1110],
],
NotNullConstraintViolationException::class => [
[1048],
[1121],
[1138],
[1171],
[1252],
[1263],
[1364],
[1566],
],
SyntaxErrorException::class => [
[1064],
[1149],
[1287],
[1341],
[1342],
[1343],
[1344],
[1382],
[1479],
[1541],
[1554],
[1626],
],
TableExistsException::class => [
[1050],
],
TableNotFoundException::class => [
[1051],
[1146],
],
UniqueConstraintViolationException::class => [
[1062],
[1557],
[1569],
[1586],
],
DeadlockException::class => [
[1213],
],
LockWaitTimeoutException::class => [
[1205],
],
];
}
}
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Driver\API\OCI;
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
use Doctrine\DBAL\Driver\API\OCI\ExceptionConverter;
use Doctrine\DBAL\Exception\ConnectionException;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Doctrine\DBAL\Exception\InvalidFieldNameException;
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
use Doctrine\DBAL\Exception\SyntaxErrorException;
use Doctrine\DBAL\Exception\TableExistsException;
use Doctrine\DBAL\Exception\TableNotFoundException;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\DBAL\Tests\Driver\API\ExceptionConverterTest as BaseExceptionConverterTest;
final class ExceptionConverterTest extends BaseExceptionConverterTest
{
protected function createConverter(): ExceptionConverterInterface
{
return new ExceptionConverter();
}
/**
* {@inheritDoc}
*/
protected static function getExceptionConversionData(): array
{
return [
ConnectionException::class => [
[1017],
[12545],
],
ForeignKeyConstraintViolationException::class => [
[2292],
],
InvalidFieldNameException::class => [
[904],
],
NonUniqueFieldNameException::class => [
[918],
[960],
],
NotNullConstraintViolationException::class => [
[1400],
],
SyntaxErrorException::class => [
[923],
],
TableExistsException::class => [
[955],
],
TableNotFoundException::class => [
[942],
],
UniqueConstraintViolationException::class => [
[1],
[2299],
[38911],
],
];
}
}
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Driver\API\PostgreSQL;
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
use Doctrine\DBAL\Driver\API\PostgreSQL\ExceptionConverter;
use Doctrine\DBAL\Exception\ConnectionException;
use Doctrine\DBAL\Exception\DeadlockException;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Doctrine\DBAL\Exception\InvalidFieldNameException;
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
use Doctrine\DBAL\Exception\SyntaxErrorException;
use Doctrine\DBAL\Exception\TableExistsException;
use Doctrine\DBAL\Exception\TableNotFoundException;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\DBAL\Tests\Driver\API\ExceptionConverterTest as BaseExceptionConverterTest;
final class ExceptionConverterTest extends BaseExceptionConverterTest
{
protected function createConverter(): ExceptionConverterInterface
{
return new ExceptionConverter();
}
/**
* {@inheritDoc}
*/
protected static function getExceptionConversionData(): array
{
return [
ConnectionException::class => [
[7, null, 'SQLSTATE[08006]'],
],
ForeignKeyConstraintViolationException::class => [
[0, '23503'],
],
InvalidFieldNameException::class => [
[0, '42703'],
],
NonUniqueFieldNameException::class => [
[0, '42702'],
],
NotNullConstraintViolationException::class => [
[0, '23502'],
],
SyntaxErrorException::class => [
[0, '42601'],
],
TableExistsException::class => [
[0, '42P07'],
],
TableNotFoundException::class => [
[0, '42P01'],
],
UniqueConstraintViolationException::class => [
[0, '23505'],
],
DeadlockException::class => [
[0, '40001'],
[0, '40P01'],
],
];
}
}
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Driver\API\SQLite;
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
use Doctrine\DBAL\Driver\API\SQLite\ExceptionConverter;
use Doctrine\DBAL\Exception\ConnectionException;
use Doctrine\DBAL\Exception\InvalidFieldNameException;
use Doctrine\DBAL\Exception\LockWaitTimeoutException;
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
use Doctrine\DBAL\Exception\ReadOnlyException;
use Doctrine\DBAL\Exception\SyntaxErrorException;
use Doctrine\DBAL\Exception\TableExistsException;
use Doctrine\DBAL\Exception\TableNotFoundException;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\DBAL\Tests\Driver\API\ExceptionConverterTest as BaseExceptionConverterTest;
final class ExceptionConverterTest extends BaseExceptionConverterTest
{
protected function createConverter(): ExceptionConverterInterface
{
return new ExceptionConverter();
}
/**
* {@inheritDoc}
*/
protected static function getExceptionConversionData(): array
{
return [
ConnectionException::class => [
[0, null, 'unable to open database file'],
],
InvalidFieldNameException::class => [
[0, null, 'has no column named'],
],
NonUniqueFieldNameException::class => [
[0, null, 'ambiguous column name'],
],
NotNullConstraintViolationException::class => [
[0, null, 'may not be NULL'],
],
ReadOnlyException::class => [
[0, null, 'attempt to write a readonly database'],
],
SyntaxErrorException::class => [
[0, null, 'syntax error'],
],
TableExistsException::class => [
[0, null, 'already exists'],
],
TableNotFoundException::class => [
[0, null, 'no such table:'],
],
UniqueConstraintViolationException::class => [
[0, null, 'must be unique'],
[0, null, 'is not unique'],
[0, null, 'are not unique'],
],
LockWaitTimeoutException::class => [
[0, null, 'database is locked'],
],
];
}
}
......@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractDB2Driver;
use Doctrine\DBAL\Driver\API\DefaultExceptionConverter;
use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
......@@ -26,4 +28,9 @@ class AbstractDB2DriverTest extends AbstractDriverTest
{
return new DB2SchemaManager($connection);
}
protected function createExceptionConverter(): ExceptionConverter
{
return new DefaultExceptionConverter();
}
}
......@@ -5,26 +5,7 @@ namespace Doctrine\DBAL\Tests\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractException;
use Doctrine\DBAL\Driver\AbstractSQLServerDriver;
use Doctrine\DBAL\Driver\IBMDB2;
use Doctrine\DBAL\Exception\ConnectionException;
use Doctrine\DBAL\Exception\ConstraintViolationException;
use Doctrine\DBAL\Exception\DatabaseObjectExistsException;
use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException;
use Doctrine\DBAL\Exception\DeadlockException;
use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Doctrine\DBAL\Exception\InvalidFieldNameException;
use Doctrine\DBAL\Exception\LockWaitTimeoutException;
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
use Doctrine\DBAL\Exception\ReadOnlyException;
use Doctrine\DBAL\Exception\ServerException;
use Doctrine\DBAL\Exception\SyntaxErrorException;
use Doctrine\DBAL\Exception\TableExistsException;
use Doctrine\DBAL\Exception\TableNotFoundException;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver;
......@@ -32,30 +13,11 @@ use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;
use function array_merge;
use function get_class;
use function sprintf;
abstract class AbstractDriverTest extends TestCase
{
public const EXCEPTION_CONNECTION = ConnectionException::class;
public const EXCEPTION_CONSTRAINT_VIOLATION = ConstraintViolationException::class;
public const EXCEPTION_DATABASE_OBJECT_EXISTS = DatabaseObjectExistsException::class;
public const EXCEPTION_DATABASE_OBJECT_NOT_FOUND = DatabaseObjectNotFoundException::class;
public const EXCEPTION_DRIVER = DriverException::class;
public const EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION = ForeignKeyConstraintViolationException::class;
public const EXCEPTION_INVALID_FIELD_NAME = InvalidFieldNameException::class;
public const EXCEPTION_NON_UNIQUE_FIELD_NAME = NonUniqueFieldNameException::class;
public const EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION = NotNullConstraintViolationException::class;
public const EXCEPTION_READ_ONLY = ReadOnlyException::class;
public const EXCEPTION_SERVER = ServerException::class;
public const EXCEPTION_SYNTAX_ERROR = SyntaxErrorException::class;
public const EXCEPTION_TABLE_EXISTS = TableExistsException::class;
public const EXCEPTION_TABLE_NOT_FOUND = TableNotFoundException::class;
public const EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION = UniqueConstraintViolationException::class;
public const EXCEPTION_DEADLOCK = DeadlockException::class;
public const EXCEPTION_LOCK_WAIT_TIMEOUT = LockWaitTimeoutException::class;
/**
* The driver mock under test.
*
......@@ -70,39 +32,6 @@ abstract class AbstractDriverTest extends TestCase
$this->driver = $this->createDriver();
}
/**
* @dataProvider exceptionConversionProvider
*/
public function testConvertsException(
string $expectedClass,
int $errorCode,
?string $sqlState = null,
string $message = ''
): void {
if ($this->driver instanceof IBMDB2\Driver) {
self::markTestSkipped("The IBM DB2 driver currently doesn't instantiate specialized exceptions");
}
if ($this->driver instanceof AbstractSQLServerDriver) {
self::markTestSkipped("The SQL Server drivers currently don't instantiate specialized exceptions");
}
$driverException = $this->getMockForAbstractClass(
AbstractException::class,
[$message, $sqlState, $errorCode]
);
$dbalMessage = 'DBAL exception message';
$dbalException = $this->driver->getExceptionConverter()->convert($dbalMessage, $driverException);
self::assertInstanceOf($expectedClass, $dbalException);
self::assertSame($driverException->getCode(), $dbalException->getCode());
self::assertSame($driverException->getSQLState(), $dbalException->getSQLState());
self::assertSame($driverException, $dbalException->getPrevious());
self::assertSame($dbalMessage, $dbalException->getMessage());
}
public function testCreatesDatabasePlatformForVersion(): void
{
if (! $this->driver instanceof VersionAwarePlatformDriver) {
......@@ -164,6 +93,11 @@ abstract class AbstractDriverTest extends TestCase
self::assertSame($connection, $re->getValue($schemaManager));
}
public function testReturnsExceptionConverter(): void
{
self::assertEquals($this->createExceptionConverter(), $this->driver->getExceptionConverter());
}
/**
* Factory method for creating the driver instance under test.
*/
......@@ -187,6 +121,8 @@ abstract class AbstractDriverTest extends TestCase
*/
abstract protected function createSchemaManager(Connection $connection): AbstractSchemaManager;
abstract protected function createExceptionConverter(): ExceptionConverter;
/**
* @return Connection&MockObject
*/
......@@ -202,26 +138,4 @@ abstract class AbstractDriverTest extends TestCase
{
return [];
}
/**
* @return iterable<mixed[]>
*/
public static function exceptionConversionProvider(): iterable
{
foreach (static::getExceptionConversionData() as $expectedClass => $items) {
foreach ($items as $item) {
yield array_merge([$expectedClass], $item);
}
}
yield [self::EXCEPTION_DRIVER, 1, 'HY000', 'The message'];
}
/**
* @return array<string,mixed[][]>
*/
protected static function getExceptionConversionData(): array
{
return [];
}
}
......@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Driver\API\MySQL;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySQL57Platform;
......@@ -30,6 +32,11 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
return new MySqlSchemaManager($connection);
}
protected function createExceptionConverter(): ExceptionConverter
{
return new MySQL\ExceptionConverter();
}
/**
* {@inheritDoc}
*/
......@@ -55,85 +62,4 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
['10.2.8-MariaDB-1~lenny-log', MariaDb1027Platform::class],
];
}
/**
* {@inheritDoc}
*/
protected static function getExceptionConversionData(): array
{
return [
self::EXCEPTION_CONNECTION => [
[1044],
[1045],
[1046],
[1049],
[1095],
[1142],
[1143],
[1227],
[1370],
[2002],
[2005],
],
self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => [
[1216],
[1217],
[1451],
[1452],
],
self::EXCEPTION_INVALID_FIELD_NAME => [
[1054],
[1166],
[1611],
],
self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
[1052],
[1060],
[1110],
],
self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
[1048],
[1121],
[1138],
[1171],
[1252],
[1263],
[1364],
[1566],
],
self::EXCEPTION_SYNTAX_ERROR => [
[1064],
[1149],
[1287],
[1341],
[1342],
[1343],
[1344],
[1382],
[1479],
[1541],
[1554],
[1626],
],
self::EXCEPTION_TABLE_EXISTS => [
[1050],
],
self::EXCEPTION_TABLE_NOT_FOUND => [
[1051],
[1146],
],
self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
[1062],
[1557],
[1569],
[1586],
],
self::EXCEPTION_DEADLOCK => [
[1213],
],
self::EXCEPTION_LOCK_WAIT_TIMEOUT => [
[1205],
],
];
}
}
......@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractOracleDriver;
use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Driver\API\OCI;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
......@@ -27,43 +29,8 @@ class AbstractOracleDriverTest extends AbstractDriverTest
return new OracleSchemaManager($connection);
}
/**
* {@inheritDoc}
*/
protected static function getExceptionConversionData(): array
protected function createExceptionConverter(): ExceptionConverter
{
return [
self::EXCEPTION_CONNECTION => [
[1017],
[12545],
],
self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => [
[2292],
],
self::EXCEPTION_INVALID_FIELD_NAME => [
[904],
],
self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
[918],
[960],
],
self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
[1400],
],
self::EXCEPTION_SYNTAX_ERROR => [
[923],
],
self::EXCEPTION_TABLE_EXISTS => [
[955],
],
self::EXCEPTION_TABLE_NOT_FOUND => [
[942],
],
self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
[1],
[2299],
[38911],
],
];
return new OCI\ExceptionConverter();
}
}
......@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Driver\API\PostgreSQL;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\PostgreSQL100Platform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
......@@ -28,6 +30,11 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
return new PostgreSqlSchemaManager($connection);
}
protected function createExceptionConverter(): ExceptionConverter
{
return new PostgreSQL\ExceptionConverter();
}
/**
* {@inheritDoc}
*/
......@@ -40,44 +47,4 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
['10', PostgreSQL100Platform::class],
];
}
/**
* {@inheritDoc}
*/
protected static function getExceptionConversionData(): array
{
return [
self::EXCEPTION_CONNECTION => [
[7, null, 'SQLSTATE[08006]'],
],
self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => [
[0, '23503'],
],
self::EXCEPTION_INVALID_FIELD_NAME => [
[0, '42703'],
],
self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
[0, '42702'],
],
self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
[0, '23502'],
],
self::EXCEPTION_SYNTAX_ERROR => [
[0, '42601'],
],
self::EXCEPTION_TABLE_EXISTS => [
[0, '42P07'],
],
self::EXCEPTION_TABLE_NOT_FOUND => [
[0, '42P01'],
],
self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
[0, '23505'],
],
self::EXCEPTION_DEADLOCK => [
[0, '40001'],
[0, '40P01'],
],
];
}
}
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Tests\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception\PortWithoutHost;
use Doctrine\DBAL\Driver\API\DefaultExceptionConverter;
use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
......@@ -21,6 +23,11 @@ abstract class AbstractSQLServerDriverTest extends AbstractDriverTest
return new SQLServerSchemaManager($connection);
}
protected function createExceptionConverter(): ExceptionConverter
{
return new DefaultExceptionConverter();
}
/**
* {@inheritDoc}
*/
......
......@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractSQLiteDriver;
use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Driver\API\SQLite;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
......@@ -27,44 +29,8 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest
return new SqliteSchemaManager($connection);
}
/**
* {@inheritDoc}
*/
protected static function getExceptionConversionData(): array
protected function createExceptionConverter(): ExceptionConverter
{
return [
self::EXCEPTION_CONNECTION => [
[0, null, 'unable to open database file'],
],
self::EXCEPTION_INVALID_FIELD_NAME => [
[0, null, 'has no column named'],
],
self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
[0, null, 'ambiguous column name'],
],
self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
[0, null, 'may not be NULL'],
],
self::EXCEPTION_READ_ONLY => [
[0, null, 'attempt to write a readonly database'],
],
self::EXCEPTION_SYNTAX_ERROR => [
[0, null, 'syntax error'],
],
self::EXCEPTION_TABLE_EXISTS => [
[0, null, 'already exists'],
],
self::EXCEPTION_TABLE_NOT_FOUND => [
[0, null, 'no such table:'],
],
self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
[0, null, 'must be unique'],
[0, null, 'is not unique'],
[0, null, 'are not unique'],
],
self::EXCEPTION_LOCK_WAIT_TIMEOUT => [
[0, null, 'database is locked'],
],
];
return new SQLite\ExceptionConverter();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment