Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
SnippetService example
if
(
$salesChannelId
!== null
)
{
$themeLoader
=
$this
->
createMock
(
SalesChannelThemeLoader::
class
)
;
$themeLoader
->
expects
(
static
::
once
(
)
)
->
method
(
'load'
)
->
with
(
$salesChannelId
)
->
willReturn
(
[
'themeName' =>
$usedTheme
?? 'Storefront',
]
)
;
}
if
(
$databaseSnippets
!== null &&
$databaseSnippets
!==
[
]
)
{
$this
->connection->
expects
(
static
::
once
(
)
)
->
method
(
'fetchAllKeyValue'
)
->
willReturn
(
$databaseSnippets
)
;
}
$snippetService
=
new
SnippetService
(
$this
->connection,
$this
->snippetCollection,
$this
->
createMock
(
EntityRepository::
class
)
,
$this
->
createMock
(
EntityRepository::
class
)
,
$this
->
createMock
(
EntityRepository::
class
)
,
$this
->
createMock
(
SnippetFilterFactory::
class
)
,
$container
,
$themeLoader
,
)
;
$catalog
=
new
MessageCatalogue
(
(string)
$fetchLocaleResult
,
[
'messages' =>
$catalogMessages
]
)
;
}
}
private
function
getSnippetService
(
AbstractSnippetFile ...
$snippetFiles
)
: SnippetService
{
$collection
=
new
SnippetFileCollection
(
)
;
foreach
(
$snippetFiles
as
$file
)
{
$collection
->
add
(
$file
)
;
}
return
new
SnippetService
(
$this
->
getContainer
(
)
->
get
(
Connection::
class
)
,
$collection
,
$this
->
getContainer
(
)
->
get
(
'snippet.repository'
)
,
$this
->
getContainer
(
)
->
get
(
'snippet_set.repository'
)
,
$this
->
getContainer
(
)
->
get
(
'sales_channel_domain.repository'
)
,
$this
->
getContainer
(
)
->
get
(
SnippetFilterFactory::
class
)
,
$this
->
getContainer
(
)
,
$this
->
getContainer
(
)
->
has
(
SalesChannelThemeLoader::
class
)
?
$this
->
getContainer
(
)
->
get
(
SalesChannelThemeLoader::
class
)
: null
)
;
}