Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
RouterListener example
public
function
testPort
(
$defaultHttpPort
,
$defaultHttpsPort
,
$uri
,
$expectedHttpPort
,
$expectedHttpsPort
)
{
$urlMatcher
=
$this
->
createMock
(
UrlMatcherInterface::
class
)
;
$context
=
new
RequestContext
(
)
;
$context
->
setHttpPort
(
$defaultHttpPort
)
;
$context
->
setHttpsPort
(
$defaultHttpsPort
)
;
$urlMatcher
->
expects
(
$this
->
any
(
)
)
->
method
(
'getContext'
)
->
willReturn
(
$context
)
;
$listener
=
new
RouterListener
(
$urlMatcher
,
$this
->requestStack
)
;
$event
=
$this
->
createRequestEventForUri
(
$uri
)
;
$listener
->
onKernelRequest
(
$event
)
;
$this
->
assertEquals
(
$expectedHttpPort
,
$context
->
getHttpPort
(
)
)
;
$this
->
assertEquals
(
$expectedHttpsPort
,
$context
->
getHttpsPort
(
)
)
;
$this
->
assertEquals
(
str_starts_with
(
$uri
, 'https'
)
? 'https' : 'http',
$context
->
getScheme
(
)
)
;
}
public
static
function
getPortData
(
)
{
return
[
[