Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
makePluginLifecycleService example
public
function
testActivate
(
)
: void
{
$inactive
=
$this
->
getInstalledInactivePlugin
(
)
;
$this
->
insertPlugin
(
$inactive
)
;
$loader
=
new
DbalKernelPluginLoader
(
$this
->classLoader, null,
$this
->connection
)
;
$this
->kernel =
$this
->
makeKernel
(
$loader
)
;
$this
->kernel->
boot
(
)
;
$lifecycleService
=
$this
->
makePluginLifecycleService
(
)
;
$lifecycleService
->
activatePlugin
(
$inactive
, Context::
createDefaultContext
(
)
)
;
/** @var SwagTest $swagTestPlugin */
$swagTestPlugin
=
$this
->kernel->
getPluginLoader
(
)
->
getPluginInstances
(
)
->
get
(
$inactive
->
getBaseClass
(
)
)
;
static
::
assertNotNull
(
$swagTestPlugin
)
;
// autowired
static
::
assertInstanceOf
(
SystemConfigService::
class
,
$swagTestPlugin
->systemConfig
)
;
// manually set
static
::
assertSame
(
$this
->kernel->
getContainer
(
)
->
get
(
'category.repository'
)
,
$swagTestPlugin
->categoryRepository
)
;