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
cab04d0e
Commit
cab04d0e
authored
Mar 27, 2017
by
Jonathan Vollebregt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract repeated code to getExecuteUpdateMockConnection method
parent
07a48467
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
50 deletions
+21
-50
ConnectionTest.php
tests/Doctrine/Tests/DBAL/ConnectionTest.php
+21
-50
No files found.
tests/Doctrine/Tests/DBAL/ConnectionTest.php
View file @
cab04d0e
...
...
@@ -34,6 +34,22 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
$this
->
_conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$this
->
params
);
}
public
function
getExecuteUpdateMockConnection
()
{
$driverMock
=
$this
->
createMock
(
\Doctrine\DBAL\Driver
::
class
);
$driverMock
->
expects
(
$this
->
any
())
->
method
(
'connect'
)
->
will
(
$this
->
returnValue
(
new
DriverConnectionMock
()));
$conn
=
$this
->
getMockBuilder
(
Connection
::
class
)
->
setMethods
([
'executeUpdate'
])
->
setConstructorArgs
([[
'platform'
=>
new
Mocks\MockPlatform
()],
$driverMock
])
->
getMock
();
return
$conn
;
}
public
function
testIsConnected
()
{
$this
->
assertFalse
(
$this
->
_conn
->
isConnected
());
...
...
@@ -285,16 +301,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
public
function
testEmptyInsert
()
{
$driverMock
=
$this
->
createMock
(
'Doctrine\DBAL\Driver'
);
$driverMock
->
expects
(
$this
->
any
())
->
method
(
'connect'
)
->
will
(
$this
->
returnValue
(
new
DriverConnectionMock
()));
$conn
=
$this
->
getMockBuilder
(
'Doctrine\DBAL\Connection'
)
->
setMethods
(
array
(
'executeUpdate'
))
->
setConstructorArgs
(
array
(
array
(
'platform'
=>
new
Mocks\MockPlatform
()),
$driverMock
))
->
getMock
();
$conn
=
$this
->
getExecuteUpdateMockConnection
();
$conn
->
expects
(
$this
->
once
())
->
method
(
'executeUpdate'
)
...
...
@@ -308,16 +315,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
*/
public
function
testUpdateWithDifferentColumnsInDataAndIdentifiers
()
{
$driverMock
=
$this
->
createMock
(
'Doctrine\DBAL\Driver'
);
$driverMock
->
expects
(
$this
->
any
())
->
method
(
'connect'
)
->
will
(
$this
->
returnValue
(
new
DriverConnectionMock
()));
$conn
=
$this
->
getMockBuilder
(
'Doctrine\DBAL\Connection'
)
->
setMethods
(
array
(
'executeUpdate'
))
->
setConstructorArgs
(
array
(
array
(
'platform'
=>
new
Mocks\MockPlatform
()),
$driverMock
))
->
getMock
();
$conn
=
$this
->
getExecuteUpdateMockConnection
();
$conn
->
expects
(
$this
->
once
())
->
method
(
'executeUpdate'
)
...
...
@@ -361,16 +359,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
*/
public
function
testUpdateWithSameColumnInDataAndIdentifiers
()
{
$driverMock
=
$this
->
createMock
(
'Doctrine\DBAL\Driver'
);
$driverMock
->
expects
(
$this
->
any
())
->
method
(
'connect'
)
->
will
(
$this
->
returnValue
(
new
DriverConnectionMock
()));
$conn
=
$this
->
getMockBuilder
(
'Doctrine\DBAL\Connection'
)
->
setMethods
(
array
(
'executeUpdate'
))
->
setConstructorArgs
(
array
(
array
(
'platform'
=>
new
Mocks\MockPlatform
()),
$driverMock
))
->
getMock
();
$conn
=
$this
->
getExecuteUpdateMockConnection
();
$conn
->
expects
(
$this
->
once
())
->
method
(
'executeUpdate'
)
...
...
@@ -413,16 +402,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
*/
public
function
testUpdateWithIsNull
()
{
$driverMock
=
$this
->
createMock
(
'Doctrine\DBAL\Driver'
);
$driverMock
->
expects
(
$this
->
any
())
->
method
(
'connect'
)
->
will
(
$this
->
returnValue
(
new
DriverConnectionMock
()));
$conn
=
$this
->
getMockBuilder
(
'Doctrine\DBAL\Connection'
)
->
setMethods
(
array
(
'executeUpdate'
))
->
setConstructorArgs
(
array
(
array
(
'platform'
=>
new
Mocks\MockPlatform
()),
$driverMock
))
->
getMock
();
$conn
=
$this
->
getExecuteUpdateMockConnection
();
$conn
->
expects
(
$this
->
once
())
->
method
(
'executeUpdate'
)
...
...
@@ -464,16 +444,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
*/
public
function
testDeleteWithIsNull
()
{
$driverMock
=
$this
->
createMock
(
'Doctrine\DBAL\Driver'
);
$driverMock
->
expects
(
$this
->
any
())
->
method
(
'connect'
)
->
will
(
$this
->
returnValue
(
new
DriverConnectionMock
()));
$conn
=
$this
->
getMockBuilder
(
'Doctrine\DBAL\Connection'
)
->
setMethods
(
array
(
'executeUpdate'
))
->
setConstructorArgs
(
array
(
array
(
'platform'
=>
new
Mocks\MockPlatform
()),
$driverMock
))
->
getMock
();
$conn
=
$this
->
getExecuteUpdateMockConnection
();
$conn
->
expects
(
$this
->
once
())
->
method
(
'executeUpdate'
)
...
...
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