Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
invalidDateIntervalFormat example
if
(
$interval
=== null
)
{
yield
$field
->
getStorageName
(
)
=> null;
return
;
}
if
(
\
is_string
(
$interval
)
)
{
try
{
$interval
=
new
DateInterval
(
$interval
)
;
}
catch
(
\Throwable
$e
)
{
throw
DataAbstractionLayerException::
invalidDateIntervalFormat
(
$interval
,
$e
)
;
}
}
$data
->
setValue
(
$interval
)
;
$this
->
validateIfNeeded
(
$field
,
$existence
,
$data
,
$parameters
)
;
if
(
!
$interval
instanceof \DateInterval
)
{
yield
$field
->
getStorageName
(
)
=> null;
return
;
}
public
function
testInvalidCronIntervalFormat
(
)
: void
{
$e
= DataAbstractionLayerException::
invalidCronIntervalFormat
(
'foo'
)
;
static
::
assertSame
(
Response::HTTP_BAD_REQUEST,
$e
->
getStatusCode
(
)
)
;
static
::
assertSame
(
DataAbstractionLayerException::INVALID_CRON_INTERVAL_CODE,
$e
->
getErrorCode
(
)
)
;
static
::
assertSame
(
'Unknown or bad CronInterval format "foo".',
$e
->
getMessage
(
)
)
;
}
public
function
testInvalidDateIntervalFormat
(
)
: void
{
$e
= DataAbstractionLayerException::
invalidDateIntervalFormat
(
'foo'
)
;
static
::
assertSame
(
Response::HTTP_BAD_REQUEST,
$e
->
getStatusCode
(
)
)
;
static
::
assertSame
(
DataAbstractionLayerException::INVALID_DATE_INTERVAL_CODE,
$e
->
getErrorCode
(
)
)
;
static
::
assertSame
(
'Unknown or bad DateInterval format "foo".',
$e
->
getMessage
(
)
)
;
}
public
function
testInvalidSerializerField
(
)
: void
{
$e
= DataAbstractionLayerException::
invalidSerializerField
(
FkField::
class
,
new
IdField
(
'foo', 'foo'
)
)
;
static
::
assertSame
(
Response::HTTP_BAD_REQUEST,
$e
->
getStatusCode
(
)
)
;