Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getValidationExceptionMessage example
$ex
= null;
try
{
$this
->
getWriter
(
)
->
insert
(
$definition
,
[
$data
]
,
$context
)
;
}
catch
(
WriteException
$ex
)
{
}
static
::
assertInstanceOf
(
WriteException::
class
,
$ex
)
;
static
::
assertCount
(
1,
$ex
->
getExceptions
(
)
)
;
static
::
assertEquals
(
'This field is write-protected.',
$this
->
getValidationExceptionMessage
(
$ex
)
)
;
$fieldException
=
$ex
->
getExceptions
(
)
[
0
]
;
static
::
assertEquals
(
WriteConstraintViolationException::
class
,
$fieldException
::
class
)
;
static
::
assertEquals
(
'/0/protected',
$fieldException
->
getPath
(
)
)
;
}
public
function
testWriteWithoutProtectedField
(
)
: void
{
$id
= Uuid::
randomHex
(
)
;
$context
=
$this
->
createWriteContext
(
)
;
$definition
=
$this
->
getContainer
(
)
->
get
(
WriteProtectedDefinition::
class
)
;