Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
assertDateTimeEquals example
$transformer
->
transform
(
'2010-01-01'
)
;
}
/** * @dataProvider reverseTransformProvider */
public
function
testReverseTransform
(
$toTz
,
$fromTz
,
$to
,
$from
)
{
$transformer
=
new
DateTimeToRfc3339Transformer
(
$toTz
,
$fromTz
)
;
if
(
null !==
$to
)
{
$this
->
assertDateTimeEquals
(
new
\
DateTime
(
$to
)
,
$transformer
->
reverseTransform
(
$from
)
)
;
}
else
{
$this
->
assertNull
(
$transformer
->
reverseTransform
(
$from
)
)
;
}
}
public
function
testReverseTransformRequiresString
(
)
{
$this
->
expectException
(
TransformationFailedException::
class
)
;
$transformer
=
new
DateTimeToRfc3339Transformer
(
)
;
$transformer
->
reverseTransform
(
12345
)
;
}
$transformer
->
transform
(
'2010-01-01'
)
;
}
/** * @dataProvider reverseTransformProvider */
public
function
testReverseTransform
(
$toTz
,
$fromTz
,
$to
,
$from
)
{
$transformer
=
new
DateTimeToHtml5LocalDateTimeTransformer
(
$toTz
,
$fromTz
)
;
if
(
null !==
$to
)
{
$this
->
assertDateTimeEquals
(
new
\
DateTime
(
$to
)
,
$transformer
->
reverseTransform
(
$from
)
)
;
}
else
{
$this
->
assertNull
(
$transformer
->
reverseTransform
(
$from
)
)
;
}
}
public
function
testReverseTransformRequiresString
(
)
{
$this
->
expectException
(
TransformationFailedException::
class
)
;
$transformer
=
new
DateTimeToHtml5LocalDateTimeTransformer
(
)
;
$transformer
->
reverseTransform
(
12345
)
;
}
public
function
testReverseTransformWithNoConstructorParameters
(
)
{
$tz
=
date_default_timezone_get
(
)
;
date_default_timezone_set
(
'Europe/Rome'
)
;
$transformer
=
new
DateTimeToLocalizedStringTransformer
(
)
;
$dateTime
=
new
\
DateTime
(
'2010-02-03 04:05'
)
;
$this
->
assertDateTimeEquals
(
$dateTime
->
format
(
'c'
)
,
$transformer
->
reverseTransform
(
'03.02.2010, 04:05'
)
->
format
(
'c'
)
)
;
date_default_timezone_set
(
$tz
)
;
}
public
function
testTransformWithDifferentPatterns
(
)
{
$transformer
=
new
DateTimeToLocalizedStringTransformer
(
'UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss'
)
;