Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
PrimitiveTypeConstraintValidator example
if
(
$valid
)
{
$context
->
expects
(
$this
->
never
(
)
)
->
method
(
'addViolation'
)
;
}
else
{
$context
->
expects
(
$this
->
once
(
)
)
->
method
(
'addViolation'
)
;
}
$constraint
=
new
PrimitiveTypeConstraint
(
)
;
$validate
=
new
PrimitiveTypeConstraintValidator
(
)
;
$validate
->
initialize
(
$context
)
;
$validate
->
validate
(
$value
,
$constraint
)
;
}
public
function
provideTestValidate
(
)
{
$data
=
[
]
;
$data
[
]
=
[
new
BooleanData
(
DataDefinition::
create
(
'boolean'
)
)
, NULL, TRUE
]
;
$data
[
]
=
[
new
BooleanData
(
DataDefinition::
create
(
'boolean'
)
)
, 1, TRUE
]
;
$data
[
]
=
[
new
BooleanData
(
DataDefinition::
create
(
'boolean'
)
)
, 'test', FALSE
]
;
$data
[
]
=
[
new
FloatData
(
DataDefinition::
create
(
'float'
)
)
, 1.5, TRUE
]
;