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
fb26c17c
Commit
fb26c17c
authored
Feb 12, 2014
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for driver abstraction refactoring and automatic platform version detection
parent
b7d63038
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
1326 additions
and
0 deletions
+1326
-0
AbstractDB2DriverTest.php
tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php
+25
-0
AbstractDriverTest.php
tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php
+207
-0
AbstractMySQLDriverTest.php
tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php
+136
-0
AbstractOracleDriverTest.php
...s/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php
+79
-0
AbstractPostgreSQLDriverTest.php
...ctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php
+98
-0
AbstractSQLAnywhereDriverTest.php
...trine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php
+98
-0
AbstractSQLServerDriverTest.php
...octrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php
+57
-0
AbstractSQLiteDriverTest.php
...s/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php
+77
-0
DriverTest.php
...Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php
+46
-0
DB2ConnectionTest.php
...s/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php
+29
-0
DB2DriverTest.php
tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php
+19
-0
DriverTest.php
tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php
+19
-0
MysqliConnectionTest.php
...octrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php
+29
-0
DriverTest.php
tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php
+19
-0
OCI8ConnectionTest.php
tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php
+29
-0
PDOExceptionTest.php
tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php
+62
-0
DriverTest.php
tests/Doctrine/Tests/DBAL/Driver/PDOIbm/DriverTest.php
+19
-0
DriverTest.php
tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php
+19
-0
DriverTest.php
tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php
+19
-0
DriverTest.php
tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
+19
-0
DriverTest.php
tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php
+19
-0
DriverTest.php
tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php
+19
-0
DriverTest.php
tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php
+19
-0
SQLAnywhereConnectionTest.php
...sts/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php
+29
-0
DriverTest.php
tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php
+19
-0
SQLSrvConnectionTest.php
...octrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php
+29
-0
PDOConnectionTest.php
...ctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php
+78
-0
DriverResultStatementMock.php
tests/Doctrine/Tests/Mocks/DriverResultStatementMock.php
+9
-0
No files found.
tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Platforms\DB2Platform
;
use
Doctrine\DBAL\Schema\DB2SchemaManager
;
class
AbstractDB2DriverTest
extends
AbstractDriverTest
{
protected
function
createDriver
()
{
return
$this
->
getMockForAbstractClass
(
'Doctrine\DBAL\Driver\AbstractDB2Driver'
);
}
protected
function
createPlatform
()
{
return
new
DB2Platform
();
}
protected
function
createSchemaManager
(
Connection
$connection
)
{
return
new
DB2SchemaManager
(
$connection
);
}
}
tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Driver\ExceptionConverterDriver
;
use
Doctrine\DBAL\VersionAwarePlatformDriver
;
use
Doctrine\Tests\DbalTestCase
;
abstract
class
AbstractDriverTest
extends
DbalTestCase
{
const
EXCEPTION_CONNECTION
=
'Doctrine\DBAL\Exception\ConnectionException'
;
const
EXCEPTION_CONSTRAINT_VIOLATION
=
'Doctrine\DBAL\Exception\ConstraintViolationException'
;
const
EXCEPTION_DATABASE_OBJECT_EXISTS
=
'Doctrine\DBAL\Exception\DatabaseObjectExistsException'
;
const
EXCEPTION_DATABASE_OBJECT_NOT_FOUND
=
'Doctrine\DBAL\Exception\DatabaseObjectNotFoundException'
;
const
EXCEPTION_DRIVER
=
'Doctrine\DBAL\Exception\DriverException'
;
const
EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION
=
'Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException'
;
const
EXCEPTION_INVALID_FIELD_NAME
=
'Doctrine\DBAL\Exception\InvalidFieldNameException'
;
const
EXCEPTION_NON_UNIQUE_FIELD_NAME
=
'Doctrine\DBAL\Exception\NonUniqueFieldNameException'
;
const
EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION
=
'Doctrine\DBAL\Exception\NotNullConstraintViolationException'
;
const
EXCEPTION_READ_ONLY
=
'Doctrine\DBAL\Exception\ReadOnlyException'
;
const
EXCEPTION_SERVER
=
'Doctrine\DBAL\Exception\ServerException'
;
const
EXCEPTION_SYNTAX_ERROR
=
'Doctrine\DBAL\Exception\SyntaxErrorException'
;
const
EXCEPTION_TABLE_EXISTS
=
'Doctrine\DBAL\Exception\TableExistsException'
;
const
EXCEPTION_TABLE_NOT_FOUND
=
'Doctrine\DBAL\Exception\TableNotFoundException'
;
const
EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION
=
'Doctrine\DBAL\Exception\UniqueConstraintViolationException'
;
/**
* The driver mock under test.
*
* @var \Doctrine\DBAL\Driver
*/
protected
$driver
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
driver
=
$this
->
createDriver
();
}
public
function
testConvertsException
()
{
if
(
!
$this
->
driver
instanceof
ExceptionConverterDriver
)
{
$this
->
markTestSkipped
(
'This test is only intended for exception converter drivers.'
);
}
$data
=
$this
->
getExceptionConversions
();
if
(
empty
(
$data
))
{
$this
->
fail
(
sprintf
(
'No test data found for test %s. You have to return test data from %s.'
,
get_class
(
$this
)
.
'::'
.
__FUNCTION__
,
get_class
(
$this
)
.
'::getExceptionConversionData'
)
);
}
$driverException
=
$this
->
getMock
(
'Doctrine\DBAL\Driver\DriverException'
);
$driverException
->
expects
(
$this
->
any
())
->
method
(
'getErrorCode'
)
->
will
(
$this
->
returnValue
(
'foo'
));
$driverException
->
expects
(
$this
->
any
())
->
method
(
'getSQLState'
)
->
will
(
$this
->
returnValue
(
'bar'
));
$driverException
->
expects
(
$this
->
any
())
->
method
(
'getMessage'
)
->
will
(
$this
->
returnValue
(
'baz'
));
$data
[]
=
array
(
$driverException
,
self
::
EXCEPTION_DRIVER
);
$message
=
'DBAL exception message'
;
foreach
(
$data
as
$item
)
{
/** @var $driverException \Doctrine\DBAL\Driver\DriverException */
list
(
$driverException
,
$convertedExceptionClassName
)
=
$item
;
$convertedException
=
$this
->
driver
->
convertException
(
$message
,
$driverException
);
$this
->
assertSame
(
$convertedExceptionClassName
,
get_class
(
$convertedException
));
$this
->
assertSame
(
$driverException
->
getErrorCode
(),
$convertedException
->
getErrorCode
());
$this
->
assertSame
(
$driverException
->
getSQLState
(),
$convertedException
->
getSQLState
());
$this
->
assertSame
(
$message
,
$convertedException
->
getMessage
());
}
}
public
function
testCreatesDatabasePlatformForVersion
()
{
if
(
!
$this
->
driver
instanceof
VersionAwarePlatformDriver
)
{
$this
->
markTestSkipped
(
'This test is only intended for version aware platform drivers.'
);
}
$data
=
$this
->
getDatabasePlatformsForVersions
();
if
(
empty
(
$data
))
{
$this
->
fail
(
sprintf
(
'No test data found for test %s. You have to return test data from %s.'
,
get_class
(
$this
)
.
'::'
.
__FUNCTION__
,
get_class
(
$this
)
.
'::getDatabasePlatformsForVersions'
)
);
}
foreach
(
$data
as
$item
)
{
$this
->
assertSame
(
$item
[
1
],
get_class
(
$this
->
driver
->
createDatabasePlatformForVersion
(
$item
[
0
])));
}
}
/**
* @expectedException \Doctrine\DBAL\DBALException
*/
public
function
testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion
()
{
if
(
!
$this
->
driver
instanceof
VersionAwarePlatformDriver
)
{
$this
->
markTestSkipped
(
'This test is only intended for version aware platform drivers.'
);
}
$this
->
driver
->
createDatabasePlatformForVersion
(
'foo'
);
}
public
function
testReturnsDatabaseName
()
{
$params
=
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'dbname'
=>
'baz'
,
);
$connection
=
$this
->
getConnectionMock
();
$connection
->
expects
(
$this
->
once
())
->
method
(
'getParams'
)
->
will
(
$this
->
returnValue
(
$params
));
$this
->
assertSame
(
$params
[
'dbname'
],
$this
->
driver
->
getDatabase
(
$connection
));
}
public
function
testReturnsDatabasePlatform
()
{
$this
->
assertEquals
(
$this
->
createPlatform
(),
$this
->
driver
->
getDatabasePlatform
());
}
public
function
testReturnsSchemaManager
()
{
$connection
=
$this
->
getConnectionMock
();
$schemaManager
=
$this
->
driver
->
getSchemaManager
(
$connection
);
$this
->
assertEquals
(
$this
->
createSchemaManager
(
$connection
),
$schemaManager
);
$this
->
assertAttributeSame
(
$connection
,
'_conn'
,
$schemaManager
);
}
abstract
protected
function
createDriver
();
abstract
protected
function
createPlatform
();
abstract
protected
function
createSchemaManager
(
Connection
$connection
);
protected
function
getConnectionMock
()
{
return
$this
->
getMockBuilder
(
'Doctrine\DBAL\Connection'
)
->
disableOriginalConstructor
()
->
getMock
();
}
protected
function
getDatabasePlatformsForVersions
()
{
return
array
();
}
protected
function
getExceptionConversionData
()
{
return
array
();
}
private
function
getExceptionConversions
()
{
$data
=
array
();
foreach
(
$this
->
getExceptionConversionData
()
as
$convertedExceptionClassName
=>
$errors
)
{
foreach
(
$errors
as
$error
)
{
$driverException
=
$this
->
getMock
(
'Doctrine\DBAL\Driver\DriverException'
);
$driverException
->
expects
(
$this
->
any
())
->
method
(
'getErrorCode'
)
->
will
(
$this
->
returnValue
(
$error
[
0
]));
$driverException
->
expects
(
$this
->
any
())
->
method
(
'getSQLState'
)
->
will
(
$this
->
returnValue
(
$error
[
1
]));
$driverException
->
expects
(
$this
->
any
())
->
method
(
'getMessage'
)
->
will
(
$this
->
returnValue
(
$error
[
2
]));
$data
[]
=
array
(
$driverException
,
$convertedExceptionClassName
);
}
}
return
$data
;
}
}
tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Platforms\MySqlPlatform
;
use
Doctrine\DBAL\Schema\MySqlSchemaManager
;
class
AbstractMySQLDriverTest
extends
AbstractDriverTest
{
public
function
testReturnsDatabaseName
()
{
parent
::
testReturnsDatabaseName
();
$database
=
'bloo'
;
$params
=
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
);
$statement
=
$this
->
getMock
(
'Doctrine\Tests\Mocks\DriverResultStatementMock'
);
$statement
->
expects
(
$this
->
once
())
->
method
(
'fetchColumn'
)
->
will
(
$this
->
returnValue
(
$database
));
$connection
=
$this
->
getConnectionMock
();
$connection
->
expects
(
$this
->
once
())
->
method
(
'getParams'
)
->
will
(
$this
->
returnValue
(
$params
));
$connection
->
expects
(
$this
->
once
())
->
method
(
'query'
)
->
will
(
$this
->
returnValue
(
$statement
));
$this
->
assertSame
(
$database
,
$this
->
driver
->
getDatabase
(
$connection
));
}
protected
function
createDriver
()
{
return
$this
->
getMockForAbstractClass
(
'Doctrine\DBAL\Driver\AbstractMySQLDriver'
);
}
protected
function
createPlatform
()
{
return
new
MySqlPlatform
();
}
protected
function
createSchemaManager
(
Connection
$connection
)
{
return
new
MySqlSchemaManager
(
$connection
);
}
protected
function
getDatabasePlatformsForVersions
()
{
return
array
(
array
(
'5.6.9'
,
'Doctrine\DBAL\Platforms\MySqlPlatform'
),
array
(
'5.7'
,
'Doctrine\DBAL\Platforms\MySQL57Platform'
),
array
(
'5.7.0'
,
'Doctrine\DBAL\Platforms\MySQL57Platform'
),
array
(
'5.7.1'
,
'Doctrine\DBAL\Platforms\MySQL57Platform'
),
array
(
'6'
,
'Doctrine\DBAL\Platforms\MySQL57Platform'
),
);
}
protected
function
getExceptionConversionData
()
{
return
array
(
self
::
EXCEPTION_CONNECTION
=>
array
(
array
(
'1044'
,
null
,
null
),
array
(
'1045'
,
null
,
null
),
array
(
'1046'
,
null
,
null
),
array
(
'1049'
,
null
,
null
),
array
(
'1095'
,
null
,
null
),
array
(
'1142'
,
null
,
null
),
array
(
'1143'
,
null
,
null
),
array
(
'1227'
,
null
,
null
),
array
(
'1370'
,
null
,
null
),
array
(
'2002'
,
null
,
null
),
array
(
'2005'
,
null
,
null
),
),
self
::
EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION
=>
array
(
array
(
'1216'
,
null
,
null
),
array
(
'1217'
,
null
,
null
),
array
(
'1451'
,
null
,
null
),
array
(
'1452'
,
null
,
null
),
),
self
::
EXCEPTION_INVALID_FIELD_NAME
=>
array
(
array
(
'1054'
,
null
,
null
),
array
(
'1166'
,
null
,
null
),
array
(
'1611'
,
null
,
null
),
),
self
::
EXCEPTION_NON_UNIQUE_FIELD_NAME
=>
array
(
array
(
'1052'
,
null
,
null
),
array
(
'1060'
,
null
,
null
),
array
(
'1110'
,
null
,
null
),
),
self
::
EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION
=>
array
(
array
(
'1048'
,
null
,
null
),
array
(
'1121'
,
null
,
null
),
array
(
'1138'
,
null
,
null
),
array
(
'1171'
,
null
,
null
),
array
(
'1252'
,
null
,
null
),
array
(
'1263'
,
null
,
null
),
array
(
'1566'
,
null
,
null
),
),
self
::
EXCEPTION_SYNTAX_ERROR
=>
array
(
array
(
'1064'
,
null
,
null
),
array
(
'1149'
,
null
,
null
),
array
(
'1287'
,
null
,
null
),
array
(
'1341'
,
null
,
null
),
array
(
'1342'
,
null
,
null
),
array
(
'1343'
,
null
,
null
),
array
(
'1344'
,
null
,
null
),
array
(
'1382'
,
null
,
null
),
array
(
'1479'
,
null
,
null
),
array
(
'1541'
,
null
,
null
),
array
(
'1554'
,
null
,
null
),
array
(
'1626'
,
null
,
null
),
),
self
::
EXCEPTION_TABLE_EXISTS
=>
array
(
array
(
'1050'
,
null
,
null
),
),
self
::
EXCEPTION_TABLE_NOT_FOUND
=>
array
(
array
(
'1051'
,
null
,
null
),
array
(
'1146'
,
null
,
null
),
),
self
::
EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION
=>
array
(
array
(
'1062'
,
null
,
null
),
array
(
'1557'
,
null
,
null
),
array
(
'1569'
,
null
,
null
),
array
(
'1586'
,
null
,
null
),
),
);
}
}
tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Platforms\OraclePlatform
;
use
Doctrine\DBAL\Schema\OracleSchemaManager
;
class
AbstractOracleDriverTest
extends
AbstractDriverTest
{
public
function
testReturnsDatabaseName
()
{
$params
=
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'dbname'
=>
'baz'
,
);
$connection
=
$this
->
getConnectionMock
();
$connection
->
expects
(
$this
->
once
())
->
method
(
'getParams'
)
->
will
(
$this
->
returnValue
(
$params
));
$this
->
assertSame
(
$params
[
'user'
],
$this
->
driver
->
getDatabase
(
$connection
));
}
protected
function
createDriver
()
{
return
$this
->
getMockForAbstractClass
(
'Doctrine\DBAL\Driver\AbstractOracleDriver'
);
}
protected
function
createPlatform
()
{
return
new
OraclePlatform
();
}
protected
function
createSchemaManager
(
Connection
$connection
)
{
return
new
OracleSchemaManager
(
$connection
);
}
protected
function
getExceptionConversionData
()
{
return
array
(
self
::
EXCEPTION_CONNECTION
=>
array
(
array
(
'1017'
,
null
,
null
),
array
(
'12545'
,
null
,
null
),
),
self
::
EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION
=>
array
(
array
(
'2292'
,
null
,
null
),
),
self
::
EXCEPTION_INVALID_FIELD_NAME
=>
array
(
array
(
'904'
,
null
,
null
),
),
self
::
EXCEPTION_NON_UNIQUE_FIELD_NAME
=>
array
(
array
(
'918'
,
null
,
null
),
array
(
'960'
,
null
,
null
),
),
self
::
EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION
=>
array
(
array
(
'1400'
,
null
,
null
),
),
self
::
EXCEPTION_SYNTAX_ERROR
=>
array
(
array
(
'923'
,
null
,
null
),
),
self
::
EXCEPTION_TABLE_EXISTS
=>
array
(
array
(
'955'
,
null
,
null
),
),
self
::
EXCEPTION_TABLE_NOT_FOUND
=>
array
(
array
(
'942'
,
null
,
null
),
),
self
::
EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION
=>
array
(
array
(
'1'
,
null
,
null
),
array
(
'2299'
,
null
,
null
),
array
(
'38911'
,
null
,
null
),
),
);
}
}
tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Platforms\PostgreSqlPlatform
;
use
Doctrine\DBAL\Schema\PostgreSqlSchemaManager
;
class
AbstractPostgreSQLDriverTest
extends
AbstractDriverTest
{
public
function
testReturnsDatabaseName
()
{
parent
::
testReturnsDatabaseName
();
$database
=
'bloo'
;
$params
=
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
);
$statement
=
$this
->
getMock
(
'Doctrine\Tests\Mocks\DriverResultStatementMock'
);
$statement
->
expects
(
$this
->
once
())
->
method
(
'fetchColumn'
)
->
will
(
$this
->
returnValue
(
$database
));
$connection
=
$this
->
getConnectionMock
();
$connection
->
expects
(
$this
->
once
())
->
method
(
'getParams'
)
->
will
(
$this
->
returnValue
(
$params
));
$connection
->
expects
(
$this
->
once
())
->
method
(
'query'
)
->
will
(
$this
->
returnValue
(
$statement
));
$this
->
assertSame
(
$database
,
$this
->
driver
->
getDatabase
(
$connection
));
}
protected
function
createDriver
()
{
return
$this
->
getMockForAbstractClass
(
'Doctrine\DBAL\Driver\AbstractPostgreSQLDriver'
);
}
protected
function
createPlatform
()
{
return
new
PostgreSqlPlatform
();
}
protected
function
createSchemaManager
(
Connection
$connection
)
{
return
new
PostgreSqlSchemaManager
(
$connection
);
}
protected
function
getDatabasePlatformsForVersions
()
{
return
array
(
array
(
'9.1.9'
,
'Doctrine\DBAL\Platforms\PostgreSqlPlatform'
),
array
(
'9.2'
,
'Doctrine\DBAL\Platforms\PostgreSQL92Platform'
),
array
(
'9.2.0'
,
'Doctrine\DBAL\Platforms\PostgreSQL92Platform'
),
array
(
'9.2.1'
,
'Doctrine\DBAL\Platforms\PostgreSQL92Platform'
),
array
(
'10'
,
'Doctrine\DBAL\Platforms\PostgreSQL92Platform'
),
);
}
protected
function
getExceptionConversionData
()
{
return
array
(
self
::
EXCEPTION_CONNECTION
=>
array
(
array
(
null
,
'7'
,
'SQLSTATE[08006]'
),
),
self
::
EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION
=>
array
(
array
(
null
,
'23503'
,
null
),
),
self
::
EXCEPTION_INVALID_FIELD_NAME
=>
array
(
array
(
null
,
'42703'
,
null
),
),
self
::
EXCEPTION_NON_UNIQUE_FIELD_NAME
=>
array
(
array
(
null
,
'42702'
,
null
),
),
self
::
EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION
=>
array
(
array
(
null
,
'23502'
,
null
),
),
self
::
EXCEPTION_SYNTAX_ERROR
=>
array
(
array
(
null
,
'42601'
,
null
),
),
self
::
EXCEPTION_TABLE_EXISTS
=>
array
(
array
(
null
,
'42P07'
,
null
),
),
self
::
EXCEPTION_TABLE_NOT_FOUND
=>
array
(
array
(
null
,
'42P01'
,
null
),
),
self
::
EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION
=>
array
(
array
(
null
,
'23505'
,
null
),
),
);
}
}
tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Platforms\SQLAnywhere12Platform
;
use
Doctrine\DBAL\Schema\SQLAnywhereSchemaManager
;
class
AbstractSQLAnywhereDriverTest
extends
AbstractDriverTest
{
protected
function
createDriver
()
{
return
$this
->
getMockForAbstractClass
(
'Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver'
);
}
protected
function
createPlatform
()
{
return
new
SQLAnywhere12Platform
();
}
protected
function
createSchemaManager
(
Connection
$connection
)
{
return
new
SQLAnywhereSchemaManager
(
$connection
);
}
protected
function
getDatabasePlatformsForVersions
()
{
return
array
(
array
(
'10'
,
'Doctrine\DBAL\Platforms\SQLAnywherePlatform'
),
array
(
'10.0'
,
'Doctrine\DBAL\Platforms\SQLAnywherePlatform'
),
array
(
'10.0.0'
,
'Doctrine\DBAL\Platforms\SQLAnywherePlatform'
),
array
(
'10.0.0.0'
,
'Doctrine\DBAL\Platforms\SQLAnywherePlatform'
),
array
(
'10.1.2.3'
,
'Doctrine\DBAL\Platforms\SQLAnywherePlatform'
),
array
(
'10.9.9.9'
,
'Doctrine\DBAL\Platforms\SQLAnywherePlatform'
),
array
(
'11'
,
'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'
),
array
(
'11.0'
,
'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'
),
array
(
'11.0.0'
,
'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'
),
array
(
'11.0.0.0'
,
'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'
),
array
(
'11.1.2.3'
,
'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'
),
array
(
'11.9.9.9'
,
'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'
),
array
(
'12'
,
'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'
),
array
(
'12.0'
,
'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'
),
array
(
'12.0.0'
,
'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'
),
array
(
'12.0.0.0'
,
'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'
),
array
(
'12.1.2.3'
,
'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'
),
array
(
'12.9.9.9'
,
'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'
),
array
(
'13'
,
'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'
),
array
(
'14'
,
'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'
),
array
(
'15'
,
'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'
),
array
(
'15.9.9.9'
,
'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'
),
array
(
'16'
,
'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'
),
array
(
'16.0'
,
'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'
),
array
(
'16.0.0'
,
'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'
),
array
(
'16.0.0.0'
,
'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'
),
array
(
'16.1.2.3'
,
'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'
),
array
(
'16.9.9.9'
,
'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'
),
array
(
'17'
,
'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'
),
);
}
protected
function
getExceptionConversionData
()
{
return
array
(
self
::
EXCEPTION_CONNECTION
=>
array
(
array
(
'-100'
,
null
,
null
),
array
(
'-103'
,
null
,
null
),
array
(
'-832'
,
null
,
null
),
),
self
::
EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION
=>
array
(
array
(
'-198'
,
null
,
null
),
),
self
::
EXCEPTION_INVALID_FIELD_NAME
=>
array
(
array
(
'-143'
,
null
,
null
),
),
self
::
EXCEPTION_NON_UNIQUE_FIELD_NAME
=>
array
(
array
(
'-144'
,
null
,
null
),
),
self
::
EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION
=>
array
(
array
(
'-184'
,
null
,
null
),
array
(
'-195'
,
null
,
null
),
),
self
::
EXCEPTION_SYNTAX_ERROR
=>
array
(
array
(
'-131'
,
null
,
null
),
),
self
::
EXCEPTION_TABLE_EXISTS
=>
array
(
array
(
'-110'
,
null
,
null
),
),
self
::
EXCEPTION_TABLE_NOT_FOUND
=>
array
(
array
(
'-141'
,
null
,
null
),
array
(
'-1041'
,
null
,
null
),
),
self
::
EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION
=>
array
(
array
(
'-193'
,
null
,
null
),
array
(
'-196'
,
null
,
null
),
),
);
}
}
tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Platforms\SQLServer2008Platform
;
use
Doctrine\DBAL\Schema\SQLServerSchemaManager
;
class
AbstractSQLServerDriverTest
extends
AbstractDriverTest
{
protected
function
createDriver
()
{
return
$this
->
getMockForAbstractClass
(
'Doctrine\DBAL\Driver\AbstractSQLServerDriver'
);
}
protected
function
createPlatform
()
{
return
new
SQLServer2008Platform
();
}
protected
function
createSchemaManager
(
Connection
$connection
)
{
return
new
SQLServerSchemaManager
(
$connection
);
}
protected
function
getDatabasePlatformsForVersions
()
{
return
array
(
array
(
'9'
,
'Doctrine\DBAL\Platforms\SQLServerPlatform'
),
array
(
'9.00'
,
'Doctrine\DBAL\Platforms\SQLServerPlatform'
),
array
(
'9.00.0'
,
'Doctrine\DBAL\Platforms\SQLServerPlatform'
),
array
(
'9.00.1398'
,
'Doctrine\DBAL\Platforms\SQLServerPlatform'
),
array
(
'9.00.1398.99'
,
'Doctrine\DBAL\Platforms\SQLServerPlatform'
),
array
(
'9.00.1399'
,
'Doctrine\DBAL\Platforms\SQLServer2005Platform'
),
array
(
'9.00.1399.0'
,
'Doctrine\DBAL\Platforms\SQLServer2005Platform'
),
array
(
'9.00.1399.99'
,
'Doctrine\DBAL\Platforms\SQLServer2005Platform'
),
array
(
'9.00.1400'
,
'Doctrine\DBAL\Platforms\SQLServer2005Platform'
),
array
(
'9.10'
,
'Doctrine\DBAL\Platforms\SQLServer2005Platform'
),
array
(
'9.10.9999'
,
'Doctrine\DBAL\Platforms\SQLServer2005Platform'
),
array
(
'10.00.1599'
,
'Doctrine\DBAL\Platforms\SQLServer2005Platform'
),
array
(
'10.00.1599.99'
,
'Doctrine\DBAL\Platforms\SQLServer2005Platform'
),
array
(
'10.00.1600'
,
'Doctrine\DBAL\Platforms\SQLServer2008Platform'
),
array
(
'10.00.1600.0'
,
'Doctrine\DBAL\Platforms\SQLServer2008Platform'
),
array
(
'10.00.1600.99'
,
'Doctrine\DBAL\Platforms\SQLServer2008Platform'
),
array
(
'10.00.1601'
,
'Doctrine\DBAL\Platforms\SQLServer2008Platform'
),
array
(
'10.10'
,
'Doctrine\DBAL\Platforms\SQLServer2008Platform'
),
array
(
'10.10.9999'
,
'Doctrine\DBAL\Platforms\SQLServer2008Platform'
),
array
(
'11.00.2099'
,
'Doctrine\DBAL\Platforms\SQLServer2008Platform'
),
array
(
'11.00.2099.99'
,
'Doctrine\DBAL\Platforms\SQLServer2008Platform'
),
array
(
'11.00.2100'
,
'Doctrine\DBAL\Platforms\SQLServer2012Platform'
),
array
(
'11.00.2100.0'
,
'Doctrine\DBAL\Platforms\SQLServer2012Platform'
),
array
(
'11.00.2100.99'
,
'Doctrine\DBAL\Platforms\SQLServer2012Platform'
),
array
(
'11.00.2101'
,
'Doctrine\DBAL\Platforms\SQLServer2012Platform'
),
array
(
'12'
,
'Doctrine\DBAL\Platforms\SQLServer2012Platform'
),
);
}
}
tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Platforms\SqlitePlatform
;
use
Doctrine\DBAL\Schema\SqliteSchemaManager
;
class
AbstractSQLiteDriverTest
extends
AbstractDriverTest
{
public
function
testReturnsDatabaseName
()
{
$params
=
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'dbname'
=>
'baz'
,
'path'
=>
'bloo'
,
);
$connection
=
$this
->
getConnectionMock
();
$connection
->
expects
(
$this
->
once
())
->
method
(
'getParams'
)
->
will
(
$this
->
returnValue
(
$params
));
$this
->
assertSame
(
$params
[
'path'
],
$this
->
driver
->
getDatabase
(
$connection
));
}
protected
function
createDriver
()
{
return
$this
->
getMockForAbstractClass
(
'Doctrine\DBAL\Driver\AbstractSQLiteDriver'
);
}
protected
function
createPlatform
()
{
return
new
SqlitePlatform
();
}
protected
function
createSchemaManager
(
Connection
$connection
)
{
return
new
SqliteSchemaManager
(
$connection
);
}
protected
function
getExceptionConversionData
()
{
return
array
(
self
::
EXCEPTION_CONNECTION
=>
array
(
array
(
null
,
null
,
'unable to open database file'
),
),
self
::
EXCEPTION_INVALID_FIELD_NAME
=>
array
(
array
(
null
,
null
,
'has no column named'
),
),
self
::
EXCEPTION_NON_UNIQUE_FIELD_NAME
=>
array
(
array
(
null
,
null
,
'ambiguous column name'
),
),
self
::
EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION
=>
array
(
array
(
null
,
null
,
'may not be NULL'
),
),
self
::
EXCEPTION_READ_ONLY
=>
array
(
array
(
null
,
null
,
'attempt to write a readonly database'
),
),
self
::
EXCEPTION_SYNTAX_ERROR
=>
array
(
array
(
null
,
null
,
'syntax error'
),
),
self
::
EXCEPTION_TABLE_EXISTS
=>
array
(
array
(
null
,
null
,
'already exists'
),
),
self
::
EXCEPTION_TABLE_NOT_FOUND
=>
array
(
array
(
null
,
null
,
'no such table:'
),
),
self
::
EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION
=>
array
(
array
(
null
,
null
,
'must be unique'
),
array
(
null
,
null
,
'is not unique'
),
),
);
}
}
tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\DrizzlePDOMySql
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver
;
use
Doctrine\DBAL\Platforms\DrizzlePlatform
;
use
Doctrine\DBAL\Schema\DrizzleSchemaManager
;
use
Doctrine\Tests\DBAL\Driver\PDOMySql\DriverTest
as
PDOMySQLDriverTest
;
class
DriverTest
extends
PDOMySQLDriverTest
{
public
function
testReturnsName
()
{
$this
->
assertSame
(
'drizzle_pdo_mysql'
,
$this
->
driver
->
getName
());
}
public
function
testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion
()
{
$this
->
markTestSkipped
(
'This test does not work on Drizzle as it is not version aware.'
);
}
protected
function
createDriver
()
{
return
new
Driver
();
}
protected
function
createPlatform
()
{
return
new
DrizzlePlatform
();
}
protected
function
createSchemaManager
(
Connection
$connection
)
{
return
new
DrizzleSchemaManager
(
$connection
);
}
protected
function
getDatabasePlatformsForVersions
()
{
return
array
(
array
(
'foo'
,
'Doctrine\DBAL\Platforms\DrizzlePlatform'
),
array
(
'bar'
,
'Doctrine\DBAL\Platforms\DrizzlePlatform'
),
array
(
'baz'
,
'Doctrine\DBAL\Platforms\DrizzlePlatform'
),
);
}
}
tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\IBMDB2
;
use
Doctrine\Tests\DbalTestCase
;
class
DB2ConnectionTest
extends
DbalTestCase
{
/**
* The ibm_db2 driver connection mock under test.
*
* @var \Doctrine\DBAL\Driver\IBMDB2\DB2Connection|\PHPUnit_Framework_MockObject_MockObject
*/
private
$connectionMock
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
connectionMock
=
$this
->
getMockBuilder
(
'Doctrine\DBAL\Driver\IBMDB2\DB2Connection'
)
->
disableOriginalConstructor
()
->
getMockForAbstractClass
();
}
public
function
testDoesNotRequireQueryForServerVersion
()
{
$this
->
assertFalse
(
$this
->
connectionMock
->
requiresQueryForServerVersion
());
}
}
tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\IBMDB2
;
use
Doctrine\DBAL\Driver\IBMDB2\DB2Driver
;
use
Doctrine\Tests\DBAL\Driver\AbstractDB2DriverTest
;
class
DriverTest
extends
AbstractDB2DriverTest
{
public
function
testReturnsName
()
{
$this
->
assertSame
(
'ibm_db2'
,
$this
->
driver
->
getName
());
}
protected
function
createDriver
()
{
return
new
DB2Driver
();
}
}
tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\Mysqli
;
use
Doctrine\DBAL\Driver\Mysqli\Driver
;
use
Doctrine\Tests\DBAL\Driver\AbstractMySQLDriverTest
;
class
DriverTest
extends
AbstractMySQLDriverTest
{
public
function
testReturnsName
()
{
$this
->
assertSame
(
'mysqli'
,
$this
->
driver
->
getName
());
}
protected
function
createDriver
()
{
return
new
Driver
();
}
}
tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\Mysqli
;
use
Doctrine\Tests\DbalTestCase
;
class
MysqliConnectionTest
extends
DbalTestCase
{
/**
* The mysqli driver connection mock under test.
*
* @var \Doctrine\DBAL\Driver\Mysqli\MysqliConnection|\PHPUnit_Framework_MockObject_MockObject
*/
private
$connectionMock
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
connectionMock
=
$this
->
getMockBuilder
(
'Doctrine\DBAL\Driver\Mysqli\MysqliConnection'
)
->
disableOriginalConstructor
()
->
getMockForAbstractClass
();
}
public
function
testDoesNotRequireQueryForServerVersion
()
{
$this
->
assertFalse
(
$this
->
connectionMock
->
requiresQueryForServerVersion
());
}
}
tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\OCI8
;
use
Doctrine\DBAL\Driver\OCI8\Driver
;
use
Doctrine\Tests\DBAL\Driver\AbstractOracleDriverTest
;
class
DriverTest
extends
AbstractOracleDriverTest
{
public
function
testReturnsName
()
{
$this
->
assertSame
(
'oci8'
,
$this
->
driver
->
getName
());
}
protected
function
createDriver
()
{
return
new
Driver
();
}
}
tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\OCI8
;
use
Doctrine\Tests\DbalTestCase
;
class
OCI8ConnectionTest
extends
DbalTestCase
{
/**
* The oci8 driver connection mock under test.
*
* @var \Doctrine\DBAL\Driver\OCI8\OCI8Connection|\PHPUnit_Framework_MockObject_MockObject
*/
private
$connectionMock
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
connectionMock
=
$this
->
getMockBuilder
(
'Doctrine\DBAL\Driver\OCI8\OCI8Connection'
)
->
disableOriginalConstructor
()
->
getMockForAbstractClass
();
}
public
function
testDoesNotRequireQueryForServerVersion
()
{
$this
->
assertFalse
(
$this
->
connectionMock
->
requiresQueryForServerVersion
());
}
}
tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver
;
use
Doctrine\DBAL\Driver\PDOException
;
use
Doctrine\Tests\DbalTestCase
;
class
PDOExceptionTest
extends
DbalTestCase
{
const
ERROR_CODE
=
666
;
const
MESSAGE
=
'PDO Exception'
;
const
SQLSTATE
=
28000
;
/**
* The PDO exception wrapper under test.
*
* @var \Doctrine\DBAL\Driver\PDOException
*/
private
$exception
;
/**
* The wrapped PDO exception mock.
*
* @var \PDOException|\PHPUnit_Framework_MockObject_MockObject
*/
private
$wrappedExceptionMock
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
wrappedExceptionMock
=
$this
->
getMockBuilder
(
'\PDOException'
)
->
setConstructorArgs
(
array
(
self
::
MESSAGE
,
self
::
SQLSTATE
))
->
getMock
();
$this
->
wrappedExceptionMock
->
errorInfo
=
array
(
self
::
SQLSTATE
,
self
::
ERROR_CODE
);
$this
->
exception
=
new
PDOException
(
$this
->
wrappedExceptionMock
);
}
public
function
testReturnsCode
()
{
$this
->
assertSame
(
self
::
SQLSTATE
,
$this
->
exception
->
getCode
());
}
public
function
testReturnsErrorCode
()
{
$this
->
assertSame
(
self
::
ERROR_CODE
,
$this
->
exception
->
getErrorCode
());
}
public
function
testReturnsMessage
()
{
$this
->
assertSame
(
self
::
MESSAGE
,
$this
->
exception
->
getMessage
());
}
public
function
testReturnsSQLState
()
{
$this
->
assertSame
(
self
::
SQLSTATE
,
$this
->
exception
->
getSQLState
());
}
}
tests/Doctrine/Tests/DBAL/Driver/PDOIbm/DriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\PDOIbm
;
use
Doctrine\DBAL\Driver\PDOIbm\Driver
;
use
Doctrine\Tests\DBAL\Driver\AbstractDB2DriverTest
;
class
DriverTest
extends
AbstractDB2DriverTest
{
public
function
testReturnsName
()
{
$this
->
assertSame
(
'pdo_ibm'
,
$this
->
driver
->
getName
());
}
protected
function
createDriver
()
{
return
new
Driver
();
}
}
tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\PDOMySql
;
use
Doctrine\DBAL\Driver\PDOMySql\Driver
;
use
Doctrine\Tests\DBAL\Driver\AbstractMySQLDriverTest
;
class
DriverTest
extends
AbstractMySQLDriverTest
{
public
function
testReturnsName
()
{
$this
->
assertSame
(
'pdo_mysql'
,
$this
->
driver
->
getName
());
}
protected
function
createDriver
()
{
return
new
Driver
();
}
}
tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\PDOOracle
;
use
Doctrine\DBAL\Driver\PDOOracle\Driver
;
use
Doctrine\Tests\DBAL\Driver\AbstractOracleDriverTest
;
class
DriverTest
extends
AbstractOracleDriverTest
{
public
function
testReturnsName
()
{
$this
->
assertSame
(
'pdo_oracle'
,
$this
->
driver
->
getName
());
}
protected
function
createDriver
()
{
return
new
Driver
();
}
}
tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\PDOPgSql
;
use
Doctrine\DBAL\Driver\PDOPgSql\Driver
;
use
Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest
;
class
DriverTest
extends
AbstractPostgreSQLDriverTest
{
public
function
testReturnsName
()
{
$this
->
assertSame
(
'pdo_pgsql'
,
$this
->
driver
->
getName
());
}
protected
function
createDriver
()
{
return
new
Driver
();
}
}
tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\PDOSqlite
;
use
Doctrine\DBAL\Driver\PDOSqlite\Driver
;
use
Doctrine\Tests\DBAL\Driver\AbstractSQLiteDriverTest
;
class
DriverTest
extends
AbstractSQLiteDriverTest
{
public
function
testReturnsName
()
{
$this
->
assertSame
(
'pdo_sqlite'
,
$this
->
driver
->
getName
());
}
protected
function
createDriver
()
{
return
new
Driver
();
}
}
tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\PDOSqlsrv
;
use
Doctrine\DBAL\Driver\PDOSqlsrv\Driver
;
use
Doctrine\Tests\DBAL\Driver\AbstractSQLServerDriverTest
;
class
DriverTest
extends
AbstractSQLServerDriverTest
{
public
function
testReturnsName
()
{
$this
->
assertSame
(
'pdo_sqlsrv'
,
$this
->
driver
->
getName
());
}
protected
function
createDriver
()
{
return
new
Driver
();
}
}
tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\SQLAnywhere
;
use
Doctrine\DBAL\Driver\SQLAnywhere\Driver
;
use
Doctrine\Tests\DBAL\Driver\AbstractSQLAnywhereDriverTest
;
class
DriverTest
extends
AbstractSQLAnywhereDriverTest
{
public
function
testReturnsName
()
{
$this
->
assertSame
(
'sqlanywhere'
,
$this
->
driver
->
getName
());
}
protected
function
createDriver
()
{
return
new
Driver
();
}
}
tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\SQLAnywhere
;
use
Doctrine\Tests\DbalTestCase
;
class
SQLAnywhereConnectionTest
extends
DbalTestCase
{
/**
* The sqlanywhere driver connection mock under test.
*
* @var \Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereConnection|\PHPUnit_Framework_MockObject_MockObject
*/
private
$connectionMock
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
connectionMock
=
$this
->
getMockBuilder
(
'Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereConnection'
)
->
disableOriginalConstructor
()
->
getMockForAbstractClass
();
}
public
function
testRequiresQueryForServerVersion
()
{
$this
->
assertTrue
(
$this
->
connectionMock
->
requiresQueryForServerVersion
());
}
}
tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\SQLSrv
;
use
Doctrine\DBAL\Driver\SQLSrv\Driver
;
use
Doctrine\Tests\DBAL\Driver\AbstractSQLServerDriverTest
;
class
DriverTest
extends
AbstractSQLServerDriverTest
{
public
function
testReturnsName
()
{
$this
->
assertSame
(
'sqlsrv'
,
$this
->
driver
->
getName
());
}
protected
function
createDriver
()
{
return
new
Driver
();
}
}
tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Driver\SQLSrv
;
use
Doctrine\Tests\DbalTestCase
;
class
SQLSrvConnectionTest
extends
DbalTestCase
{
/**
* The sqlsrv driver connection mock under test.
*
* @var \Doctrine\DBAL\Driver\SQLSrv\SQLSrvConnection|\PHPUnit_Framework_MockObject_MockObject
*/
private
$connectionMock
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
connectionMock
=
$this
->
getMockBuilder
(
'Doctrine\DBAL\Driver\SQLSrv\SQLSrvConnection'
)
->
disableOriginalConstructor
()
->
getMockForAbstractClass
();
}
public
function
testDoesNotRequireQueryForServerVersion
()
{
$this
->
assertFalse
(
$this
->
connectionMock
->
requiresQueryForServerVersion
());
}
}
tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\DBAL\Functional\Driver
;
use
Doctrine\DBAL\Driver\PDOConnection
;
use
Doctrine\DBAL\Driver\PDOException
;
use
Doctrine\Tests\DbalFunctionalTestCase
;
class
PDOConnectionTest
extends
DbalFunctionalTestCase
{
/**
* The PDO driver connection under test.
*
* @var \Doctrine\DBAL\Driver\PDOConnection
*/
protected
$driverConnection
;
protected
function
setUp
()
{
if
(
!
extension_loaded
(
'PDO'
))
{
$this
->
markTestSkipped
(
'PDO is not installed.'
);
}
parent
::
setUp
();
$this
->
driverConnection
=
$this
->
_conn
->
getWrappedConnection
();
if
(
!
$this
->
_conn
->
getWrappedConnection
()
instanceof
PDOConnection
)
{
$this
->
markTestSkipped
(
'PDO connection only test.'
);
}
}
public
function
testDoesNotRequireQueryForServerVersion
()
{
$this
->
assertFalse
(
$this
->
driverConnection
->
requiresQueryForServerVersion
());
}
/**
* @expectedException \Doctrine\DBAL\Driver\PDOException
*/
public
function
testWrapsPDOExceptionsDuringPrepare
()
{
$this
->
driverConnection
->
prepare
(
'foo'
);
}
public
function
testWrapsPDOExceptionsDuringQuery
()
{
$failMessage
=
'Failed asserting that exception of type "\Doctrine\DBAL\Driver\PDOException" is thrown.'
;
try
{
$this
->
driverConnection
->
query
(
'foo'
);
$this
->
fail
(
$failMessage
);
}
catch
(
PDOException
$e
)
{
}
try
{
$this
->
driverConnection
->
query
(
'foo'
,
'bar'
);
$this
->
fail
(
$failMessage
);
}
catch
(
PDOException
$e
)
{
}
try
{
$this
->
driverConnection
->
query
(
'foo'
,
'bar'
,
'baz'
);
$this
->
fail
(
$failMessage
);
}
catch
(
PDOException
$e
)
{
}
try
{
$this
->
driverConnection
->
query
(
'foo'
,
'bar'
,
'baz'
,
'bloo'
);
$this
->
fail
(
$failMessage
);
}
catch
(
PDOException
$e
)
{
}
}
}
tests/Doctrine/Tests/Mocks/DriverResultStatementMock.php
0 → 100644
View file @
fb26c17c
<?php
namespace
Doctrine\Tests\Mocks
;
use
Doctrine\DBAL\Driver\ResultStatement
;
interface
DriverResultStatementMock
extends
ResultStatement
,
\IteratorAggregate
{
}
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