Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
DriverWrapper example
public
function
testConfigureSchemaDecoratedDbalDriver
(
)
{
$connection
= DriverManager::
getConnection
(
[
'driver' => 'pdo_sqlite', 'path' => self::
$dbFile
]
,
$this
->
getDbalConfig
(
)
)
;
if
(
!
interface_exists
(
Middleware::
class
)
)
{
$this
->
markTestSkipped
(
'doctrine/dbal v2 does not support custom drivers using middleware'
)
;
}
$middleware
=
$this
->
createMock
(
Middleware::
class
)
;
$middleware
->
method
(
'wrap'
)
->
willReturn
(
new
DriverWrapper
(
$connection
->
getDriver
(
)
)
)
;
$config
=
$this
->
getDbalConfig
(
)
;
$config
->
setMiddlewares
(
[
$middleware
]
)
;
$connection
= DriverManager::
getConnection
(
[
'driver' => 'pdo_sqlite', 'path' => self::
$dbFile
]
,
$config
)
;
$adapter
=
new
DoctrineDbalAdapter
(
$connection
)
;
$adapter
->
createTable
(
)
;
$item
=
$adapter
->
getItem
(
'key'
)
;
$item
->
set
(
'value'
)
;