Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
PluginFromFileSystemStruct example
'SwagPayPal-Extension',
]
,
[
self::
getPluginFromFileSystemStructWithBaseClass
(
'Test'
)
,
'Test',
]
,
]
;
}
private
static
function
getPluginFromFileSystemStructWithBaseClass
(
string
$baseClass
)
: PluginFromFileSystemStruct
{
return
(
new
PluginFromFileSystemStruct
(
)
)
->
assign
(
[
'baseClass' =>
$baseClass
,
]
)
;
}
}
class
PluginServiceTest
extends
TestCase
{
public
function
testPluginsAddsPlugin
(
)
: void
{
$pluginFinder
=
$this
->
createMock
(
PluginFinder::
class
)
;
$completePackage
=
$this
->
getComposerPackage
(
)
;
$pluginFromFileSystemStruct
=
new
PluginFromFileSystemStruct
(
)
;
$pluginFromFileSystemStruct
->
assign
(
[
'baseClass' => 'foo',
'path' => __DIR__,
'composerPackage' =>
$completePackage
,
'managedByComposer' => true,
]
)
;
$pluginFinder
->
method
(
'findPlugins'
)
->
willReturn
(
[
$pluginFromFileSystemStruct
,
]
)
;
continue
;
}
if
(
!
$this
->
isShopwarePluginType
(
$package
)
|| !
$this
->
isPluginComposerValid
(
$package
)
)
{
$this
->
addError
(
$pluginPath
,
$errors
)
;
continue
;
}
$pluginName
=
$this
->
getPluginNameFromPackage
(
$package
)
;
$plugins
[
$pluginName
]
=
(
new
PluginFromFileSystemStruct
(
)
)
->
assign
(
[
'baseClass' =>
$pluginName
,
'path' =>
$filesystemPlugin
->
getPathname
(
)
,
'managedByComposer' => false,
'composerPackage' =>
$package
,
]
)
;
}
}
catch
(
DirectoryNotFoundException
)
{
}
return
$plugins
;
}