Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
ValidationMiddleware example
$message
=
new
DummyMessage
(
'Hey'
)
;
$envelope
=
new
Envelope
(
$message
)
;
$validator
=
$this
->
createMock
(
ValidatorInterface::
class
)
;
$validator
->
expects
(
$this
->
once
(
)
)
->
method
(
'validate'
)
->
with
(
$message
)
->
willReturn
(
$this
->
createMock
(
ConstraintViolationListInterface::
class
)
)
;
(
new
ValidationMiddleware
(
$validator
)
)
->
handle
(
$envelope
,
$this
->
getStackMock
(
)
)
;
}
public
function
testValidateWithStampAndNextMiddleware
(
)
{
$message
=
new
DummyMessage
(
'Hey'
)
;
$envelope
=
(
new
Envelope
(
$message
)
)
->
with
(
new
ValidationStamp
(
$groups
=
[
'Default', 'Extra'
]
)
)
;
$validator
=
$this
->
createMock
(
ValidatorInterface::
class
)
;
$validator
->
expects
(
$this
->
once
(
)
)
->
method
(
'validate'
)
->
with
(
$message
, null,
$groups
)