Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getInfoPathContext example
public
function
testMapping
(
)
: void
{
$route
=
new
ProductPageSeoUrlRoute
(
$this
->
createMock
(
ProductDefinition::
class
)
)
;
$product
=
new
ProductEntity
(
)
;
$product
->
setId
(
'test'
)
;
$data
=
$route
->
getMapping
(
$product
,
new
SalesChannelEntity
(
)
)
;
static
::
assertNull
(
$data
->
getError
(
)
)
;
static
::
assertSame
(
$product
,
$data
->
getEntity
(
)
)
;
static
::
assertSame
(
[
'productId' => 'test'
]
,
$data
->
getInfoPathContext
(
)
)
;
$context
=
$data
->
getSeoPathInfoContext
(
)
;
static
::
assertIsArray
(
$context
)
;
static
::
assertArrayHasKey
(
'product',
$context
)
;
static
::
assertSame
(
$product
->
jsonSerialize
(
)
,
$context
[
'product'
]
)
;
}
}
public
function
testMapping
(
)
: void
{
$route
=
new
ProductPageSeoUrlRoute
(
$this
->
createMock
(
ProductDefinition::
class
)
)
;
$product
=
new
ProductEntity
(
)
;
$product
->
setId
(
'test'
)
;
$data
=
$route
->
getMapping
(
$product
,
new
SalesChannelEntity
(
)
)
;
static
::
assertNull
(
$data
->
getError
(
)
)
;
static
::
assertSame
(
$product
,
$data
->
getEntity
(
)
)
;
static
::
assertSame
(
[
'productId' => 'test'
]
,
$data
->
getInfoPathContext
(
)
)
;
$context
=
$data
->
getSeoPathInfoContext
(
)
;
static
::
assertIsArray
(
$context
)
;
static
::
assertArrayHasKey
(
'product',
$context
)
;
static
::
assertSame
(
$product
->
jsonSerialize
(
)
,
$context
[
'product'
]
)
;
}
}
$seoUrl
->
setForeignKey
(
$entity
->
getUniqueIdentifier
(
)
)
;
$seoUrl
->
setIsCanonical
(
true
)
;
$seoUrl
->
setIsModified
(
false
)
;
$seoUrl
->
setIsDeleted
(
false
)
;
$copy
=
clone
$seoUrl
;
$mapping
=
$seoUrlRoute
->
getMapping
(
$entity
,
$salesChannel
)
;
$copy
->
setError
(
$mapping
->
getError
(
)
)
;
$pathInfo
=
$this
->router->
generate
(
$config
->
getRouteName
(
)
,
$mapping
->
getInfoPathContext
(
)
)
;
$pathInfo
=
$this
->
removePrefix
(
$pathInfo
,
$basePath
)
;
$copy
->
setPathInfo
(
$pathInfo
)
;
$seoPathInfo
=
$this
->
getSeoPathInfo
(
$mapping
,
$config
)
;
if
(
$seoPathInfo
=== null ||
$seoPathInfo
=== ''
)
{
continue
;
}
$copy
->
setSeoPathInfo
(
$seoPathInfo
)
;