Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
preValidate example
'code' => ' ',
]
,
[
'id' => 'D1'
]
,
$this
->
createMock
(
EntityExistence::
class
)
,
'/0'
)
;
$fakeConnection
=
new
FakeConnection
(
$this
->
getPromotionDbRows
(
)
)
;
$event
=
new
PreWriteValidationEvent
(
$this
->context,
$commands
)
;
$validator
=
new
PromotionValidator
(
$fakeConnection
)
;
$validator
->
preValidate
(
$event
)
;
try
{
$event
->
getExceptions
(
)
->
tryToThrow
(
)
;
static
::
fail
(
'Validation with invalid until was not triggered.'
)
;
}
catch
(
WriteException
$e
)
{
static
::
assertCount
(
1,
$e
->
getExceptions
(
)
)
;
$firstException
=
$e
->
getExceptions
(
)
[
0
]
;
static
::
assertInstanceOf
(
WriteConstraintViolationException::
class
,
$firstException
)
;
$violation
=
$firstException
->
getViolations
(
)
->
get
(
0
)
;
]
,
[
'id' => 'D1'
]
,
$this
->
createMock
(
EntityExistence::
class
)
,
'/0/'
)
;
$fakeConnection
=
new
FakeConnection
(
[
]
)
;
$event
=
new
PreWriteValidationEvent
(
$this
->context,
$commands
)
;
$validator
=
new
ShippingMethodValidator
(
$fakeConnection
)
;
$validator
->
preValidate
(
$event
)
;
$exception
= null;
try
{
$event
->
getExceptions
(
)
->
tryToThrow
(
)
;
}
catch
(
WriteException
$e
)
{
$exception
=
$e
;
}
if
(
!
$success
)
{
static
::
assertNotNull
(
$exception
)
;