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
b24fe977
Unverified
Commit
b24fe977
authored
Dec 30, 2017
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reworked tests to avoid hard dependency on PDO
parent
c2a4ae07
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
20 deletions
+52
-20
ConnectionTest.php
tests/Doctrine/Tests/DBAL/ConnectionTest.php
+4
-0
DriverManagerTest.php
tests/Doctrine/Tests/DBAL/DriverManagerTest.php
+31
-8
PortabilityTest.php
tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
+4
-1
SingleDatabaseSynchronizerTest.php
...AL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php
+3
-0
PoolingShardConnectionTest.php
...ctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php
+3
-0
PDOMock.php
tests/Doctrine/Tests/Mocks/PDOMock.php
+0
-10
TestUtil.php
tests/Doctrine/Tests/TestUtil.php
+7
-1
No files found.
tests/Doctrine/Tests/DBAL/ConnectionTest.php
View file @
b24fe977
...
...
@@ -20,6 +20,9 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
use
Doctrine\Tests\Mocks\DriverMock
;
use
Doctrine\Tests\Mocks\VersionAwarePlatformDriverMock
;
/**
* @requires extension pdo_mysql
*/
class
ConnectionTest
extends
\Doctrine\Tests\DbalTestCase
{
/**
...
...
@@ -157,6 +160,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
}
/**
* @requires extension pdo_sqlite
* @expectedException \Doctrine\DBAL\DBALException
* @dataProvider getQueryMethods
*/
...
...
tests/Doctrine/Tests/DBAL/DriverManagerTest.php
View file @
b24fe977
...
...
@@ -3,11 +3,11 @@
namespace
Doctrine\Tests\DBAL
;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\Tests\Mocks\PDOMock
;
class
DriverManagerTest
extends
\Doctrine\Tests\DbalTestCase
{
/**
* @requires extension pdo_sqlite
* @expectedException \Doctrine\DBAL\DBALException
*/
public
function
testInvalidPdoInstance
()
...
...
@@ -18,6 +18,9 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
$test
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$options
);
}
/**
* @requires extension pdo_sqlite
*/
public
function
testValidPdoInstance
()
{
$options
=
array
(
...
...
@@ -29,6 +32,7 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
/**
* @group DBAL-32
* @requires extension pdo_sqlite
*/
public
function
testPdoInstanceSetErrorMode
()
{
...
...
@@ -58,6 +62,9 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
array
(
'driver'
=>
'invalid_driver'
));
}
/**
* @requires extension pdo_sqlite
*/
public
function
testCustomPlatform
()
{
$mockPlatform
=
new
\Doctrine\Tests\DBAL\Mocks\MockPlatform
();
...
...
@@ -70,6 +77,9 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
self
::
assertSame
(
$mockPlatform
,
$conn
->
getDatabasePlatform
());
}
/**
* @requires extension pdo_sqlite
*/
public
function
testCustomWrapper
()
{
$wrapperClass
=
'Doctrine\Tests\Mocks\ConnectionMock'
;
...
...
@@ -83,6 +93,9 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
self
::
assertInstanceOf
(
$wrapperClass
,
$conn
);
}
/**
* @requires extension pdo_sqlite
*/
public
function
testInvalidWrapperClass
()
{
$this
->
expectException
(
DBALException
::
class
);
...
...
@@ -125,6 +138,18 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
'url'
=>
$url
,
);
if
(
isset
(
$options
[
'pdo'
]))
{
if
(
!
extension_loaded
(
'pdo'
))
{
$this
->
markTestSkipped
(
'PDO is not installed'
);
}
$options
[
'pdo'
]
=
$this
->
createMock
(
\PDO
::
class
);
}
$options
=
is_array
(
$url
)
?
$url
:
array
(
'url'
=>
$url
,
);
if
(
$expected
===
false
)
{
$this
->
expectException
(
DBALException
::
class
);
}
...
...
@@ -143,8 +168,6 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
public
function
databaseUrls
()
{
$pdoMock
=
$this
->
createMock
(
PDOMock
::
class
);
return
array
(
'simple URL'
=>
array
(
'mysql://foo:bar@localhost/baz'
,
...
...
@@ -217,7 +240,7 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
false
,
),
'URL without scheme but default PDO driver'
=>
array
(
array
(
'url'
=>
'//foo:bar@localhost/baz'
,
'pdo'
=>
$pdoMock
),
array
(
'url'
=>
'//foo:bar@localhost/baz'
,
'pdo'
=>
true
),
false
,
),
'URL without scheme but default driver'
=>
array
(
...
...
@@ -229,7 +252,7 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driverClass'
=>
'Doctrine\Tests\Mocks\DriverMock'
),
),
'URL without scheme but default PDO driver and default driver'
=>
array
(
array
(
'url'
=>
'//foo:bar@localhost/baz'
,
'pdo'
=>
$pdoMock
,
'driver'
=>
'pdo_mysql'
),
array
(
'url'
=>
'//foo:bar@localhost/baz'
,
'pdo'
=>
true
,
'driver'
=>
'pdo_mysql'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'URL without scheme but driver and custom driver'
=>
array
(
...
...
@@ -237,7 +260,7 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driverClass'
=>
'Doctrine\Tests\Mocks\DriverMock'
),
),
'URL with default PDO driver'
=>
array
(
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'pdo'
=>
$pdoMock
),
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'pdo'
=>
true
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'URL with default driver'
=>
array
(
...
...
@@ -249,7 +272,7 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'URL with default PDO driver and default driver'
=>
array
(
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'pdo'
=>
$pdoMock
,
'driver'
=>
'sqlite'
),
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'pdo'
=>
true
,
'driver'
=>
'sqlite'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'URL with default driver and default custom driver'
=>
array
(
...
...
@@ -257,7 +280,7 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'URL with default PDO driver and default driver and default custom driver'
=>
array
(
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'pdo'
=>
$pdoMock
,
'driver'
=>
'sqlite'
,
'driverClass'
=>
'Doctrine\Tests\Mocks\DriverMock'
),
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'pdo'
=>
true
,
'driver'
=>
'sqlite'
,
'driverClass'
=>
'Doctrine\Tests\Mocks\DriverMock'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
);
...
...
tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
View file @
b24fe977
...
...
@@ -131,7 +131,10 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
self
::
assertArrayNotHasKey
(
0
,
$row
,
"The row should not contain numerical keys."
);
}
public
function
testPortabilitySqlServer
()
/**
* @requires extension pdo
*/
public
function
testPortabilityPdoSqlServer
()
{
$portability
=
ConnectionPortability
::
PORTABILITY_SQLSRV
;
$params
=
array
(
...
...
tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php
View file @
b24fe977
...
...
@@ -23,6 +23,9 @@ use Doctrine\DBAL\DriverManager;
use
Doctrine\DBAL\Schema\Schema
;
use
Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer
;
/**
* @requires extension pdo_sqlite
*/
class
SingleDatabaseSynchronizerTest
extends
\PHPUnit\Framework\TestCase
{
private
$conn
;
...
...
tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php
View file @
b24fe977
...
...
@@ -22,6 +22,9 @@ namespace Doctrine\Tests\DBAL\Sharding;
use
Doctrine\DBAL\DriverManager
;
use
Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser
;
/**
* @requires extension pdo_sqlite
*/
class
PoolingShardConnectionTest
extends
\PHPUnit\Framework\TestCase
{
public
function
testConnect
()
...
...
tests/Doctrine/Tests/Mocks/PDOMock.php
deleted
100644 → 0
View file @
c2a4ae07
<?php
namespace
Doctrine\Tests\Mocks
;
class
PDOMock
extends
\PDO
{
public
function
__construct
()
{
}
}
tests/Doctrine/Tests/TestUtil.php
View file @
b24fe977
...
...
@@ -4,6 +4,7 @@ namespace Doctrine\Tests;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\DriverManager
;
use
PHPUnit\Framework\Assert
;
/**
* TestUtil is a class with static utility methods used during tests.
...
...
@@ -110,7 +111,12 @@ class TestUtil
return
$realDbParams
;
}
private
static
function
getFallbackConnectionParams
()
{
private
static
function
getFallbackConnectionParams
()
{
if
(
!
extension_loaded
(
'pdo_sqlite'
))
{
Assert
::
markTestSkipped
(
'PDO SQLite extension is not loaded'
);
}
$params
=
array
(
'driver'
=>
'pdo_sqlite'
,
'memory'
=>
true
...
...
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