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
de755610
Commit
de755610
authored
Jan 10, 2016
by
Steve Müller
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #781 from rosier/detect-database-platform
Call detectDatabasePlatform only once fixes #1068
parents
61f09cef
6fcdafe7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
5 deletions
+57
-5
Connection.php
lib/Doctrine/DBAL/Connection.php
+1
-5
ConnectionTest.php
tests/Doctrine/Tests/DBAL/ConnectionTest.php
+36
-0
ServerInfoAwareConnectionMock.php
tests/Doctrine/Tests/Mocks/ServerInfoAwareConnectionMock.php
+10
-0
VersionAwarePlatformDriverMock.php
...s/Doctrine/Tests/Mocks/VersionAwarePlatformDriverMock.php
+10
-0
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
de755610
...
...
@@ -324,7 +324,7 @@ class Connection implements DriverConnection
*/
public
function
getDatabasePlatform
()
{
if
(
null
==
$this
->
platform
)
{
if
(
null
==
=
$this
->
platform
)
{
$this
->
detectDatabasePlatform
();
}
...
...
@@ -362,10 +362,6 @@ class Connection implements DriverConnection
$this
->
_conn
=
$this
->
_driver
->
connect
(
$this
->
_params
,
$user
,
$password
,
$driverOptions
);
$this
->
_isConnected
=
true
;
if
(
null
===
$this
->
platform
)
{
$this
->
detectDatabasePlatform
();
}
if
(
false
===
$this
->
autoCommit
)
{
$this
->
beginTransaction
();
}
...
...
tests/Doctrine/Tests/DBAL/ConnectionTest.php
View file @
de755610
...
...
@@ -527,4 +527,40 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
call_user_func_array
(
array
(
$conn
,
$method
),
$params
);
}
/**
* @group DBAL-1127
*/
public
function
testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform
()
{
/** @var \Doctrine\Tests\Mocks\VersionAwarePlatformDriverMock|\PHPUnit_Framework_MockObject_MockObject $driverMock */
$driverMock
=
$this
->
getMock
(
'Doctrine\Tests\Mocks\VersionAwarePlatformDriverMock'
);
/** @var \Doctrine\Tests\Mocks\ServerInfoAwareConnectionMock|\PHPUnit_Framework_MockObject_MockObject $driverConnectionMock */
$driverConnectionMock
=
$this
->
getMock
(
'Doctrine\Tests\Mocks\ServerInfoAwareConnectionMock'
);
/** @var \Doctrine\DBAL\Platforms\AbstractPlatform|\PHPUnit_Framework_MockObject_MockObject $platformMock */
$platformMock
=
$this
->
getMockForAbstractClass
(
'Doctrine\DBAL\Platforms\AbstractPlatform'
);
$connection
=
new
Connection
(
array
(),
$driverMock
);
$driverMock
->
expects
(
$this
->
once
())
->
method
(
'connect'
)
->
will
(
$this
->
returnValue
(
$driverConnectionMock
));
$driverConnectionMock
->
expects
(
$this
->
once
())
->
method
(
'requiresQueryForServerVersion'
)
->
will
(
$this
->
returnValue
(
false
));
$driverConnectionMock
->
expects
(
$this
->
once
())
->
method
(
'getServerVersion'
)
->
will
(
$this
->
returnValue
(
'6.6.6'
));
$driverMock
->
expects
(
$this
->
once
())
->
method
(
'createDatabasePlatformForVersion'
)
->
with
(
'6.6.6'
)
->
will
(
$this
->
returnValue
(
$platformMock
));
$this
->
assertSame
(
$platformMock
,
$connection
->
getDatabasePlatform
());
}
}
tests/Doctrine/Tests/Mocks/ServerInfoAwareConnectionMock.php
0 → 100644
View file @
de755610
<?php
namespace
Doctrine\Tests\Mocks
;
use
Doctrine\DBAL\Driver\Connection
;
use
Doctrine\DBAL\Driver\ServerInfoAwareConnection
;
interface
ServerInfoAwareConnectionMock
extends
Connection
,
ServerInfoAwareConnection
{
}
tests/Doctrine/Tests/Mocks/VersionAwarePlatformDriverMock.php
0 → 100644
View file @
de755610
<?php
namespace
Doctrine\Tests\Mocks
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\VersionAwarePlatformDriver
;
interface
VersionAwarePlatformDriverMock
extends
Driver
,
VersionAwarePlatformDriver
{
}
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