Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
MySqlPlatform example
null,
[
]
, null
]
,
]
;
}
private
function
createCollector
(
array
$queries
)
: DoctrineDataCollector
{
$connection
=
$this
->
getMockBuilder
(
Connection::
class
)
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$connection
->
expects
(
$this
->
any
(
)
)
->
method
(
'getDatabasePlatform'
)
->
willReturn
(
new
MySqlPlatform
(
)
)
;
$registry
=
$this
->
createMock
(
ManagerRegistry::
class
)
;
$registry
->
expects
(
$this
->
any
(
)
)
->
method
(
'getConnectionNames'
)
->
willReturn
(
[
'default' => 'doctrine.dbal.default_connection'
]
)
;
$registry
->
expects
(
$this
->
any
(
)
)
->
method
(
'getManagerNames'
)
->
willReturn
(
[
'default' => 'doctrine.orm.default_entity_manager'
]
)
;
$registry
->
expects
(
$this
->
any
(
)
)
private
function
createCollector
(
array
$queries
)
: ConnectionProfiler
{
$debugDataHolder
=
new
BacktraceDebugDataHolder
(
[
'default'
]
)
;
$config
=
new
Configuration
(
)
;
$config
->
setMiddlewares
(
[
new
ProfilingMiddleware
(
$debugDataHolder
)
]
)
;
$connection
=
$this
->
getMockBuilder
(
Connection::
class
)
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$connection
->
expects
(
static
::
any
(
)
)
->
method
(
'getDatabasePlatform'
)
->
willReturn
(
new
MySqlPlatform
(
)
)
;
$connection
->
expects
(
static
::
any
(
)
)
->
method
(
'getConfiguration'
)
->
willReturn
(
$config
)
;
$collector
=
new
ConnectionProfiler
(
$connection
)
;
foreach
(
$queries
as
$queryData
)
{
$query
=
new
Query
(
$queryData
[
'sql'
]
?? ''
)
;
foreach
(
(
$queryData
[
'params'
]
??
[
]
)
as
$key
=>
$value
)
{
if
(
\
is_int
(
$key
)
)
{
++
$key
;
}
]
;
}
private
function
createCollector
(
array
$queries
)
: DoctrineDataCollector
{
$connection
=
$this
->
getMockBuilder
(
Connection::
class
)
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$connection
->
expects
(
$this
->
any
(
)
)
->
method
(
'getDatabasePlatform'
)
->
willReturn
(
new
MySqlPlatform
(
)
)
;
$registry
=
$this
->
createMock
(
ManagerRegistry::
class
)
;
$registry
->
expects
(
$this
->
any
(
)
)
->
method
(
'getConnectionNames'
)
->
willReturn
(
[
'default' => 'doctrine.dbal.default_connection'
]
)
;
$registry
->
expects
(
$this
->
any
(
)
)
->
method
(
'getManagerNames'
)
->
willReturn
(
[
'default' => 'doctrine.orm.default_entity_manager'
]
)
;
$registry
->
expects
(
$this
->
any
(
)
)