Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
19cc7568
Unverified
Commit
19cc7568
authored
Jul 01, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor driver exception conversion tests
parent
ec291a12
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
425 additions
and
290 deletions
+425
-290
ExceptionConverterTest.php
tests/Driver/API/ExceptionConverterTest.php
+71
-0
ExceptionConverterTest.php
tests/Driver/API/MySQL/ExceptionConverterTest.php
+109
-0
ExceptionConverterTest.php
tests/Driver/API/OCI/ExceptionConverterTest.php
+66
-0
ExceptionConverterTest.php
tests/Driver/API/PostgreSQL/ExceptionConverterTest.php
+67
-0
ExceptionConverterTest.php
tests/Driver/API/SQLite/ExceptionConverterTest.php
+68
-0
AbstractDB2DriverTest.php
tests/Driver/AbstractDB2DriverTest.php
+7
-0
AbstractDriverTest.php
tests/Driver/AbstractDriverTest.php
+8
-94
AbstractMySQLDriverTest.php
tests/Driver/AbstractMySQLDriverTest.php
+7
-81
AbstractOracleDriverTest.php
tests/Driver/AbstractOracleDriverTest.php
+4
-37
AbstractPostgreSQLDriverTest.php
tests/Driver/AbstractPostgreSQLDriverTest.php
+7
-40
AbstractSQLServerDriverTest.php
tests/Driver/AbstractSQLServerDriverTest.php
+7
-0
AbstractSQLiteDriverTest.php
tests/Driver/AbstractSQLiteDriverTest.php
+4
-38
No files found.
tests/Driver/API/ExceptionConverterTest.php
0 → 100644
View file @
19cc7568
<?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
;
}
tests/Driver/API/MySQL/ExceptionConverterTest.php
0 → 100644
View file @
19cc7568
<?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
],
],
];
}
}
tests/Driver/API/OCI/ExceptionConverterTest.php
0 → 100644
View file @
19cc7568
<?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
],
],
];
}
}
tests/Driver/API/PostgreSQL/ExceptionConverterTest.php
0 → 100644
View file @
19cc7568
<?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'
],
],
];
}
}
tests/Driver/API/SQLite/ExceptionConverterTest.php
0 → 100644
View file @
19cc7568
<?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'
],
],
];
}
}
tests/Driver/AbstractDB2DriverTest.php
View file @
19cc7568
...
@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
...
@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver\AbstractDB2Driver
;
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\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\DB2Platform
;
use
Doctrine\DBAL\Platforms\DB2Platform
;
use
Doctrine\DBAL\Schema\AbstractSchemaManager
;
use
Doctrine\DBAL\Schema\AbstractSchemaManager
;
...
@@ -26,4 +28,9 @@ class AbstractDB2DriverTest extends AbstractDriverTest
...
@@ -26,4 +28,9 @@ class AbstractDB2DriverTest extends AbstractDriverTest
{
{
return
new
DB2SchemaManager
(
$connection
);
return
new
DB2SchemaManager
(
$connection
);
}
}
protected
function
createExceptionConverter
()
:
ExceptionConverter
{
return
new
DefaultExceptionConverter
();
}
}
}
tests/Driver/AbstractDriverTest.php
View file @
19cc7568
...
@@ -5,26 +5,7 @@ namespace Doctrine\DBAL\Tests\Driver;
...
@@ -5,26 +5,7 @@ namespace Doctrine\DBAL\Tests\Driver;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver\AbstractException
;
use
Doctrine\DBAL\Driver\API\ExceptionConverter
;
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\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Schema\AbstractSchemaManager
;
use
Doctrine\DBAL\Schema\AbstractSchemaManager
;
use
Doctrine\DBAL\VersionAwarePlatformDriver
;
use
Doctrine\DBAL\VersionAwarePlatformDriver
;
...
@@ -32,30 +13,11 @@ use PHPUnit\Framework\MockObject\MockObject;
...
@@ -32,30 +13,11 @@ use PHPUnit\Framework\MockObject\MockObject;
use
PHPUnit\Framework\TestCase
;
use
PHPUnit\Framework\TestCase
;
use
ReflectionProperty
;
use
ReflectionProperty
;
use
function
array_merge
;
use
function
get_class
;
use
function
get_class
;
use
function
sprintf
;
use
function
sprintf
;
abstract
class
AbstractDriverTest
extends
TestCase
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.
* The driver mock under test.
*
*
...
@@ -70,39 +32,6 @@ abstract class AbstractDriverTest extends TestCase
...
@@ -70,39 +32,6 @@ abstract class AbstractDriverTest extends TestCase
$this
->
driver
=
$this
->
createDriver
();
$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
public
function
testCreatesDatabasePlatformForVersion
()
:
void
{
{
if
(
!
$this
->
driver
instanceof
VersionAwarePlatformDriver
)
{
if
(
!
$this
->
driver
instanceof
VersionAwarePlatformDriver
)
{
...
@@ -164,6 +93,11 @@ abstract class AbstractDriverTest extends TestCase
...
@@ -164,6 +93,11 @@ abstract class AbstractDriverTest extends TestCase
self
::
assertSame
(
$connection
,
$re
->
getValue
(
$schemaManager
));
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.
* Factory method for creating the driver instance under test.
*/
*/
...
@@ -187,6 +121,8 @@ abstract class AbstractDriverTest extends TestCase
...
@@ -187,6 +121,8 @@ abstract class AbstractDriverTest extends TestCase
*/
*/
abstract
protected
function
createSchemaManager
(
Connection
$connection
)
:
AbstractSchemaManager
;
abstract
protected
function
createSchemaManager
(
Connection
$connection
)
:
AbstractSchemaManager
;
abstract
protected
function
createExceptionConverter
()
:
ExceptionConverter
;
/**
/**
* @return Connection&MockObject
* @return Connection&MockObject
*/
*/
...
@@ -202,26 +138,4 @@ abstract class AbstractDriverTest extends TestCase
...
@@ -202,26 +138,4 @@ abstract class AbstractDriverTest extends TestCase
{
{
return
[];
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
[];
}
}
}
tests/Driver/AbstractMySQLDriverTest.php
View file @
19cc7568
...
@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
...
@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver\AbstractMySQLDriver
;
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\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\MariaDb1027Platform
;
use
Doctrine\DBAL\Platforms\MariaDb1027Platform
;
use
Doctrine\DBAL\Platforms\MySQL57Platform
;
use
Doctrine\DBAL\Platforms\MySQL57Platform
;
...
@@ -30,6 +32,11 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
...
@@ -30,6 +32,11 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
return
new
MySqlSchemaManager
(
$connection
);
return
new
MySqlSchemaManager
(
$connection
);
}
}
protected
function
createExceptionConverter
()
:
ExceptionConverter
{
return
new
MySQL\ExceptionConverter
();
}
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
...
@@ -55,85 +62,4 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
...
@@ -55,85 +62,4 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
[
'10.2.8-MariaDB-1~lenny-log'
,
MariaDb1027Platform
::
class
],
[
'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
],
],
];
}
}
}
tests/Driver/AbstractOracleDriverTest.php
View file @
19cc7568
...
@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
...
@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver\AbstractOracleDriver
;
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\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\OraclePlatform
;
use
Doctrine\DBAL\Platforms\OraclePlatform
;
use
Doctrine\DBAL\Schema\AbstractSchemaManager
;
use
Doctrine\DBAL\Schema\AbstractSchemaManager
;
...
@@ -27,43 +29,8 @@ class AbstractOracleDriverTest extends AbstractDriverTest
...
@@ -27,43 +29,8 @@ class AbstractOracleDriverTest extends AbstractDriverTest
return
new
OracleSchemaManager
(
$connection
);
return
new
OracleSchemaManager
(
$connection
);
}
}
/**
protected
function
createExceptionConverter
()
:
ExceptionConverter
* {@inheritDoc}
*/
protected
static
function
getExceptionConversionData
()
:
array
{
{
return
[
return
new
OCI\ExceptionConverter
();
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
],
],
];
}
}
}
}
tests/Driver/AbstractPostgreSQLDriverTest.php
View file @
19cc7568
...
@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
...
@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver\AbstractPostgreSQLDriver
;
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\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\PostgreSQL100Platform
;
use
Doctrine\DBAL\Platforms\PostgreSQL100Platform
;
use
Doctrine\DBAL\Platforms\PostgreSQL94Platform
;
use
Doctrine\DBAL\Platforms\PostgreSQL94Platform
;
...
@@ -28,6 +30,11 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
...
@@ -28,6 +30,11 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
return
new
PostgreSqlSchemaManager
(
$connection
);
return
new
PostgreSqlSchemaManager
(
$connection
);
}
}
protected
function
createExceptionConverter
()
:
ExceptionConverter
{
return
new
PostgreSQL\ExceptionConverter
();
}
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
...
@@ -40,44 +47,4 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
...
@@ -40,44 +47,4 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
[
'10'
,
PostgreSQL100Platform
::
class
],
[
'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'
],
],
];
}
}
}
tests/Driver/AbstractSQLServerDriverTest.php
View file @
19cc7568
...
@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Tests\Driver;
...
@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Tests\Driver;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception\PortWithoutHost
;
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\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\SQLServer2012Platform
;
use
Doctrine\DBAL\Platforms\SQLServer2012Platform
;
use
Doctrine\DBAL\Schema\AbstractSchemaManager
;
use
Doctrine\DBAL\Schema\AbstractSchemaManager
;
...
@@ -21,6 +23,11 @@ abstract class AbstractSQLServerDriverTest extends AbstractDriverTest
...
@@ -21,6 +23,11 @@ abstract class AbstractSQLServerDriverTest extends AbstractDriverTest
return
new
SQLServerSchemaManager
(
$connection
);
return
new
SQLServerSchemaManager
(
$connection
);
}
}
protected
function
createExceptionConverter
()
:
ExceptionConverter
{
return
new
DefaultExceptionConverter
();
}
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
...
...
tests/Driver/AbstractSQLiteDriverTest.php
View file @
19cc7568
...
@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
...
@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Tests\Driver;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver\AbstractSQLiteDriver
;
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\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\SqlitePlatform
;
use
Doctrine\DBAL\Platforms\SqlitePlatform
;
use
Doctrine\DBAL\Schema\AbstractSchemaManager
;
use
Doctrine\DBAL\Schema\AbstractSchemaManager
;
...
@@ -27,44 +29,8 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest
...
@@ -27,44 +29,8 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest
return
new
SqliteSchemaManager
(
$connection
);
return
new
SqliteSchemaManager
(
$connection
);
}
}
/**
protected
function
createExceptionConverter
()
:
ExceptionConverter
* {@inheritDoc}
*/
protected
static
function
getExceptionConversionData
()
:
array
{
{
return
[
return
new
SQLite\ExceptionConverter
();
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'
],
],
];
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment