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
4c25c6b9
Commit
4c25c6b9
authored
Nov 26, 2014
by
David Zuelke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some tests for database URLs
parent
71c10076
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
0 deletions
+75
-0
DriverManagerTest.php
tests/Doctrine/Tests/DBAL/DriverManagerTest.php
+75
-0
No files found.
tests/Doctrine/Tests/DBAL/DriverManagerTest.php
View file @
4c25c6b9
...
...
@@ -114,4 +114,79 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$options
);
$this
->
assertInstanceOf
(
'Doctrine\DBAL\Driver\PDOMySql\Driver'
,
$conn
->
getDriver
());
}
/**
* @dataProvider databaseUrls
*/
public
function
testDatabaseUrl
(
$url
,
$expected
)
{
$options
=
is_array
(
$url
)
?
$url
:
array
(
'url'
=>
$url
,
);
if
(
$expected
===
false
)
{
$this
->
setExpectedException
(
'\Doctrine\DBAL\DBALException'
);
}
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$options
);
if
(
$expected
===
false
)
{
return
;
}
$params
=
$conn
->
getParams
();
foreach
(
$expected
as
$key
=>
$value
)
{
if
(
$key
==
'driver'
)
{
$this
->
assertInstanceOf
(
$value
,
$conn
->
getDriver
());
}
else
{
$this
->
assertEquals
(
$value
,
$params
[
$key
]);
}
}
}
public
function
databaseUrls
()
{
return
array
(
'simple URL'
=>
array
(
'mysql://foo:bar@localhost/baz'
,
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'simple URL with port'
=>
array
(
'mysql://foo:bar@localhost:11211/baz'
,
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'port'
=>
11211
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'sqlite relative URL with host'
=>
array
(
'sqlite://localhost/foo/dbname.sqlite'
,
array
(
'dbname'
=>
'foo/dbname.sqlite'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOSqlite\Driver'
),
),
'sqlite absolute URL with host'
=>
array
(
'sqlite://localhost//tmp/dbname.sqlite'
,
array
(
'dbname'
=>
'/tmp/dbname.sqlite'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOSqlite\Driver'
),
),
'sqlite relative URL without host'
=>
array
(
'sqlite:///foo/dbname.sqlite'
,
array
(
'dbname'
=>
'foo/dbname.sqlite'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOSqlite\Driver'
),
),
'sqlite absolute URL without host'
=>
array
(
'sqlite:////tmp/dbname.sqlite'
,
array
(
'dbname'
=>
'/tmp/dbname.sqlite'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOSqlite\Driver'
),
),
'sqlite memory'
=>
array
(
'sqlite:///:memory:'
,
array
(
'dbname'
=>
':memory:'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOSqlite\Driver'
),
),
'params parsed from URL override individual params'
=>
array
(
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'password'
=>
'lulz'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'params not parsed from URL but individual params are preserved'
=>
array
(
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'port'
=>
1234
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'port'
=>
1234
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'query params from URL are used as extra params'
=>
array
(
'url'
=>
'mysql://foo:bar@localhost/dbname?charset=UTF-8'
,
array
(
'charset'
=>
'UTF-8'
),
),
);
}
}
\ No newline at end of file
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