Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
RouterDebugCommand example
$tester
=
$this
->
createCommandTester
(
)
;
$ret
=
$tester
->
execute
(
[
'path_info' => '/test', 'foo'
]
,
[
'decorated' => false
]
)
;
$this
->
assertEquals
(
1,
$ret
, 'Returns 1 in case of failure'
)
;
$this
->
assertStringContainsString
(
'None of the routes match the path "/test"',
$tester
->
getDisplay
(
)
)
;
}
private
function
createCommandTester
(
)
: CommandTester
{
$application
=
new
Application
(
$this
->
getKernel
(
)
)
;
$application
->
add
(
new
RouterMatchCommand
(
$this
->
getRouter
(
)
)
)
;
$application
->
add
(
new
RouterDebugCommand
(
$this
->
getRouter
(
)
)
)
;
return
new
CommandTester
(
$application
->
find
(
'router:match'
)
)
;
}
private
function
getRouter
(
)
{
$routeCollection
=
new
RouteCollection
(
)
;
$routeCollection
->
add
(
'foo',
new
Route
(
'foo'
)
)
;
$requestContext
=
new
RequestContext
(
)
;
$router
=
$this
->
createMock
(
RouterInterface::
class
)
;
$router