Skip to content

Extend tests with date constants #11241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions ext/date/tests/DateTimeImmutable_constants.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ DateTimeImmutable constants
<?php

var_dump(
DATE_ATOM === DateTimeImmutable::ATOM,
DATE_COOKIE === DateTimeImmutable::COOKIE,
DATE_ISO8601 === DateTimeImmutable::ISO8601,
DATE_RFC822 === DateTimeImmutable::RFC822,
DATE_RFC850 === DateTimeImmutable::RFC850,
DATE_RFC1036 === DateTimeImmutable::RFC1036,
DATE_RFC1123 === DateTimeImmutable::RFC1123,
DATE_RFC2822 === DateTimeImmutable::RFC2822,
DATE_RFC3339 === DateTimeImmutable::RFC3339,
DATE_RSS === DateTimeImmutable::RSS,
DATE_W3C === DateTimeImmutable::W3C
DATE_ATOM === DateTimeImmutable::ATOM,
DATE_COOKIE === DateTimeImmutable::COOKIE,
DATE_ISO8601 === DateTimeImmutable::ISO8601,
DATE_ISO8601_EXPANDED === DateTimeImmutable::ISO8601_EXPANDED,
DATE_RFC822 === DateTimeImmutable::RFC822,
DATE_RFC850 === DateTimeImmutable::RFC850,
DATE_RFC1036 === DateTimeImmutable::RFC1036,
DATE_RFC1123 === DateTimeImmutable::RFC1123,
DATE_RFC7231 === DateTimeImmutable::RFC7231,
DATE_RFC2822 === DateTimeImmutable::RFC2822,
DATE_RFC3339 === DateTimeImmutable::RFC3339,
DATE_RFC3339_EXTENDED === DateTimeImmutable::RFC3339_EXTENDED,
DATE_RSS === DateTimeImmutable::RSS,
DATE_W3C === DateTimeImmutable::W3C
);

?>
Expand All @@ -30,3 +33,6 @@ bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
28 changes: 17 additions & 11 deletions ext/date/tests/DateTimeInterface_constants.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ DateTimeInterface constants
<?php

var_dump(
DATE_ATOM === DateTimeInterface::ATOM,
DATE_COOKIE === DateTimeInterface::COOKIE,
DATE_ISO8601 === DateTimeInterface::ISO8601,
DATE_RFC822 === DateTimeInterface::RFC822,
DATE_RFC850 === DateTimeInterface::RFC850,
DATE_RFC1036 === DateTimeInterface::RFC1036,
DATE_RFC1123 === DateTimeInterface::RFC1123,
DATE_RFC2822 === DateTimeInterface::RFC2822,
DATE_RFC3339 === DateTimeInterface::RFC3339,
DATE_RSS === DateTimeInterface::RSS,
DATE_W3C === DateTimeInterface::W3C
DATE_ATOM === DateTimeInterface::ATOM,
DATE_COOKIE === DateTimeInterface::COOKIE,
DATE_ISO8601 === DateTimeInterface::ISO8601,
DATE_ISO8601_EXPANDED === DateTimeInterface::ISO8601_EXPANDED,
DATE_RFC822 === DateTimeInterface::RFC822,
DATE_RFC850 === DateTimeInterface::RFC850,
DATE_RFC1036 === DateTimeInterface::RFC1036,
DATE_RFC1123 === DateTimeInterface::RFC1123,
DATE_RFC7231 === DateTimeImmutable::RFC7231,
DATE_RFC2822 === DateTimeInterface::RFC2822,
DATE_RFC3339 === DateTimeInterface::RFC3339,
DATE_RFC3339_EXTENDED === DateTimeInterface::RFC3339_EXTENDED,
DATE_RSS === DateTimeInterface::RSS,
DATE_W3C === DateTimeInterface::W3C
);

?>
Expand All @@ -30,3 +33,6 @@ bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
28 changes: 17 additions & 11 deletions ext/date/tests/DateTime_constants.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ DateTime constants
<?php

var_dump(
DATE_ATOM === DateTime::ATOM,
DATE_COOKIE === DateTime::COOKIE,
DATE_ISO8601 === DateTime::ISO8601,
DATE_RFC822 === DateTime::RFC822,
DATE_RFC850 === DateTime::RFC850,
DATE_RFC1036 === DateTime::RFC1036,
DATE_RFC1123 === DateTime::RFC1123,
DATE_RFC2822 === DateTime::RFC2822,
DATE_RFC3339 === DateTime::RFC3339,
DATE_RSS === DateTime::RSS,
DATE_W3C === DateTime::W3C
DATE_ATOM === DateTime::ATOM,
DATE_COOKIE === DateTime::COOKIE,
DATE_ISO8601 === DateTime::ISO8601,
DATE_ISO8601_EXPANDED === DateTime::ISO8601_EXPANDED,
DATE_RFC822 === DateTime::RFC822,
DATE_RFC850 === DateTime::RFC850,
DATE_RFC1036 === DateTime::RFC1036,
DATE_RFC1123 === DateTime::RFC1123,
DATE_RFC7231 === DateTime::RFC7231,
DATE_RFC2822 === DateTime::RFC2822,
DATE_RFC3339 === DateTime::RFC3339,
DATE_RFC3339_EXTENDED === DateTime::RFC3339_EXTENDED,
DATE_RSS === DateTime::RSS,
DATE_W3C === DateTime::W3C
);

?>
Expand All @@ -30,3 +33,6 @@ bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
12 changes: 9 additions & 3 deletions ext/date/tests/DateTime_format_basic2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,38 @@ Test date_format() function : basic functionality
//Set the default time zone
date_default_timezone_set("Europe/London");

echo "*** Testing date_format() : basic functionality - formatting coinstants ***\n";
echo "*** Testing date_format() : basic functionality - formatting constants ***\n";
$date = new DateTime("2005-07-14 22:30:41");

var_dump( $date->format( DateTime::ATOM) ) ;
var_dump( $date->format( DateTime::COOKIE) ) ;
var_dump( $date->format( DateTime::ISO8601) ) ;
var_dump( $date->format( DateTime::ISO8601_EXPANDED) ) ;
var_dump( $date->format( DateTime::RFC822) ) ;
var_dump( $date->format( DateTime::RFC850) ) ;
var_dump( $date->format( DateTime::RFC1036) ) ;
var_dump( $date->format( DateTime::RFC1123) ) ;
var_dump( $date->format( DateTime:: RFC2822) ) ;
var_dump( $date->format( DateTime::RFC7231) ) ;
var_dump( $date->format( DateTime::RFC2822) ) ;
var_dump( $date->format( DateTime::RFC3339) ) ;
var_dump( $date->format( DateTime::RFC3339_EXTENDED) ) ;
var_dump( $date->format( DateTime::RSS) ) ;
var_dump( $date->format( DateTime::W3C) ) ;

?>
--EXPECT--
*** Testing date_format() : basic functionality - formatting coinstants ***
*** Testing date_format() : basic functionality - formatting constants ***
string(25) "2005-07-14T22:30:41+01:00"
string(34) "Thursday, 14-Jul-2005 22:30:41 BST"
string(24) "2005-07-14T22:30:41+0100"
string(26) "+2005-07-14T22:30:41+01:00"
string(29) "Thu, 14 Jul 05 22:30:41 +0100"
string(32) "Thursday, 14-Jul-05 22:30:41 BST"
string(29) "Thu, 14 Jul 05 22:30:41 +0100"
string(31) "Thu, 14 Jul 2005 22:30:41 +0100"
string(29) "Thu, 14 Jul 2005 22:30:41 GMT"
string(31) "Thu, 14 Jul 2005 22:30:41 +0100"
string(25) "2005-07-14T22:30:41+01:00"
string(29) "2005-07-14T22:30:41.000+01:00"
string(31) "Thu, 14 Jul 2005 22:30:41 +0100"
string(25) "2005-07-14T22:30:41+01:00"
37 changes: 26 additions & 11 deletions ext/date/tests/date_constants.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ Date constants
DATE_ATOM,
DATE_COOKIE,
DATE_ISO8601,
DATE_ISO8601_EXPANDED,
DATE_RFC822,
DATE_RFC850,
DATE_RFC1036,
DATE_RFC1123,
DATE_RFC7231,
DATE_RFC2822,
DATE_RFC3339,
DATE_RFC3339_EXTENDED,
DATE_RSS,
DATE_W3C
);
Expand All @@ -25,17 +28,20 @@ Date constants
print "\n";

var_dump(
DATE_ATOM == DateTime::ATOM,
DATE_COOKIE == DateTime::COOKIE,
DATE_ISO8601 == DateTime::ISO8601,
DATE_RFC822 == DateTime::RFC822,
DATE_RFC850 == DateTime::RFC850,
DATE_RFC1036 == DateTime::RFC1036,
DATE_RFC1123 == DateTime::RFC1123,
DATE_RFC2822 == DateTime::RFC2822,
DATE_RFC3339 == DateTime::RFC3339,
DATE_RSS == DateTime::RSS,
DATE_W3C == DateTime::W3C
DATE_ATOM == DateTime::ATOM,
DATE_COOKIE == DateTime::COOKIE,
DATE_ISO8601 == DateTime::ISO8601,
DATE_ISO8601_EXPANDED == DateTime::ISO8601_EXPANDED,
DATE_RFC822 == DateTime::RFC822,
DATE_RFC850 == DateTime::RFC850,
DATE_RFC1036 == DateTime::RFC1036,
DATE_RFC1123 == DateTime::RFC1123,
DATE_RFC2822 == DateTime::RFC2822,
DATE_RFC7231 == DateTime::RFC7231,
DATE_RFC3339 == DateTime::RFC3339,
DATE_RFC3339_EXTENDED == DateTime::RFC3339_EXTENDED,
DATE_RSS == DateTime::RSS,
DATE_W3C == DateTime::W3C
);
?>
--EXPECT--
Expand All @@ -45,6 +51,8 @@ string(35) "Saturday, 01-Jul-2006 14:27:30 CEST"
string(34) "Tuesday, 30-May-2006 14:32:13 CEST"
string(24) "2006-07-01T14:27:30+0200"
string(24) "2006-05-30T14:32:13+0200"
string(26) "+2006-07-01T14:27:30+02:00"
string(26) "+2006-05-30T14:32:13+02:00"
string(29) "Sat, 01 Jul 06 14:27:30 +0200"
string(29) "Tue, 30 May 06 14:32:13 +0200"
string(33) "Saturday, 01-Jul-06 14:27:30 CEST"
Expand All @@ -53,10 +61,14 @@ string(29) "Sat, 01 Jul 06 14:27:30 +0200"
string(29) "Tue, 30 May 06 14:32:13 +0200"
string(31) "Sat, 01 Jul 2006 14:27:30 +0200"
string(31) "Tue, 30 May 2006 14:32:13 +0200"
string(29) "Sat, 01 Jul 2006 14:27:30 GMT"
string(29) "Tue, 30 May 2006 14:32:13 GMT"
string(31) "Sat, 01 Jul 2006 14:27:30 +0200"
string(31) "Tue, 30 May 2006 14:32:13 +0200"
string(25) "2006-07-01T14:27:30+02:00"
string(25) "2006-05-30T14:32:13+02:00"
string(29) "2006-07-01T14:27:30.000+02:00"
string(29) "2006-05-30T14:32:13.000+02:00"
string(31) "Sat, 01 Jul 2006 14:27:30 +0200"
string(31) "Tue, 30 May 2006 14:32:13 +0200"
string(25) "2006-07-01T14:27:30+02:00"
Expand All @@ -73,3 +85,6 @@ bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
4 changes: 4 additions & 0 deletions ext/date/tests/strtotime2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ $constants = array(
'DATE_ATOM',
'DATE_COOKIE',
'DATE_ISO8601',
'DATE_ISO8601_EXPANDED',
'DATE_RFC822',
'DATE_RFC850',
'DATE_RFC1036',
'DATE_RFC1123',
'DATE_RFC2822',
'DATE_RFC3339',
'DATE_RFC3339_EXTENDED',
'DATE_RSS',
'DATE_W3C'
);
Expand All @@ -30,11 +32,13 @@ foreach ($constants as $const) {
DATE_ATOM: OK
DATE_COOKIE: OK
DATE_ISO8601: OK
DATE_ISO8601_EXPANDED: OK
DATE_RFC822: OK
DATE_RFC850: OK
DATE_RFC1036: OK
DATE_RFC1123: OK
DATE_RFC2822: OK
DATE_RFC3339: OK
DATE_RFC3339_EXTENDED: OK
DATE_RSS: OK
DATE_W3C: OK
42 changes: 32 additions & 10 deletions ext/date/tests/test-parse-from-format.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ date_create_from_format() and date_parse_from_format().
--FILE--
<?php
date_default_timezone_set('Europe/Oslo');
$formats = array( DATE_ATOM, DATE_COOKIE, DATE_ISO8601, DATE_RFC822,
DATE_RFC850, DATE_RFC1036, DATE_RFC1123, DATE_RFC2822, DATE_RFC3339,
$formats = array( DATE_ATOM, DATE_COOKIE, DATE_ISO8601, DATE_ISO8601_EXPANDED, DATE_RFC822,
DATE_RFC850, DATE_RFC1036, DATE_RFC1123, DATE_RFC2822, DATE_RFC3339, DATE_RFC3339_EXTENDED,
DATE_RSS, DATE_W3C );

foreach( $formats as $format )
Expand Down Expand Up @@ -54,9 +54,20 @@ object(DateTime)#3 (3) {
string(6) "+02:00"
}

string(13) "X-m-d\TH:i:sP"
string(26) "+2008-07-08T22:14:12+02:00"
object(DateTime)#2 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+02:00"
}

string(16) "D, d M y H:i:s O"
string(29) "Tue, 08 Jul 08 22:14:12 +0200"
object(DateTime)#2 (3) {
object(DateTime)#1 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
Expand All @@ -67,7 +78,7 @@ object(DateTime)#2 (3) {

string(16) "l, d-M-y H:i:s T"
string(36) "Tuesday, 08-Jul-08 22:14:12 GMT+0200"
object(DateTime)#1 (3) {
object(DateTime)#3 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
Expand All @@ -78,7 +89,7 @@ object(DateTime)#1 (3) {

string(16) "D, d M y H:i:s O"
string(29) "Tue, 08 Jul 08 22:14:12 +0200"
object(DateTime)#3 (3) {
object(DateTime)#2 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
Expand All @@ -89,7 +100,7 @@ object(DateTime)#3 (3) {

string(16) "D, d M Y H:i:s O"
string(31) "Tue, 08 Jul 2008 22:14:12 +0200"
object(DateTime)#2 (3) {
object(DateTime)#1 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
Expand All @@ -100,7 +111,7 @@ object(DateTime)#2 (3) {

string(16) "D, d M Y H:i:s O"
string(31) "Tue, 08 Jul 2008 22:14:12 +0200"
object(DateTime)#1 (3) {
object(DateTime)#3 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
Expand All @@ -111,7 +122,18 @@ object(DateTime)#1 (3) {

string(13) "Y-m-d\TH:i:sP"
string(25) "2008-07-08T22:14:12+02:00"
object(DateTime)#3 (3) {
object(DateTime)#2 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+02:00"
}

string(15) "Y-m-d\TH:i:s.vP"
string(29) "2008-07-08T22:14:12.000+02:00"
object(DateTime)#1 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
Expand All @@ -122,7 +144,7 @@ object(DateTime)#3 (3) {

string(16) "D, d M Y H:i:s O"
string(31) "Tue, 08 Jul 2008 22:14:12 +0200"
object(DateTime)#2 (3) {
object(DateTime)#3 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
Expand All @@ -133,7 +155,7 @@ object(DateTime)#2 (3) {

string(13) "Y-m-d\TH:i:sP"
string(25) "2008-07-08T22:14:12+02:00"
object(DateTime)#1 (3) {
object(DateTime)#2 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
Expand Down