Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
TestManagerRegistry example
public
static
function
setUpBeforeClass
(
)
: void
{
$test
=
new
PhpDumperTest
(
)
;
$test
->
testDumpContainerWithProxyServiceWillShareProxies
(
)
;
}
public
function
testResetService
(
)
{
$container
=
new
\
LazyServiceProjectServiceContainer
(
)
;
$registry
=
new
TestManagerRegistry
(
'name',
[
]
,
[
'defaultManager' => 'foo'
]
, 'defaultConnection', 'defaultManager', 'proxyInterfaceName'
)
;
$registry
->
setTestContainer
(
$container
)
;
$foo
=
$container
->
get
(
'foo'
)
;
$foo
->bar = 123;
$this
->
assertTrue
(
isset
(
$foo
->bar
)
)
;
$registry
->
resetManager
(
)
;
$this
->
assertSame
(
$foo
,
$container
->
get
(
'foo'
)
)
;
$this
->
assertInstanceOf
(
\stdClass::
class
,
$foo
)
;
$this
->
assertFalse
(
property_exists
(
$foo
, 'bar'
)
)
;
}
$container
->
getDefinition
(
'foo'
)
->
setLazy
(
true
)
->
addTag
(
'proxy',
[
'interface' => \stdClass::
class
]
)
;
$container
->
compile
(
)
;
$dumper
=
new
PhpDumper
(
$container
)
;
eval
(
'?>'.
$dumper
->
dump
(
[
'class' => 'LazyServiceDoctrineBridgeContainer'
]
)
)
;
}
public
function
testResetService
(
)
{
$container
=
new
\
LazyServiceDoctrineBridgeContainer
(
)
;
$registry
=
new
TestManagerRegistry
(
'name',
[
]
,
[
'defaultManager' => 'foo'
]
, 'defaultConnection', 'defaultManager', 'proxyInterfaceName'
)
;
$registry
->
setTestContainer
(
$container
)
;
$foo
=
$container
->
get
(
'foo'
)
;
$foo
->bar = 123;
$this
->
assertTrue
(
isset
(
$foo
->bar
)
)
;
$registry
->
resetManager
(
)
;
$this
->
assertSame
(
$foo
,
$container
->
get
(
'foo'
)
)
;
$this
->
assertInstanceOf
(
\stdClass::
class
,
$foo
)
;
$this
->
assertFalse
(
property_exists
(
$foo
, 'bar'
)
)
;
}