mirror of
https://github.com/php/php-src.git
synced 2026-04-28 18:53:33 +02:00
New tests for date extension DateTime methods Tested on Windows, Linux and linux 64
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
--TEST--
|
||||
Test clone on DateTime objects
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
echo "*** Testing clone on DateTime objects ***\n";
|
||||
|
||||
// Create a DateTime object..
|
||||
$orig = new DateTime('2008-07-02 14:25:41');
|
||||
|
||||
// ..create a clone of it ..Clone
|
||||
$clone = clone $orig;
|
||||
|
||||
// ..and modify original
|
||||
$orig->setTime(22, 41, 50);
|
||||
|
||||
echo "Original: " . $orig->format("H:i:s") . "\n";
|
||||
echo "Clone: " . $clone->format("H:i:s") . "\n";
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing clone on DateTime objects ***
|
||||
Original: 22:41:50
|
||||
Clone: 14:25:41
|
||||
===DONE===
|
||||
@@ -0,0 +1,90 @@
|
||||
--TEST--
|
||||
Test clone of objects whoose class derived from DateTime class
|
||||
--FILE--
|
||||
<?php
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
class DateTimeExt1 extends DateTime {
|
||||
public $property1 = 99;
|
||||
public $property2 = "Hello";
|
||||
|
||||
}
|
||||
|
||||
class DateTimeExt2 extends DateTimeExt1 {
|
||||
public $property3 = true;
|
||||
public $property4 = 10.5;
|
||||
}
|
||||
|
||||
echo "*** Testing clone on objects whoose class derived from DateTime class ***\n";
|
||||
|
||||
$d1 = new DateTimeExt1("2009-02-03 12:34:41 GMT");
|
||||
var_dump($d1);
|
||||
$d1_clone = clone $d1;
|
||||
var_dump($d1_clone);
|
||||
|
||||
$d2 = new DateTimeExt2("2009-02-03 12:34:41 GMT");
|
||||
var_dump($d2);
|
||||
$d2_clone = clone $d2;
|
||||
var_dump($d2_clone);
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing clone on objects whoose class derived from DateTime class ***
|
||||
object(DateTimeExt1)#%d (5) {
|
||||
[u"property1"]=>
|
||||
int(99)
|
||||
[u"property2"]=>
|
||||
unicode(5) "Hello"
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-02-03 12:34:41"
|
||||
[u"timezone_type"]=>
|
||||
int(2)
|
||||
[u"timezone"]=>
|
||||
unicode(3) "GMT"
|
||||
}
|
||||
object(DateTimeExt1)#%d (5) {
|
||||
[u"property1"]=>
|
||||
int(99)
|
||||
[u"property2"]=>
|
||||
unicode(5) "Hello"
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-02-03 12:34:41"
|
||||
[u"timezone_type"]=>
|
||||
int(2)
|
||||
[u"timezone"]=>
|
||||
unicode(3) "GMT"
|
||||
}
|
||||
object(DateTimeExt2)#%d (7) {
|
||||
[u"property3"]=>
|
||||
bool(true)
|
||||
[u"property4"]=>
|
||||
float(10.5)
|
||||
[u"property1"]=>
|
||||
int(99)
|
||||
[u"property2"]=>
|
||||
unicode(5) "Hello"
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-02-03 12:34:41"
|
||||
[u"timezone_type"]=>
|
||||
int(2)
|
||||
[u"timezone"]=>
|
||||
unicode(3) "GMT"
|
||||
}
|
||||
object(DateTimeExt2)#%d (7) {
|
||||
[u"property3"]=>
|
||||
bool(true)
|
||||
[u"property4"]=>
|
||||
float(10.5)
|
||||
[u"property1"]=>
|
||||
int(99)
|
||||
[u"property2"]=>
|
||||
unicode(5) "Hello"
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-02-03 12:34:41"
|
||||
[u"timezone_type"]=>
|
||||
int(2)
|
||||
[u"timezone"]=>
|
||||
unicode(3) "GMT"
|
||||
}
|
||||
===DONE===
|
||||
@@ -0,0 +1,105 @@
|
||||
--TEST--
|
||||
Test clone of DateTime objects
|
||||
--FILE--
|
||||
<?php
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing clone on DateTime objects ***\n";
|
||||
|
||||
echo "\n-- Create a DateTime object --\n";
|
||||
$d1 = new DateTime("2009-02-03 12:34:41 GMT");
|
||||
var_dump($d1);
|
||||
echo "\n-- Add some properties --\n";
|
||||
$d1->property1 = 99;
|
||||
$d1->property2 = "Hello";
|
||||
var_dump($d1);
|
||||
echo "\n-- clone it --\n";
|
||||
$d1_clone = clone $d1;
|
||||
var_dump($d1_clone);
|
||||
echo "\n-- Add some more properties --\n";
|
||||
$d1_clone->property3 = true;
|
||||
$d1_clone->property4 = 10.5;
|
||||
var_dump($d1_clone);
|
||||
echo "\n-- clone it --\n";
|
||||
$d2_clone = clone $d1_clone;
|
||||
var_dump($d2_clone);
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing clone on DateTime objects ***
|
||||
|
||||
-- Create a DateTime object --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-02-03 12:34:41"
|
||||
[u"timezone_type"]=>
|
||||
int(2)
|
||||
[u"timezone"]=>
|
||||
unicode(3) "GMT"
|
||||
}
|
||||
|
||||
-- Add some properties --
|
||||
object(DateTime)#%d (5) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-02-03 12:34:41"
|
||||
[u"timezone_type"]=>
|
||||
int(2)
|
||||
[u"timezone"]=>
|
||||
unicode(3) "GMT"
|
||||
[u"property1"]=>
|
||||
int(99)
|
||||
[u"property2"]=>
|
||||
unicode(5) "Hello"
|
||||
}
|
||||
|
||||
-- clone it --
|
||||
object(DateTime)#%d (5) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-02-03 12:34:41"
|
||||
[u"timezone_type"]=>
|
||||
int(2)
|
||||
[u"timezone"]=>
|
||||
unicode(3) "GMT"
|
||||
[u"property1"]=>
|
||||
int(99)
|
||||
[u"property2"]=>
|
||||
unicode(5) "Hello"
|
||||
}
|
||||
|
||||
-- Add some more properties --
|
||||
object(DateTime)#%d (7) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-02-03 12:34:41"
|
||||
[u"timezone_type"]=>
|
||||
int(2)
|
||||
[u"timezone"]=>
|
||||
unicode(3) "GMT"
|
||||
[u"property1"]=>
|
||||
int(99)
|
||||
[u"property2"]=>
|
||||
unicode(5) "Hello"
|
||||
[u"property3"]=>
|
||||
bool(true)
|
||||
[u"property4"]=>
|
||||
float(10.5)
|
||||
}
|
||||
|
||||
-- clone it --
|
||||
object(DateTime)#%d (7) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-02-03 12:34:41"
|
||||
[u"timezone_type"]=>
|
||||
int(2)
|
||||
[u"timezone"]=>
|
||||
unicode(3) "GMT"
|
||||
[u"property1"]=>
|
||||
int(99)
|
||||
[u"property2"]=>
|
||||
unicode(5) "Hello"
|
||||
[u"property3"]=>
|
||||
bool(true)
|
||||
[u"property4"]=>
|
||||
float(10.5)
|
||||
}
|
||||
===DONE===
|
||||
@@ -0,0 +1,31 @@
|
||||
--TEST--
|
||||
Test clone of DateTime derived objects with __clone magic method
|
||||
--FILE--
|
||||
<?php
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
class DateTimeExt1 extends DateTime {
|
||||
public function __clone() {
|
||||
echo "-- DateTimeExt1 __clone magic method called --\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "*** Testing clone of objects derived from DateTime class with __clone magic method***\n";
|
||||
|
||||
$d1 = new DateTimeExt1("2009-02-03 12:34:41 GMT");
|
||||
$d1_clone = clone $d1;
|
||||
|
||||
//verify clone by calling method on new object
|
||||
var_dump( $d1_clone->format( "m.d.y") );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing clone of objects derived from DateTime class with __clone magic method***
|
||||
-- DateTimeExt1 __clone magic method called --
|
||||
unicode(8) "02.03.09"
|
||||
===DONE===
|
||||
@@ -0,0 +1,77 @@
|
||||
--TEST--
|
||||
Test of compare object handler for DateTime objects
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
echo "Simple test for DateTime compare object handler\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
class DateTimeExt1 extends DateTime {
|
||||
}
|
||||
|
||||
class DateTimeExt2 extends DateTime{
|
||||
public $foo = "Hello";
|
||||
private $bar = 99;
|
||||
}
|
||||
|
||||
class DateTimeExt3 extends DateTimeExt2 {
|
||||
}
|
||||
|
||||
$obj1 = new DateTime("2009-02-12 12:47:41 GMT");
|
||||
$obj2 = new DateTimeExt1("2009-02-12 12:47:41 GMT");
|
||||
$obj3 = new DateTimeExt2("2009-02-12 12:47:41 GMT");
|
||||
$obj4 = new DateTimeExt3("2009-02-12 12:47:41 GMT");
|
||||
|
||||
echo "\n-- All the following tests should compare equal --\n";
|
||||
var_dump($obj1 == $obj1);
|
||||
var_dump($obj1 == $obj2);
|
||||
var_dump($obj1 == $obj3);
|
||||
var_dump($obj1 == $obj4);
|
||||
var_dump($obj2 == $obj3);
|
||||
var_dump($obj2 == $obj4);
|
||||
var_dump($obj3 == $obj4);
|
||||
|
||||
date_modify($obj1, "+1 day");
|
||||
echo "\n-- The following test should still compare equal --\n";
|
||||
var_dump($obj1 == $obj1);
|
||||
echo "\n-- All the following tests should now compare NOT equal --\n";
|
||||
var_dump($obj1 == $obj2);
|
||||
var_dump($obj1 == $obj3);
|
||||
var_dump($obj1 == $obj4);
|
||||
|
||||
echo "\n-- All the following tests should again compare equal --\n";
|
||||
date_modify($obj2, "+1 day");
|
||||
date_modify($obj3, "+1 day");
|
||||
date_modify($obj4, "+1 day");
|
||||
var_dump($obj1 == $obj2);
|
||||
var_dump($obj1 == $obj3);
|
||||
var_dump($obj1 == $obj4);
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
Simple test for DateTime compare object handler
|
||||
|
||||
-- All the following tests should compare equal --
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
|
||||
-- The following test should still compare equal --
|
||||
bool(true)
|
||||
|
||||
-- All the following tests should now compare NOT equal --
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- All the following tests should again compare equal --
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
===DONE===
|
||||
@@ -0,0 +1,58 @@
|
||||
--TEST--
|
||||
Test new DateTime() : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime::__construct ([ string $time="now" [, DateTimeZone $timezone=NULL ]] )
|
||||
* Description: Returns new DateTime object
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing new DateTime() : basic functionality ***\n";
|
||||
|
||||
var_dump( new DateTime('') );
|
||||
|
||||
var_dump( new DateTime("GMT") );
|
||||
var_dump( new DateTime("2005-07-14 22:30:41") );
|
||||
var_dump( new DateTime("2005-07-14 22:30:41 GMT") );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing new DateTime() : basic functionality ***
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(2)
|
||||
[u"timezone"]=>
|
||||
unicode(3) "GMT"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2005-07-14 22:30:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2005-07-14 22:30:41"
|
||||
[u"timezone_type"]=>
|
||||
int(2)
|
||||
[u"timezone"]=>
|
||||
unicode(3) "GMT"
|
||||
}
|
||||
===DONE===
|
||||
@@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
Test new DateTime() : error conditions
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime::__construct ([ string $time="now" [, DateTimeZone $timezone=NULL ]] )
|
||||
* Description: Returns new DateTime object
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("GMT");
|
||||
|
||||
echo "*** Testing date_create() : error conditions ***\n";
|
||||
|
||||
echo "\n-- Testing new DateTime() with more than expected no. of arguments --\n";
|
||||
$time = "GMT";
|
||||
$timezone = timezone_open("GMT");
|
||||
$extra_arg = 99;
|
||||
var_dump( new DateTime($time, $timezone, $extra_arg) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_create() : error conditions ***
|
||||
|
||||
-- Testing new DateTime() with more than expected no. of arguments --
|
||||
|
||||
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() expects at most 2 parameters, 3 given' in %s:%d
|
||||
Stack trace:
|
||||
#0 %s(%d): DateTime->__construct('GMT', Object(DateTimeZone), 99)
|
||||
#1 {main}
|
||||
thrown in %s on line %d
|
||||
@@ -0,0 +1,377 @@
|
||||
--TEST--
|
||||
Test new DateTime() function : usage variation - Passing unexpected values to first argument $time.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime::__construct ([ string $time="now" [, DateTimeZone $timezone=NULL ]] )
|
||||
* Description: Returns new DateTime object
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_create
|
||||
*/
|
||||
|
||||
echo "*** Testing new DateTime(): usage variation - unexpected values to first argument \$time***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
// resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource
|
||||
'resource' => $file_handle
|
||||
);
|
||||
|
||||
$timezone = new DateTimeZone("Europe/London");
|
||||
|
||||
foreach($inputs as $variation =>$time) {
|
||||
echo "\n-- $variation --\n";
|
||||
|
||||
try {
|
||||
var_dump( new DateTime($time) );
|
||||
} catch(Exception $e) {
|
||||
$msg = $e->getMessage();
|
||||
echo "FAILED: " . $msg . "\n";
|
||||
}
|
||||
|
||||
try {
|
||||
var_dump( new DateTime($time, $timezone) );
|
||||
} catch(Exception$e) {
|
||||
$msg = $e->getMessage();
|
||||
echo "FAILED: " . $msg . "\n";
|
||||
}
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing new DateTime(): usage variation - unexpected values to first argument $time***
|
||||
|
||||
-- int 0 --
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (0) at position 0 (0): Unexpected character
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (0) at position 0 (0): Unexpected character
|
||||
|
||||
-- int 1 --
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (1) at position 0 (1): Unexpected character
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (1) at position 0 (1): Unexpected character
|
||||
|
||||
-- int 12345 --
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (12345) at position 4 (5): Unexpected character
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (12345) at position 4 (5): Unexpected character
|
||||
|
||||
-- int -12345 --
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (-12345) at position 5 (5): Unexpected character
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (-12345) at position 5 (5): Unexpected character
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (-10.5) at position 4 (5): Unexpected character
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (-10.5) at position 4 (5): Unexpected character
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be binary string, array given
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be binary string, array given
|
||||
|
||||
-- int indexed array --
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be binary string, array given
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be binary string, array given
|
||||
|
||||
-- associative array --
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be binary string, array given
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be binary string, array given
|
||||
|
||||
-- nested arrays --
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be binary string, array given
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be binary string, array given
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#6 (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#6 (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#6 (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (1) at position 0 (1): Unexpected character
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (1) at position 0 (1): Unexpected character
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#5 (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#5 (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (1) at position 0 (1): Unexpected character
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (1) at position 0 (1): Unexpected character
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#4 (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#4 (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
object(DateTime)#4 (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#4 (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string SQ --
|
||||
object(DateTime)#4 (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- string DQ --
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database
|
||||
|
||||
-- string SQ --
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database
|
||||
|
||||
-- mixed case string --
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (sTrInG) at position 0 (s): The timezone could not be found in the database
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (sTrInG) at position 0 (s): The timezone could not be found in the database
|
||||
|
||||
-- heredoc --
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (hello world) at position 0 (h): The timezone could not be found in the database
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (hello world) at position 0 (h): The timezone could not be found in the database
|
||||
|
||||
-- instance of classWithToString --
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (Class A object) at position 0 (C): The timezone could not be found in the database
|
||||
FAILED: DateTime::__construct(): Failed to parse time string (Class A object) at position 0 (C): The timezone could not be found in the database
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be binary string, object given
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be binary string, object given
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "%s"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be binary string, resource given
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be binary string, resource given
|
||||
===DONE===
|
||||
@@ -0,0 +1,203 @@
|
||||
--TEST--
|
||||
Test new DateTime() function : usage variation - Passing unexpected values to second argument $timezone.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime::__construct ([ string $time="now" [, DateTimeZone $timezone=NULL ]] )
|
||||
* Description: Returns new DateTime object
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_create
|
||||
*/
|
||||
|
||||
echo "*** Testing new DateTime() : usage variation - unexpected values to second argument \$timezone***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
// resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource
|
||||
'resource' => $file_handle
|
||||
);
|
||||
|
||||
$time = "2005-07-14 22:30:41";
|
||||
|
||||
foreach($inputs as $variation =>$timezone) {
|
||||
echo "\n-- $variation --\n";
|
||||
|
||||
try {
|
||||
var_dump( new DateTime($time, $timezone) );
|
||||
} catch(Exception $e) {
|
||||
$msg = $e->getMessage();
|
||||
echo "FAILED: " . $msg . "\n";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
*** Testing new DateTime() : usage variation - unexpected values to second argument $timezone***
|
||||
|
||||
-- int 0 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, integer given
|
||||
|
||||
-- int 1 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, integer given
|
||||
|
||||
-- int 12345 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, integer given
|
||||
|
||||
-- int -12345 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, integer given
|
||||
|
||||
-- float 10.5 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, double given
|
||||
|
||||
-- float -10.5 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, double given
|
||||
|
||||
-- float .5 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, double given
|
||||
|
||||
-- empty array --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, array given
|
||||
|
||||
-- int indexed array --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, array given
|
||||
|
||||
-- associative array --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, array given
|
||||
|
||||
-- nested arrays --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, array given
|
||||
|
||||
-- uppercase NULL --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, null given
|
||||
|
||||
-- lowercase null --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, null given
|
||||
|
||||
-- lowercase true --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, boolean given
|
||||
|
||||
-- lowercase false --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, boolean given
|
||||
|
||||
-- uppercase TRUE --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, boolean given
|
||||
|
||||
-- uppercase FALSE --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, boolean given
|
||||
|
||||
-- empty string DQ --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, Unicode string given
|
||||
|
||||
-- empty string SQ --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, Unicode string given
|
||||
|
||||
-- string DQ --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, Unicode string given
|
||||
|
||||
-- string SQ --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, Unicode string given
|
||||
|
||||
-- mixed case string --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, Unicode string given
|
||||
|
||||
-- heredoc --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, Unicode string given
|
||||
|
||||
-- instance of classWithToString --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, object given
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, object given
|
||||
|
||||
-- undefined var --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, null given
|
||||
|
||||
-- unset var --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, null given
|
||||
|
||||
-- resource --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, resource given
|
||||
===DONE===
|
||||
@@ -0,0 +1,49 @@
|
||||
--TEST--
|
||||
Test DateTime class inheritance
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing basic DateTime inheritance() ***\n";
|
||||
|
||||
|
||||
class DateTimeExt extends DateTime
|
||||
{
|
||||
public static $format = "F j, Y, g:i:s a";
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return parent::format(self::$format);
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n-- Create an instance of DateTimeExt --\n";
|
||||
$d = new DateTimeExt("1967-05-01 22:30:41");
|
||||
|
||||
echo "\n-- Invoke __toString --\n";
|
||||
echo $d . "\n";
|
||||
|
||||
echo "\n -- modify date and time --\n";
|
||||
$d->setDate(1963, 7, 2);
|
||||
$d->setTime(10, 45, 30);
|
||||
|
||||
echo "\n-- Invoke __toString again --\n";
|
||||
echo $d . "\n";
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing basic DateTime inheritance() ***
|
||||
|
||||
-- Create an instance of DateTimeExt --
|
||||
|
||||
-- Invoke __toString --
|
||||
May 1, 1967, 10:30:41 pm
|
||||
|
||||
-- modify date and time --
|
||||
|
||||
-- Invoke __toString again --
|
||||
July 2, 1963, 10:45:30 am
|
||||
===DONE===
|
||||
@@ -0,0 +1,31 @@
|
||||
--TEST--
|
||||
Test DateTime class inheritance : with user space __construct magic method
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing new DateTime() : with user space __construct magic method ***\n";
|
||||
|
||||
class DateTimeExt extends DateTime
|
||||
{
|
||||
public function __construct ($date = null, DateTimeZone $dtz = null)
|
||||
{
|
||||
if($dtz === null)
|
||||
{
|
||||
$dtz = new DateTimeZone(date_default_timezone_get());
|
||||
}
|
||||
parent::__construct($date, $dtz);
|
||||
}
|
||||
}
|
||||
|
||||
$d = new DateTimeExt("1967-05-01 22:30:41");
|
||||
echo $d->format("F j, Y, g:i:s a") . "\n";
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing new DateTime() : with user space __construct magic method ***
|
||||
May 1, 1967, 10:30:41 pm
|
||||
===DONE===
|
||||
@@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
Test DateTime class inheritance : with user space fromat() method
|
||||
--FILE--
|
||||
<?php
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing new DateTime() : with user format() method ***\n";
|
||||
|
||||
class DateTimeExt extends DateTime
|
||||
{
|
||||
public function format($format = "F j, Y, g:i:s a")
|
||||
{
|
||||
return parent::format($format);
|
||||
}
|
||||
}
|
||||
|
||||
$d = new DateTimeExt("1967-05-01 22:30:41");
|
||||
echo $d->format() . "\n";
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing new DateTime() : with user format() method ***
|
||||
May 1, 1967, 10:30:41 pm
|
||||
===DONE===
|
||||
@@ -0,0 +1,40 @@
|
||||
--TEST--
|
||||
Test DateTime::format() function : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public unicode DateTime::format ( unicode $format )
|
||||
* Description: Returns date formatted according to given format
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_format
|
||||
*/
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing DateTime::format() : basic functionality ***\n";
|
||||
$date = new DateTime("2005-07-14 22:30:41");
|
||||
|
||||
var_dump( $date->format( "F j, Y, g:i a") );
|
||||
var_dump( $date->format( "m.d.y") );
|
||||
var_dump( $date->format( "j, n, Y") );
|
||||
var_dump( $date->format( "Ymd") );
|
||||
var_dump( $date->format( 'h-i-s, j-m-y, it is w Day') );
|
||||
var_dump( $date->format( '\i\t \i\s \t\h\e jS \d\a\y.') );
|
||||
var_dump( $date->format( "D M j G:i:s T Y") );
|
||||
var_dump( $date->format( 'H:m:s \m \i\s\ \m\o\n\t\h') );
|
||||
var_dump( $date->format( "H:i:s") );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
*** Testing DateTime::format() : basic functionality ***
|
||||
unicode(23) "July 14, 2005, 10:30 pm"
|
||||
unicode(8) "07.14.05"
|
||||
unicode(11) "14, 7, 2005"
|
||||
unicode(8) "20050714"
|
||||
unicode(39) "10-30-41, 14-07-05, 3031 3041 4 Thupm05"
|
||||
unicode(19) "it is the 14th day."
|
||||
unicode(28) "Thu Jul 14 22:30:41 BST 2005"
|
||||
unicode(19) "22:07:41 m is month"
|
||||
unicode(8) "22:30:41"
|
||||
===DONE===
|
||||
@@ -0,0 +1,44 @@
|
||||
--TEST--
|
||||
Test date_format() function : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public unicode DateTime::format ( unicode $format )
|
||||
* Description: Returns date formatted according to given format
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_format
|
||||
*/
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing date_format() : basic functionality - formatting coinstants ***\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::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::RFC3339) ) ;
|
||||
var_dump( $date->format( DateTime::RSS) ) ;
|
||||
var_dump( $date->format( DateTime::W3C) ) ;
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
*** Testing date_format() : basic functionality - formatting coinstants ***
|
||||
unicode(25) "2005-07-14T22:30:41+01:00"
|
||||
unicode(32) "Thursday, 14-Jul-05 22:30:41 BST"
|
||||
unicode(24) "2005-07-14T22:30:41+0100"
|
||||
unicode(29) "Thu, 14 Jul 05 22:30:41 +0100"
|
||||
unicode(32) "Thursday, 14-Jul-05 22:30:41 BST"
|
||||
unicode(29) "Thu, 14 Jul 05 22:30:41 +0100"
|
||||
unicode(31) "Thu, 14 Jul 2005 22:30:41 +0100"
|
||||
unicode(31) "Thu, 14 Jul 2005 22:30:41 +0100"
|
||||
unicode(25) "2005-07-14T22:30:41+01:00"
|
||||
unicode(31) "Thu, 14 Jul 2005 22:30:41 +0100"
|
||||
unicode(25) "2005-07-14T22:30:41+01:00"
|
||||
===DONE===
|
||||
@@ -0,0 +1,41 @@
|
||||
--TEST--
|
||||
Test DateTime::format() function : error conditions
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public string DateTime::format ( string $format )
|
||||
* Description: Returns date formatted according to given format
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_format
|
||||
*/
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
// Craete a date object
|
||||
$date = new DateTime("2005-07-14 22:30:41");
|
||||
|
||||
echo "*** Testing DateTime::format() : error conditions ***\n";
|
||||
|
||||
echo "\n-- Testing date_date_formatcreate() function with zero arguments --\n";
|
||||
var_dump( $date->format() );
|
||||
|
||||
echo "\n-- Testing date_date_formatcreate() function with more than expected no. of arguments --\n";
|
||||
$format = "F j, Y, g:i a";
|
||||
$extra_arg = 10;
|
||||
var_dump( $date->format($format, $extra_arg) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::format() : error conditions ***
|
||||
|
||||
-- Testing date_date_formatcreate() function with zero arguments --
|
||||
|
||||
Warning: DateTime::format() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing date_date_formatcreate() function with more than expected no. of arguments --
|
||||
|
||||
Warning: DateTime::format() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Test DateTime::getOffset() function : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public int DateTime::getOffset ( void )
|
||||
* Description: Returns the daylight saving time offset
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_offset_get
|
||||
*/
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
echo "*** Testing DateTime::getOffset() : basic functionality ***\n";
|
||||
|
||||
$winter = new DateTime('2008-12-25 14:25:41');
|
||||
$summer = new DateTime('2008-07-02 14:25:41');
|
||||
|
||||
echo "Winter offset: " . $winter->getOffset() / 3600 . " hours\n";
|
||||
echo "Summer offset: " . $summer->getOffset() / 3600 . " hours\n";
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::getOffset() : basic functionality ***
|
||||
Winter offset: 0 hours
|
||||
Summer offset: 1 hours
|
||||
===DONE===
|
||||
@@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
Test DateTime::getOffset() function : error conditions
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/* Prototype : public int DateTime::getOffset ( void )
|
||||
* Description: Returns the daylight saving time offset
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_offset_get
|
||||
*/
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing DateTime::getOffset() : error conditions ***\n";
|
||||
|
||||
echo "\n-- Testing DateTime::getOffset() function with more than expected no. of arguments --\n";
|
||||
$datetime = new DateTime("2009-01-30 19:34:10");
|
||||
$extra_arg = 30;
|
||||
|
||||
var_dump( $datetime->getOffset($extra_arg) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::getOffset() : error conditions ***
|
||||
|
||||
-- Testing DateTime::getOffset() function with more than expected no. of arguments --
|
||||
|
||||
Warning: DateTime::getOffset() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
Test DateTime::getTimezone() function : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTimeZone DateTime::getTimezone ( void )
|
||||
* Description: Return time zone relative to given DateTime
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_timezone_get
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::getTimezone() : basic functionality ***\n";
|
||||
|
||||
date_default_timezone_set("Europe/London");
|
||||
$object = new DateTime("2009-01-30 17:57:32");
|
||||
var_dump( $object->getTimeZone()->getName() );
|
||||
|
||||
|
||||
date_default_timezone_set("America/New_York");
|
||||
$object = new DateTime("2009-01-30 17:57:32");
|
||||
var_dump( $object->getTimeZone()->getName() );
|
||||
|
||||
$la_time = new DateTimeZone("America/Los_Angeles");
|
||||
$object->setTimeZone($la_time);
|
||||
var_dump( $object->getTimeZone()->getName() );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::getTimezone() : basic functionality ***
|
||||
unicode(13) "Europe/London"
|
||||
unicode(16) "America/New_York"
|
||||
unicode(19) "America/Los_Angeles"
|
||||
===DONE===
|
||||
@@ -0,0 +1,39 @@
|
||||
--TEST--
|
||||
Test DateTime::modify() function : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::modify ( string $modify )
|
||||
* Description: Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime().
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: public date_modify()
|
||||
*/
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing DateTime::modify() : basic functionality ***\n";
|
||||
|
||||
// Create a date object to modify
|
||||
$datetime = new DateTime("2009-01-31 14:28:41");
|
||||
|
||||
$datetime->modify("+1 day");
|
||||
echo "After modification 1: " . $datetime->format("D, d M Y") . "\n";
|
||||
|
||||
$datetime->modify("+1 week 2 days 4 hours 2 seconds");
|
||||
echo "After modification 2: " . $datetime->format("D, d M Y H:i:s") . "\n";
|
||||
|
||||
$datetime->modify("next Thursday");
|
||||
echo "After modification 3: " . $datetime->format("D, d M Y") . "\n";
|
||||
|
||||
$datetime->modify("last Sunday");
|
||||
echo "After modification 4: " . $datetime->format("D, d M Y") . "\n";
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::modify() : basic functionality ***
|
||||
After modification 1: Sun, 01 Feb 2009
|
||||
After modification 2: Tue, 10 Feb 2009 18:28:43
|
||||
After modification 3: Thu, 12 Feb 2009
|
||||
After modification 4: Sun, 08 Feb 2009
|
||||
===DONE===
|
||||
@@ -0,0 +1,42 @@
|
||||
--TEST--
|
||||
Test DateTime::modify() function : error conditions
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::modify ( string $modify )
|
||||
* Description: Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime().
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: public date_modify()
|
||||
*/
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing DateTime::modify() : error conditions ***\n";
|
||||
|
||||
// Create a date object
|
||||
$object = new DateTime("2009-01-30 19:34:10");
|
||||
|
||||
echo "\n-- Testing DateTime::modify() function with less than expected no. of arguments --\n";
|
||||
var_dump( $object->modify() );
|
||||
|
||||
echo "\n-- Testing DateTime::modify() function with more than expected no. of arguments --\n";
|
||||
$modify = "+1 day";
|
||||
$extra_arg = 99;
|
||||
var_dump( $object->modify($modify, $extra_arg) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::modify() : error conditions ***
|
||||
|
||||
-- Testing DateTime::modify() function with less than expected no. of arguments --
|
||||
|
||||
Warning: DateTime::modify() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing DateTime::modify() function with more than expected no. of arguments --
|
||||
|
||||
Warning: DateTime::modify() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
|
||||
@@ -0,0 +1,362 @@
|
||||
--TEST--
|
||||
Test DateTime::modify() function : usage variation - Passing unexpected values to first argument $modify.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::modify ( string $modify )
|
||||
* Description: Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime().
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: public date_modify()
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::modify() : usage variation - unexpected values to first argument \$modify***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
// resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource
|
||||
'resource' => $file_handle
|
||||
);
|
||||
|
||||
$object = new DateTime("2009-01-31 14:28:41");
|
||||
|
||||
foreach($inputs as $variation =>$format) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( $object->modify($format) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::modify() : usage variation - unexpected values to first argument $modify***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::modify() expects parameter 1 to be binary string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::modify() expects parameter 1 to be binary string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::modify() expects parameter 1 to be binary string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::modify() expects parameter 1 to be binary string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string SQ --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- string DQ --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- string SQ --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- mixed case string --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- heredoc --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- instance of classWithToString --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::modify() expects parameter 1 to be binary string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 14:28:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::modify() expects parameter 1 to be binary string, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,39 @@
|
||||
--TEST--
|
||||
Test serialization of DateTime objects
|
||||
--FILE--
|
||||
<?php
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
$date1 = new DateTime("2005-07-14 22:30:41");
|
||||
var_dump($date1);
|
||||
$serialized = serialize($date1);
|
||||
var_dump($serialized);
|
||||
|
||||
$date2 = unserialize($serialized);
|
||||
var_dump($date2);
|
||||
// Try to use unserialzied object
|
||||
var_dump( $date2->format( "F j, Y, g:i a") );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2005-07-14 22:30:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
unicode(118) "O:8:"DateTime":3:{U:4:"date";U:19:"2005-07-14 22:30:41";U:13:"timezone_type";i:3;U:8:"timezone";U:13:"Europe/London";}"
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2005-07-14 22:30:41"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
unicode(23) "July 14, 2005, 10:30 pm"
|
||||
===DONE===
|
||||
@@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Test DateTime::setDate() function : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setDate ( int $year , int $month , int $day )
|
||||
* Description: Resets the current date of the DateTime object to a different date.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_date_set()
|
||||
*/
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing DateTime::setDate() : basic functionality ***\n";
|
||||
|
||||
$datetime = new DateTime("2009-01-30 19:34:10");
|
||||
|
||||
echo $datetime->format(DATE_RFC2822) . "\n";
|
||||
|
||||
$datetime->setDate(2008, 02, 01);
|
||||
|
||||
echo $datetime->format(DATE_RFC2822) . "\n";
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setDate() : basic functionality ***
|
||||
Fri, 30 Jan 2009 19:34:10 +0000
|
||||
Fri, 01 Feb 2008 19:34:10 +0000
|
||||
===DONE===
|
||||
@@ -0,0 +1,53 @@
|
||||
--TEST--
|
||||
Test DateTime::setDate() function : error conditions
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setDate ( int $year , int $month , int $day )
|
||||
* Description: Resets the current date of the DateTime object to a different date.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_date_set()
|
||||
*/
|
||||
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing DateTime::setDate() : error conditions ***\n";
|
||||
|
||||
$datetime = new DateTime("2009-01-30 19:34:10");
|
||||
|
||||
echo "\n-- Testing DateTime::setDate() function with zero arguments --\n";
|
||||
var_dump( $datetime->setDate() );
|
||||
|
||||
echo "\n-- Testing DateTime::setDate() function with less than expected no. of arguments --\n";
|
||||
$year = 2009;
|
||||
$month = 1;
|
||||
$day = 30;
|
||||
var_dump( $datetime->setDate($year) );
|
||||
var_dump( $datetime->setDate($year, $month) );
|
||||
|
||||
echo "\n-- Testing DateTime::setDate() function with more than expected no. of arguments --\n";
|
||||
$extra_arg = 10;
|
||||
var_dump( $datetime->setDate($year, $month, $day, $extra_arg) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setDate() : error conditions ***
|
||||
|
||||
-- Testing DateTime::setDate() function with zero arguments --
|
||||
|
||||
Warning: DateTime::setDate() expects exactly 3 parameters, 0 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing DateTime::setDate() function with less than expected no. of arguments --
|
||||
|
||||
Warning: DateTime::setDate() expects exactly 3 parameters, 1 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: DateTime::setDate() expects exactly 3 parameters, 2 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing DateTime::setDate() function with more than expected no. of arguments --
|
||||
|
||||
Warning: DateTime::setDate() expects exactly 3 parameters, 4 given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,329 @@
|
||||
--TEST--
|
||||
Test DateTime::setDate() function : usage variation - Passing unexpected values to first argument $year.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setDate ( int $year , int $month , int $day )
|
||||
* Description: Resets the current date of the DateTime object to a different date.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_date_set
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::setDate() : usage variation - unexpected values to first argument \$year***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
// resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource
|
||||
'resource' => $file_handle
|
||||
);
|
||||
|
||||
$object = new DateTime("2009-02-27 08:34:10");
|
||||
$day = 2;
|
||||
$month = 7;
|
||||
|
||||
foreach($inputs as $variation =>$year) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( $object->setDate($year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setDate() : usage variation - unexpected values to first argument $year***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0001-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(20) "12345-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(21) "-12345-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0010-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(20) "-0010-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0001-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0001-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-07-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be long, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,330 @@
|
||||
--TEST--
|
||||
Test DateTime::setDate() function : usage variation - Passing unexpected values to second argument $month.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setDate ( int $year , int $month , int $day )
|
||||
* Description: Resets the current date of the DateTime object to a different date.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_date_set
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::setDate() : usage variation - unexpected values to second argument \$month***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
// resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource
|
||||
'resource' => $file_handle
|
||||
);
|
||||
|
||||
$object = new DateTime("2009-02-27 08:34:10");
|
||||
$day = 2;
|
||||
$year = 1963;
|
||||
|
||||
foreach($inputs as $variation =>$month) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( $object->setDate($year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
|
||||
*** Testing DateTime::setDate() : usage variation - unexpected values to second argument $month***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-01-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2991-09-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0934-03-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-10-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-02-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-01-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-01-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-02 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be long, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,329 @@
|
||||
--TEST--
|
||||
Test DateTime::setDate() function : usage variation - Passing unexpected values to third argument $day.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setDate ( int $year , int $month , int $day )
|
||||
* Description: Resets the current date of the DateTime object to a different date.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_date_set
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::setDate() : usage variation - unexpected values to third argument \$day***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
// resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource
|
||||
'resource' => $file_handle
|
||||
);
|
||||
|
||||
$object = new DateTime("2009-02-27 08:34:10");
|
||||
$month = 7;
|
||||
$year = 1963;
|
||||
|
||||
foreach($inputs as $variation =>$day) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( $object->setDate($year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setDate() : usage variation - unexpected values to third argument $day***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-06-30 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-07-01 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1997-04-17 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1929-09-11 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-07-10 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-06-20 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-06-30 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-06-30 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-06-30 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-07-01 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-06-30 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-07-01 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-06-30 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-06-30 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-06-30 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be long, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,38 @@
|
||||
--TEST--
|
||||
Test DateTime::setISODate() function : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setISODate ( int $year , int $week [, int $day ] )
|
||||
* Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_isodate_set
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::setISODate() : basic functionality ***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
// Create a deate object
|
||||
$datetime = new DateTime("2009-01-30 17:57:32");
|
||||
|
||||
// Which month is week 40 ?
|
||||
$datetime->setISODate(2008, 40);
|
||||
echo "Week 40 of 2009 is in \"" . $datetime->format("F") . "\"\n";
|
||||
|
||||
// What date is week week 30 day 3 ?
|
||||
$datetime->setISODate(2009, 30, 3);
|
||||
echo "Week 30 day 3 of 2009 is \"" . $datetime->format("D M j") . "\"\n";
|
||||
|
||||
// What date was is last year ?
|
||||
$datetime->setISODate(2008, 30, 3);
|
||||
echo "..same day last year was \"" . $datetime->format("D M j") . "\"\n";
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setISODate() : basic functionality ***
|
||||
Week 40 of 2009 is in "September"
|
||||
Week 30 day 3 of 2009 is "Wed Jul 22"
|
||||
..same day last year was "Wed Jul 23"
|
||||
===DONE===
|
||||
@@ -0,0 +1,51 @@
|
||||
--TEST--
|
||||
Test DateTime::setISODate () function : error conditions
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/* Prototype : public DateTime DateTime::setISODate ( int $year , int $week [, int $day ] )
|
||||
* Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_isodate_set
|
||||
*/
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
$datetime = new DateTime("2009-01-30 19:34:10");
|
||||
|
||||
echo "*** Testing DateTime::setISODate () : error conditions ***\n";
|
||||
|
||||
echo "\n-- Testing DateTime::setISODate() function with zero arguments --\n";
|
||||
var_dump( $datetime->setISODate() );
|
||||
|
||||
$year = 2009;
|
||||
echo "\n-- Testing DateTime::setISODate() function with less than expected no. of arguments --\n";
|
||||
var_dump( $datetime->setISODate($year) );
|
||||
|
||||
echo "\n-- Testing date_isodate_set() function with more than expected no. of arguments --\n";
|
||||
$week = 30;
|
||||
$day = 7;
|
||||
$extra_arg = 30;
|
||||
var_dump( $datetime->setISODate($year, $week, $day, $extra_arg) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setISODate () : error conditions ***
|
||||
|
||||
-- Testing DateTime::setISODate() function with zero arguments --
|
||||
|
||||
Warning: DateTime::setISODate() expects at least 2 parameters, 0 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing DateTime::setISODate() function with less than expected no. of arguments --
|
||||
|
||||
Warning: DateTime::setISODate() expects at least 2 parameters, 1 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing date_isodate_set() function with more than expected no. of arguments --
|
||||
|
||||
Warning: DateTime::setISODate() expects at most 3 parameters, 4 given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,329 @@
|
||||
--TEST--
|
||||
Test DateTime::setISODate() function : usage variation - Passing unexpected values to first argument $year.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setISODate ( int $year , int $week [, int $day ] )
|
||||
* Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_isodate_set
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::setISODate() : usage variation - unexpected values to first argument \$year***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
// resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource
|
||||
'resource' => $file_handle
|
||||
);
|
||||
|
||||
$object = new DateTime("2009-02-27 08:34:10");
|
||||
$day = 2;
|
||||
$month = 7;
|
||||
|
||||
foreach($inputs as $variation =>$year) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( $object->setISODate($year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setISODate() : usage variation - unexpected values to first argument $year***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-02-15 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0001-02-13 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(20) "12345-02-13 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(21) "-12345-02-15 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0010-02-16 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(20) "-0010-02-19 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-02-15 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-02-15 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-02-15 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0001-02-13 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-02-15 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0001-02-13 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-02-15 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-02-15 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "0000-02-15 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be long, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,329 @@
|
||||
--TEST--
|
||||
Test DateTime::setISODate() function : usage variation - Passing unexpected values to second argument $week.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setISODate ( int $year , int $week [, int $day ] )
|
||||
* Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_isodate_set
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::setISODate() : usage variation - unexpected values to second argument \$week***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
// resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource
|
||||
'resource' => $file_handle
|
||||
);
|
||||
|
||||
$object = date_create("2009-02-27 08:34:10");
|
||||
$day = 2;
|
||||
$year = 1963;
|
||||
|
||||
foreach($inputs as $variation =>$month) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( $object->setISODate($year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setISODate() : usage variation - unexpected values to second argument $week***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-25 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-01-01 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2199-07-30 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1726-05-21 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-03-05 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-10-16 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-25 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-25 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-25 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-01-01 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-25 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-01-01 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-25 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-25 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1962-12-25 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be long, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,329 @@
|
||||
--TEST--
|
||||
Test DateTime::setISODate() function : usage variation - Passing unexpected values to third argument $day.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setISODate ( int $year , int $week [, int $day ] )
|
||||
* Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_isodate_set
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::setISODate() : usage variation - unexpected values to third argument \$day***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
// resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource
|
||||
'resource' => $file_handle
|
||||
);
|
||||
|
||||
$object = date_create("2009-02-27 08:34:10");
|
||||
$year = 1963;
|
||||
$month = 7;
|
||||
|
||||
foreach($inputs as $variation =>$day) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( $object->setISODate($year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setISODate() : usage variation - unexpected values to third argument $day***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-02-10 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-02-11 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1996-11-28 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1929-04-24 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-02-20 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-01-31 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-02-10 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-02-10 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-02-10 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-02-11 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-02-10 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-02-11 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-02-10 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-02-10 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "1963-02-10 08:34:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be long, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,46 @@
|
||||
--TEST--
|
||||
Test DateTime::setTime() function : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] )
|
||||
* Description: Resets the current time of the DateTime object to a different time.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_time_set
|
||||
*/
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing DateTime::setTime() : basic functionality ***\n";
|
||||
|
||||
// Create a DateTime object
|
||||
$datetime = new DateTime("2009-01-31 15:14:10");
|
||||
|
||||
echo "Initial date: " . $datetime ->format(DATE_RFC2822) . "\n";
|
||||
|
||||
$datetime->setTime(17, 20);
|
||||
echo "After modification1 " . $datetime ->format(DATE_RFC2822) . "\n";
|
||||
|
||||
$datetime->setTime(19, 05, 59);
|
||||
echo "After modification2 " . $datetime ->format(DATE_RFC2822) . "\n";
|
||||
|
||||
$datetime->setTime(24, 10);
|
||||
echo "After modification3 " . $datetime ->format(DATE_RFC2822) . "\n";
|
||||
|
||||
$datetime->setTime(47, 35, 47);
|
||||
echo "After modification4 " . $datetime ->format(DATE_RFC2822) . "\n";
|
||||
|
||||
$datetime->setTime(54, 25);
|
||||
echo "After modification5 " . $datetime ->format(DATE_RFC2822) . "\n";
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setTime() : basic functionality ***
|
||||
Initial date: Sat, 31 Jan 2009 15:14:10 +0000
|
||||
After modification1 Sat, 31 Jan 2009 17:20:00 +0000
|
||||
After modification2 Sat, 31 Jan 2009 19:05:59 +0000
|
||||
After modification3 Sun, 01 Feb 2009 00:10:00 +0000
|
||||
After modification4 Mon, 02 Feb 2009 23:35:47 +0000
|
||||
After modification5 Wed, 04 Feb 2009 06:25:00 +0000
|
||||
===DONE===
|
||||
@@ -0,0 +1,49 @@
|
||||
--TEST--
|
||||
Test DateTime::setTime() function : error conditions
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] )
|
||||
* Description: Resets the current time of the DateTime object to a different time.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_time_set
|
||||
*/
|
||||
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
echo "*** Testing DateTime::setTime() : error conditions ***\n";
|
||||
|
||||
$datetime = date_create("2009-01-31 15:34:10");
|
||||
|
||||
echo "\n-- Testing DateTime::setTime() function with zero arguments --\n";
|
||||
var_dump( $datetime->setTime() );
|
||||
|
||||
echo "\n-- Testing DateTime::setTime() function with less than expected no. of arguments --\n";
|
||||
$hour = 18;
|
||||
var_dump( $datetime->setTime($hour) );
|
||||
|
||||
echo "\n-- Testing DateTime::setTime() function with more than expected no. of arguments --\n";
|
||||
$min = 15;
|
||||
$sec = 30;
|
||||
$extra_arg = 10;
|
||||
var_dump( $datetime->setTime($hour, $min, $sec, $extra_arg) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setTime() : error conditions ***
|
||||
|
||||
-- Testing DateTime::setTime() function with zero arguments --
|
||||
|
||||
Warning: DateTime::setTime() expects at least 2 parameters, 0 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing DateTime::setTime() function with less than expected no. of arguments --
|
||||
|
||||
Warning: DateTime::setTime() expects at least 2 parameters, 1 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing DateTime::setTime() function with more than expected no. of arguments --
|
||||
|
||||
Warning: DateTime::setTime() expects at most 3 parameters, 4 given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,329 @@
|
||||
--TEST--
|
||||
Test DateTime::setTime() function : usage variation - Passing unexpected values to first argument $hour.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] )
|
||||
* Description: Resets the current time of the DateTime object to a different time.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_time_set
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::setTime() : usage variation - unexpected values to first argument \$hour***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
// resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource
|
||||
'resource' => $file_handle
|
||||
);
|
||||
|
||||
$object = new DateTime("2009-01-31 15:14:10");
|
||||
$minute = 13;
|
||||
$sec = 45;
|
||||
|
||||
foreach($inputs as $variation =>$hour) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( $object->setTime($hour, $minute, $sec) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setTime() : usage variation - unexpected values to first argument $hour***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 00:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 01:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2010-06-29 09:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 15:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 10:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-29 14:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-29 00:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-29 00:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-29 00:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-29 01:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-29 00:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-29 01:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-29 00:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-29 00:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-29 00:13:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be long, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,329 @@
|
||||
--TEST--
|
||||
Test DateTime::setTime() function : usage variation - Passing unexpected values to second argument $minute.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] )
|
||||
* Description: Resets the current time of the DateTime object to a different time.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_time_set
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::setTime() : usage variation - unexpected values to second argument \$minute***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
// resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource
|
||||
'resource' => $file_handle
|
||||
);
|
||||
|
||||
$object = new DateTime("2009-01-31 15:14:10");
|
||||
$hour = 10;
|
||||
$sec = 45;
|
||||
|
||||
foreach($inputs as $variation =>$minute) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( $object->setTime($hour, $minute, $sec) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setTime() : usage variation - unexpected values to second argument $minute***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:00:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:01:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-02-08 23:45:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 20:15:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 10:10:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 09:50:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 10:00:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 10:00:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 10:00:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 10:01:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 10:00:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 10:01:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 10:00:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 10:00:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-30 10:00:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be long, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,329 @@
|
||||
--TEST--
|
||||
Test DateTime::setTime() function : usage variation - Passing unexpected values to third argument $second.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] )
|
||||
* Description: Resets the current time of the DateTime object to a different time.
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_time_set
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::setTime() : usage variation - unexpected values to third argument \$second***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
// resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource
|
||||
'resource' => $file_handle
|
||||
);
|
||||
|
||||
$object = new DateTime("2009-01-31 15:14:10");
|
||||
$hour = 10;
|
||||
$minute = 13;
|
||||
|
||||
foreach($inputs as $variation =>$sec) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( $object->setTime($hour, $minute, $sec) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setTime() : usage variation - unexpected values to third argument $second***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:13:00"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:13:01"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 13:38:45"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 06:47:15"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:13:10"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:12:50"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:13:00"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:13:00"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:13:00"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:13:01"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:13:00"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:13:01"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:13:00"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:13:00"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
[u"date"]=>
|
||||
unicode(19) "2009-01-31 10:13:00"
|
||||
[u"timezone_type"]=>
|
||||
int(3)
|
||||
[u"timezone"]=>
|
||||
unicode(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be long, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,29 @@
|
||||
--TEST--
|
||||
Test DateTime::setTimezone() function : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setTimezone ( DateTimeZone $timezone )
|
||||
* Description: Sets the time zone for the DateTime object
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_timezone_set
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::setTimezone() : basic functionality ***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
$datetime = new DateTime("2009-01-30 17:57:32");
|
||||
echo "Default timezone: " . date_timezone_get($datetime)->getName() . "\n";
|
||||
|
||||
$la_time = new DateTimezone("America/Los_Angeles");
|
||||
$datetime->setTimezone($la_time);
|
||||
echo "New timezone: " . date_timezone_get($datetime)->getName() . "\n";
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setTimezone() : basic functionality ***
|
||||
Default timezone: Europe/London
|
||||
New timezone: America/Los_Angeles
|
||||
===DONE===
|
||||
@@ -0,0 +1,39 @@
|
||||
--TEST--
|
||||
Test DateTime::setTimezone () function : error conditions
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setTimezone ( DateTimeZone $timezone )
|
||||
* Description: Sets the time zone for the DateTime object
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_timezone_set
|
||||
*/
|
||||
|
||||
date_default_timezone_set("UTC");
|
||||
|
||||
echo "*** Testing DateTime::setTimezone () : error conditions ***\n";
|
||||
|
||||
$datetime = new DateTime("2009-01-30 17:57:32");
|
||||
|
||||
echo "\n-- Testing DateTime::setTimezone () function with zero arguments --\n";
|
||||
var_dump( $datetime->setTimezone() );
|
||||
|
||||
echo "\n-- Testing DateTime::setTimezone () function with more than expected no. of arguments --\n";
|
||||
$timezone = new DateTimezone("GMT");
|
||||
$extra_arg = 99;
|
||||
var_dump( $datetime->setTimezone($timezone, $extra_arg) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setTimezone () : error conditions ***
|
||||
|
||||
-- Testing DateTime::setTimezone () function with zero arguments --
|
||||
|
||||
Warning: DateTime::setTimezone() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing DateTime::setTimezone () function with more than expected no. of arguments --
|
||||
|
||||
Warning: DateTime::setTimezone() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,252 @@
|
||||
--TEST--
|
||||
Test DateTime::setTimezone() function : usage variation - Passing unexpected values to first argument $timezone.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : public DateTime DateTime::setTimezone ( DateTimeZone $timezone )
|
||||
* Description: Sets the time zone for the DateTime object
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: date_timezone_set
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::setTimezone() : usage variation - unexpected values to first argument \$timezone***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
// resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource
|
||||
'resource' => $file_handle
|
||||
);
|
||||
|
||||
$object = new DateTime("2009-01-30 17:57:32");
|
||||
|
||||
foreach($inputs as $variation =>$timezone) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( $object->setTimezone($timezone) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::setTimezone() : usage variation - unexpected values to first argument $timezone***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,183 @@
|
||||
--TEST--
|
||||
Test DateTime class registration
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
echo "*** Verify DateTime class ***\n";
|
||||
|
||||
echo "Verify DateTime class registered OK\n";
|
||||
$class = new ReflectionClass('DateTime');
|
||||
var_dump($class);
|
||||
|
||||
echo "..and get names of all its methods\n";
|
||||
$methods = $class->getMethods();
|
||||
var_dump($methods);
|
||||
|
||||
echo "..and get names of all its class constants\n";
|
||||
$constants = $class->getConstants();
|
||||
var_dump($constants);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Verify DateTime class ***
|
||||
Verify DateTime class registered OK
|
||||
object(ReflectionClass)#%d (1) {
|
||||
[u"name"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
..and get names of all its methods
|
||||
array(18) {
|
||||
[0]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(11) "__construct"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[1]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(8) "__wakeup"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[2]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(11) "__set_state"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[3]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(16) "createFromFormat"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[4]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(13) "getLastErrors"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[5]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(6) "format"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[6]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(6) "modify"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[7]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(3) "add"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[8]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(3) "sub"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[9]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(11) "getTimezone"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[10]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(11) "setTimezone"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[11]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(9) "getOffset"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[12]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(7) "setTime"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[13]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(7) "setDate"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[14]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(10) "setISODate"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[15]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(12) "setTimestamp"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[16]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(12) "getTimestamp"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
[17]=>
|
||||
&object(ReflectionMethod)#%d (2) {
|
||||
[u"name"]=>
|
||||
unicode(4) "diff"
|
||||
[u"class"]=>
|
||||
unicode(8) "DateTime"
|
||||
}
|
||||
}
|
||||
..and get names of all its class constants
|
||||
array(11) {
|
||||
[u"ATOM"]=>
|
||||
unicode(13) "Y-m-d\TH:i:sP"
|
||||
[u"COOKIE"]=>
|
||||
unicode(16) "l, d-M-y H:i:s T"
|
||||
[u"ISO8601"]=>
|
||||
unicode(13) "Y-m-d\TH:i:sO"
|
||||
[u"RFC822"]=>
|
||||
unicode(16) "D, d M y H:i:s O"
|
||||
[u"RFC850"]=>
|
||||
unicode(16) "l, d-M-y H:i:s T"
|
||||
[u"RFC1036"]=>
|
||||
unicode(16) "D, d M y H:i:s O"
|
||||
[u"RFC1123"]=>
|
||||
unicode(16) "D, d M Y H:i:s O"
|
||||
[u"RFC2822"]=>
|
||||
unicode(16) "D, d M Y H:i:s O"
|
||||
[u"RFC3339"]=>
|
||||
unicode(13) "Y-m-d\TH:i:sP"
|
||||
[u"RSS"]=>
|
||||
unicode(16) "D, d M Y H:i:s O"
|
||||
[u"W3C"]=>
|
||||
unicode(13) "Y-m-d\TH:i:sP"
|
||||
}
|
||||
===DONE===
|
||||
Reference in New Issue
Block a user