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
a0127056
Commit
a0127056
authored
Sep 17, 2012
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #200 from robap/master
params not passed from execute to logger
parents
9d5c2a4a
a50e38c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
0 deletions
+95
-0
Statement.php
lib/Doctrine/DBAL/Statement.php
+4
-0
StatementTest.php
tests/Doctrine/Tests/DBAL/StatementTest.php
+91
-0
No files found.
lib/Doctrine/DBAL/Statement.php
View file @
a0127056
...
...
@@ -129,6 +129,10 @@ class Statement implements \IteratorAggregate, DriverStatement
*/
public
function
execute
(
$params
=
null
)
{
if
(
is_array
(
$params
))
{
$this
->
params
=
$params
;
}
$logger
=
$this
->
conn
->
getConfiguration
()
->
getSQLLogger
();
if
(
$logger
)
{
$logger
->
startQuery
(
$this
->
sql
,
$this
->
params
,
$this
->
types
);
...
...
tests/Doctrine/Tests/DBAL/StatementTest.php
0 → 100644
View file @
a0127056
<?php
namespace
Doctrine\Tests\DBAL
;
use
Doctrine\DBAL\Statement
;
class
StatementTest
extends
\Doctrine\Tests\DbalTestCase
{
/**
*
* @var \Doctrine\DBAL\Connection
*/
private
$conn
;
/**
*
* @var \Doctrine\DBAL\Configuration
*/
private
$configuration
;
public
function
setUp
()
{
$pdoStatement
=
$this
->
getMock
(
'\PDOStatment'
,
array
(
'execute'
,
'bindParam'
,
'bindValue'
));
$platform
=
new
\Doctrine\Tests\DBAL\Mocks\MockPlatform
();
$driverConnection
=
$this
->
getMock
(
'\Doctrine\DBAL\Driver\Connection'
);
$driverConnection
->
expects
(
$this
->
any
())
->
method
(
'prepare'
)
->
will
(
$this
->
returnValue
(
$pdoStatement
));
$driver
=
$this
->
getMock
(
'\Doctrine\DBAL\Driver'
);
$constructorArgs
=
array
(
array
(
'platform'
=>
$platform
),
$driver
);
$this
->
conn
=
$this
->
getMock
(
'\Doctrine\DBAL\Connection'
,
array
(),
$constructorArgs
);
$this
->
conn
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'getWrappedConnection'
)
->
will
(
$this
->
returnValue
(
$driverConnection
));
$this
->
configuration
=
$this
->
getMock
(
'\Doctrine\DBAL\Configuration'
);
$this
->
conn
->
expects
(
$this
->
any
())
->
method
(
'getConfiguration'
)
->
will
(
$this
->
returnValue
(
$this
->
configuration
));
}
public
function
testExecuteCallsLoggerStartQueryWithParametersWhenValuesBound
()
{
$name
=
'foo'
;
$var
=
'bar'
;
$type
=
\PDO
::
PARAM_STR
;
$values
=
array
(
$name
=>
$var
);
$types
=
array
(
$name
=>
$type
);
$sql
=
''
;
$logger
=
$this
->
getMock
(
'\Doctrine\DBAL\Logging\SQLLogger'
);
$logger
->
expects
(
$this
->
once
())
->
method
(
'startQuery'
)
->
with
(
$this
->
equalTo
(
$sql
),
$this
->
equalTo
(
$values
),
$this
->
equalTo
(
$types
));
$this
->
configuration
->
expects
(
$this
->
once
())
->
method
(
'getSQLLogger'
)
->
will
(
$this
->
returnValue
(
$logger
));
$statement
=
new
Statement
(
$sql
,
$this
->
conn
);
$statement
->
bindValue
(
$name
,
$var
,
$type
);
$statement
->
execute
();
}
public
function
testExecuteCallsLoggerStartQueryWithParametersWhenParamsPassedToExecute
()
{
$name
=
'foo'
;
$var
=
'bar'
;
$values
=
array
(
$name
=>
$var
);
$types
=
array
();
$sql
=
''
;
$logger
=
$this
->
getMock
(
'\Doctrine\DBAL\Logging\SQLLogger'
);
$logger
->
expects
(
$this
->
once
())
->
method
(
'startQuery'
)
->
with
(
$this
->
equalTo
(
$sql
),
$this
->
equalTo
(
$values
),
$this
->
equalTo
(
$types
));
$this
->
configuration
->
expects
(
$this
->
once
())
->
method
(
'getSQLLogger'
)
->
will
(
$this
->
returnValue
(
$logger
));
$statement
=
new
Statement
(
$sql
,
$this
->
conn
);
$statement
->
execute
(
$values
);
}
}
\ 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