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
eff314db
Commit
eff314db
authored
Apr 30, 2015
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add functional driver test case for connecting without dbname parameter
parent
0f36c991
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
0 deletions
+111
-0
AbstractDriverTest.php
...trine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php
+73
-0
DriverTest.php
...rine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php
+38
-0
No files found.
tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php
0 → 100644
View file @
eff314db
<?php
namespace
Doctrine\Tests\DBAL\Functional\Driver
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\Tests\DbalFunctionalTestCase
;
abstract
class
AbstractDriverTest
extends
DbalFunctionalTestCase
{
/**
* The driver instance under test.
*
* @var \Doctrine\DBAL\Driver
*/
private
$driver
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
driver
=
$this
->
createDriver
();
}
/**
* @group DBAL-1215
*/
public
function
testConnectsWithoutDatabaseNameParameter
()
{
$params
=
$this
->
_conn
->
getParams
();
unset
(
$params
[
'dbname'
]);
$user
=
isset
(
$params
[
'user'
])
?
$params
[
'user'
]
:
null
;
$password
=
isset
(
$params
[
'password'
])
?
$params
[
'password'
]
:
null
;
$connection
=
$this
->
driver
->
connect
(
$params
,
$user
,
$password
);
$this
->
assertInstanceOf
(
'Doctrine\DBAL\Driver\Connection'
,
$connection
);
}
/**
* @group DBAL-1215
*/
public
function
testReturnsDatabaseNameWithoutDatabaseNameParameter
()
{
$params
=
$this
->
_conn
->
getParams
();
unset
(
$params
[
'dbname'
]);
$connection
=
new
Connection
(
$params
,
$this
->
_conn
->
getDriver
(),
$this
->
_conn
->
getConfiguration
(),
$this
->
_conn
->
getEventManager
()
);
$this
->
assertSame
(
$this
->
getDatabaseNameForConnectionWithoutDatabaseNameParameter
(),
$this
->
driver
->
getDatabase
(
$connection
)
);
}
/**
* @return \Doctrine\DBAL\Driver
*/
abstract
protected
function
createDriver
();
/**
* @return string|null
*/
protected
function
getDatabaseNameForConnectionWithoutDatabaseNameParameter
()
{
return
null
;
}
}
tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php
0 → 100644
View file @
eff314db
<?php
namespace
Doctrine\Tests\DBAL\Functional\Driver\PDOPgSql
;
use
Doctrine\DBAL\Driver\PDOPgSql\Driver
;
use
Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest
;
class
DriverTest
extends
AbstractDriverTest
{
protected
function
setUp
()
{
if
(
!
extension_loaded
(
'pdo_pgsql'
))
{
$this
->
markTestSkipped
(
'pdo_pgsql is not installed.'
);
}
parent
::
setUp
();
if
(
!
$this
->
_conn
->
getDriver
()
instanceof
Driver
)
{
$this
->
markTestSkipped
(
'pdo_pgsql only test.'
);
}
}
/**
* {@inheritdoc}
*/
protected
function
createDriver
()
{
return
new
Driver
();
}
/**
* {@inheritdoc}
*/
protected
function
getDatabaseNameForConnectionWithoutDatabaseNameParameter
()
{
return
'template1'
;
}
}
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