Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
HappyPathValidator example
$inner
=
$this
->
createMock
(
ValidatorInterface::
class
)
;
if
(
$isValid
)
{
$inner
->
expects
(
static
::
never
(
)
)
->
method
(
'validate'
)
;
}
else
{
$inner
->
expects
(
static
::
atLeastOnce
(
)
)
->
method
(
'validate'
)
->
willReturn
(
new
ConstraintViolationList
(
[
$this
->
createMock
(
ConstraintViolationInterface::
class
)
,
]
)
)
;
}
$validator
=
new
HappyPathValidator
(
$inner
)
;
$list
=
$validator
->
validate
(
$value
,
$constraint
)
;
$isEmpty
=
$list
->
count
(
)
=== 0;
static
::
assertSame
(
$isValid
,
$isEmpty
)
;
}
public
static
function
constraintDataProvider
(
)
: \Generator
{
yield
'min range valid' =>
[
new
Range
(
[
'min' => 11
]
)
,
11,