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
41e718ea
Commit
41e718ea
authored
Apr 30, 2015
by
Steve Müller
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #844 from kiwidg/pgsql
template1 as default database for PostgreSQL
parents
18507520
f229b8a7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
0 deletions
+116
-0
Driver.php
lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
+5
-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.
lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
View file @
41e718ea
...
...
@@ -88,6 +88,11 @@ class Driver extends AbstractPostgreSQLDriver
if
(
isset
(
$params
[
'dbname'
]))
{
$dsn
.=
'dbname='
.
$params
[
'dbname'
]
.
' '
;
}
else
{
// Used for temporary connections to allow operations like dropping the database currently connected to.
// Connecting without an explicit database does not work, therefore "template1" database is used
// as it is certainly present in every server setup.
$dsn
.=
'dbname=template1'
.
' '
;
}
if
(
isset
(
$params
[
'sslmode'
]))
{
...
...
tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php
0 → 100644
View file @
41e718ea
<?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 @
41e718ea
<?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