mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Merge branch 'PHP-7.4'
This commit is contained in:
commit
d750f0a192
@ -1,138 +0,0 @@
|
||||
--TEST--
|
||||
Test function_exists() function : usage variations - test values for $str argument
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* proto bool function_exists(string function_name)
|
||||
* Function is implemented in Zend/zend_builtin_functions.c
|
||||
*/
|
||||
|
||||
echo "*** Testing function_exists() function: with unexpected inputs for 'str' argument ***\n";
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 'string_val';
|
||||
unset($unset_var);
|
||||
|
||||
//defining a class
|
||||
class sample {
|
||||
public function __toString() {
|
||||
return "sample object";
|
||||
}
|
||||
}
|
||||
|
||||
//getting the resource
|
||||
$file_handle = fopen(__FILE__, "r");
|
||||
|
||||
// array with different values for $str
|
||||
$inputs = array (
|
||||
|
||||
// integer values
|
||||
0,
|
||||
1,
|
||||
255,
|
||||
256,
|
||||
PHP_INT_MAX,
|
||||
-PHP_INT_MAX,
|
||||
|
||||
// float values
|
||||
10.5,
|
||||
-20.5,
|
||||
10.1234567e10,
|
||||
|
||||
// array values
|
||||
array(),
|
||||
array(0),
|
||||
array(1, 2),
|
||||
|
||||
// boolean values
|
||||
true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// null values
|
||||
NULL,
|
||||
null,
|
||||
|
||||
// objects
|
||||
new sample(),
|
||||
|
||||
// resource
|
||||
$file_handle,
|
||||
|
||||
// undefined variable
|
||||
@$undefined_var,
|
||||
|
||||
// unset variable
|
||||
@$unset_var
|
||||
);
|
||||
|
||||
// loop through with each element of the $inputs array to test function_exists() function
|
||||
$count = 1;
|
||||
foreach($inputs as $input) {
|
||||
echo "-- Iteration $count --\n";
|
||||
var_dump( function_exists($input) );
|
||||
$count ++;
|
||||
}
|
||||
|
||||
fclose($file_handle); //closing the file handle
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing function_exists() function: with unexpected inputs for 'str' argument ***
|
||||
-- Iteration 1 --
|
||||
bool(false)
|
||||
-- Iteration 2 --
|
||||
bool(false)
|
||||
-- Iteration 3 --
|
||||
bool(false)
|
||||
-- Iteration 4 --
|
||||
bool(false)
|
||||
-- Iteration 5 --
|
||||
bool(false)
|
||||
-- Iteration 6 --
|
||||
bool(false)
|
||||
-- Iteration 7 --
|
||||
bool(false)
|
||||
-- Iteration 8 --
|
||||
bool(false)
|
||||
-- Iteration 9 --
|
||||
bool(false)
|
||||
-- Iteration 10 --
|
||||
|
||||
Warning: function_exists() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 11 --
|
||||
|
||||
Warning: function_exists() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 12 --
|
||||
|
||||
Warning: function_exists() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 13 --
|
||||
bool(false)
|
||||
-- Iteration 14 --
|
||||
bool(false)
|
||||
-- Iteration 15 --
|
||||
bool(false)
|
||||
-- Iteration 16 --
|
||||
bool(false)
|
||||
-- Iteration 17 --
|
||||
bool(false)
|
||||
-- Iteration 18 --
|
||||
bool(false)
|
||||
-- Iteration 19 --
|
||||
bool(false)
|
||||
-- Iteration 20 --
|
||||
|
||||
Warning: function_exists() expects parameter 1 to be string, resource given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 21 --
|
||||
bool(false)
|
||||
-- Iteration 22 --
|
||||
bool(false)
|
||||
===Done===
|
||||
|
@ -1,159 +0,0 @@
|
||||
--TEST--
|
||||
Test curl_version() function : usage variations - test values for $ascii argument
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded");
|
||||
if (PHP_INT_SIZE != 8) die('skip 64-bit only'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/* Prototype : array curl_version ([ int $age ] )
|
||||
* Description: Returns information about the cURL version.
|
||||
* Source code: ext/curl/interface.c
|
||||
*/
|
||||
|
||||
echo "*** Testing curl_version() function: with unexpected inputs for 'age' argument ***\n";
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 'string_val';
|
||||
unset($unset_var);
|
||||
|
||||
//defining a class
|
||||
class sample {
|
||||
public function __toString() {
|
||||
return "sample object";
|
||||
}
|
||||
}
|
||||
|
||||
//getting the resource
|
||||
$file_handle = fopen(__FILE__, "r");
|
||||
|
||||
// array with different values for $input
|
||||
$inputs = array (
|
||||
|
||||
// integer values
|
||||
0,
|
||||
1,
|
||||
255,
|
||||
256,
|
||||
PHP_INT_MAX,
|
||||
-PHP_INT_MAX,
|
||||
|
||||
// float values
|
||||
10.5,
|
||||
-20.5,
|
||||
10.1234567e10,
|
||||
|
||||
// array values
|
||||
array(),
|
||||
array(0),
|
||||
array(1, 2),
|
||||
|
||||
//string values
|
||||
"ABC",
|
||||
'abc',
|
||||
"2abc",
|
||||
|
||||
// boolean values
|
||||
true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// null values
|
||||
NULL,
|
||||
null,
|
||||
|
||||
// objects
|
||||
new sample(),
|
||||
|
||||
// resource
|
||||
$file_handle,
|
||||
|
||||
// undefined variable
|
||||
@$undefined_var,
|
||||
|
||||
// unset variable
|
||||
@$unset_var
|
||||
);
|
||||
|
||||
// loop through with each element of the $inputs array to test curl_version() function
|
||||
$count = 1;
|
||||
foreach($inputs as $input) {
|
||||
echo "-- Iteration $count --\n";
|
||||
var_dump( is_array(curl_version($input)) );
|
||||
$count ++;
|
||||
}
|
||||
|
||||
fclose($file_handle); //closing the file handle
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing curl_version() function: with unexpected inputs for 'age' argument ***
|
||||
-- Iteration 1 --
|
||||
bool(true)
|
||||
-- Iteration 2 --
|
||||
bool(true)
|
||||
-- Iteration 3 --
|
||||
bool(true)
|
||||
-- Iteration 4 --
|
||||
bool(true)
|
||||
-- Iteration 5 --
|
||||
bool(true)
|
||||
-- Iteration 6 --
|
||||
bool(true)
|
||||
-- Iteration 7 --
|
||||
bool(true)
|
||||
-- Iteration 8 --
|
||||
bool(true)
|
||||
-- Iteration 9 --
|
||||
bool(true)
|
||||
-- Iteration 10 --
|
||||
|
||||
Warning: curl_version() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 11 --
|
||||
|
||||
Warning: curl_version() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 12 --
|
||||
|
||||
Warning: curl_version() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 13 --
|
||||
|
||||
Warning: curl_version() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 14 --
|
||||
|
||||
Warning: curl_version() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 15 --
|
||||
|
||||
Notice: A non well formed numeric value encountered in %s on line %d
|
||||
bool(true)
|
||||
-- Iteration 16 --
|
||||
bool(true)
|
||||
-- Iteration 17 --
|
||||
bool(true)
|
||||
-- Iteration 18 --
|
||||
bool(true)
|
||||
-- Iteration 19 --
|
||||
bool(true)
|
||||
-- Iteration 20 --
|
||||
bool(true)
|
||||
-- Iteration 21 --
|
||||
bool(true)
|
||||
-- Iteration 22 --
|
||||
|
||||
Warning: curl_version() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 23 --
|
||||
|
||||
Warning: curl_version() expects parameter 1 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 24 --
|
||||
bool(true)
|
||||
-- Iteration 25 --
|
||||
bool(true)
|
||||
===Done===
|
@ -1,192 +0,0 @@
|
||||
--TEST--
|
||||
Test DateTime::__construct() function : usage variation - Passing unexpected values to first argument $timezone.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTimeZone::__construct ( string $timezone )
|
||||
* Description: Returns new DateTimeZone object
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::__construct() : 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,
|
||||
|
||||
// float data
|
||||
'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
|
||||
);
|
||||
|
||||
foreach($inputs as $variation =>$timezone) {
|
||||
echo "\n-- $variation --\n";
|
||||
try {
|
||||
var_dump( new DateTimezone($timezone) );
|
||||
} catch (Throwable $e) {
|
||||
$msg = $e->getMessage();
|
||||
echo "FAILED: " . $msg . "\n";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
*** Testing DateTime::__construct() : usage variation - unexpected values to first argument $timezone***
|
||||
|
||||
-- int 0 --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone (0)
|
||||
|
||||
-- int 1 --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone (1)
|
||||
|
||||
-- int 12345 --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone (12345)
|
||||
|
||||
-- float 10.5 --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone (10.5)
|
||||
|
||||
-- float .5 --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone (0.5)
|
||||
|
||||
-- empty array --
|
||||
FAILED: DateTimeZone::__construct() expects parameter 1 to be string, array given
|
||||
|
||||
-- int indexed array --
|
||||
FAILED: DateTimeZone::__construct() expects parameter 1 to be string, array given
|
||||
|
||||
-- associative array --
|
||||
FAILED: DateTimeZone::__construct() expects parameter 1 to be string, array given
|
||||
|
||||
-- nested arrays --
|
||||
FAILED: DateTimeZone::__construct() expects parameter 1 to be string, array given
|
||||
|
||||
-- uppercase NULL --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone ()
|
||||
|
||||
-- lowercase null --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone ()
|
||||
|
||||
-- lowercase true --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone (1)
|
||||
|
||||
-- lowercase false --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone ()
|
||||
|
||||
-- uppercase TRUE --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone (1)
|
||||
|
||||
-- uppercase FALSE --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone ()
|
||||
|
||||
-- empty string DQ --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone ()
|
||||
|
||||
-- empty string SQ --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone ()
|
||||
|
||||
-- string DQ --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone (string)
|
||||
|
||||
-- string SQ --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone (string)
|
||||
|
||||
-- mixed case string --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone (sTrInG)
|
||||
|
||||
-- heredoc --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone (hello world)
|
||||
|
||||
-- instance of classWithToString --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone (Class A object)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
FAILED: DateTimeZone::__construct() expects parameter 1 to be string, object given
|
||||
|
||||
-- undefined var --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone ()
|
||||
|
||||
-- unset var --
|
||||
FAILED: DateTimeZone::__construct(): Unknown or bad timezone ()
|
||||
|
||||
-- resource --
|
||||
FAILED: DateTimeZone::__construct() expects parameter 1 to be string, resource given
|
||||
===DONE===
|
@ -1,252 +0,0 @@
|
||||
--TEST--
|
||||
Test DateTimeZone::getOffset() function : usage variation - Passing unexpected values to first argument $datetime.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int DateTimeZone::getOffset ( DateTime $datetime )
|
||||
* Description: Returns the timezone offset from GMT
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: timezone_offset_get()
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTimeZone::getOffset() : usage variation - unexpected values to first argument \$datetime***\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 =>$datetime) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( $timezone->getOffset($datetime) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTimeZone::getOffset() : usage variation - unexpected values to first argument $datetime***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,377 +0,0 @@
|
||||
--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 (Throwable $e) {
|
||||
$msg = $e->getMessage();
|
||||
echo "FAILED: " . $msg . "\n";
|
||||
}
|
||||
|
||||
try {
|
||||
var_dump( new DateTime($time, $timezone) );
|
||||
} catch (Throwable $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) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(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) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be string, array given
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be string, array given
|
||||
|
||||
-- int indexed array --
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be string, array given
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be string, array given
|
||||
|
||||
-- associative array --
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be string, array given
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be string, array given
|
||||
|
||||
-- nested arrays --
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be string, array given
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be string, array given
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(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)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(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)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string SQ --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(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 string, object given
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be string, object given
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be string, resource given
|
||||
FAILED: DateTime::__construct() expects parameter 1 to be string, resource given
|
||||
===DONE===
|
@ -1,231 +0,0 @@
|
||||
--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 (Throwable $e) {
|
||||
$msg = $e->getMessage();
|
||||
echo "FAILED: " . $msg . "\n";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing new DateTime() : usage variation - unexpected values to second argument $timezone***
|
||||
|
||||
-- int 0 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, int given
|
||||
|
||||
-- int 1 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, int given
|
||||
|
||||
-- int 12345 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, int given
|
||||
|
||||
-- int -12345 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, int given
|
||||
|
||||
-- float 10.5 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, float given
|
||||
|
||||
-- float -10.5 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, float given
|
||||
|
||||
-- float .5 --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, float 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 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2005-07-14 22:30:41.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2005-07-14 22:30:41.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, bool given
|
||||
|
||||
-- lowercase false --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, bool given
|
||||
|
||||
-- uppercase TRUE --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, bool given
|
||||
|
||||
-- uppercase FALSE --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, bool given
|
||||
|
||||
-- empty string DQ --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, string given
|
||||
|
||||
-- empty string SQ --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, string given
|
||||
|
||||
-- string DQ --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, string given
|
||||
|
||||
-- string SQ --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, string given
|
||||
|
||||
-- mixed case string --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, string given
|
||||
|
||||
-- heredoc --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, 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 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2005-07-14 22:30:41.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2005-07-14 22:30:41.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, resource given
|
||||
===DONE===
|
@ -1,208 +0,0 @@
|
||||
--TEST--
|
||||
Test DateTime::format() function : usage variation - Passing unexpected values to first argument $format.
|
||||
--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
|
||||
*/
|
||||
|
||||
echo "*** Testing DateTime::format() : usage variation - unexpected values to first argument \$format***\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("2005-07-14 22:30:41");
|
||||
|
||||
foreach($inputs as $variation =>$format) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( $object->format($format) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing DateTime::format() : usage variation - unexpected values to first argument $format***
|
||||
|
||||
-- int 0 --
|
||||
string(1) "0"
|
||||
|
||||
-- int 1 --
|
||||
string(1) "1"
|
||||
|
||||
-- int 12345 --
|
||||
string(5) "12345"
|
||||
|
||||
-- int -12345 --
|
||||
string(6) "-12345"
|
||||
|
||||
-- float 10.5 --
|
||||
string(4) "10.5"
|
||||
|
||||
-- float -10.5 --
|
||||
string(5) "-10.5"
|
||||
|
||||
-- float .5 --
|
||||
string(3) "0.5"
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::format() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::format() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::format() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::format() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
string(0) ""
|
||||
|
||||
-- lowercase null --
|
||||
string(0) ""
|
||||
|
||||
-- lowercase true --
|
||||
string(1) "1"
|
||||
|
||||
-- lowercase false --
|
||||
string(0) ""
|
||||
|
||||
-- uppercase TRUE --
|
||||
string(1) "1"
|
||||
|
||||
-- uppercase FALSE --
|
||||
string(0) ""
|
||||
|
||||
-- empty string DQ --
|
||||
string(0) ""
|
||||
|
||||
-- empty string SQ --
|
||||
string(0) ""
|
||||
|
||||
-- string DQ --
|
||||
string(40) "4131Thu, 14 Jul 2005 22:30:41 +010030710"
|
||||
|
||||
-- string SQ --
|
||||
string(40) "4131Thu, 14 Jul 2005 22:30:41 +010030710"
|
||||
|
||||
-- mixed case string --
|
||||
string(40) "41BSTThu, 14 Jul 2005 22:30:41 +01001722"
|
||||
|
||||
-- heredoc --
|
||||
string(82) "10Europe/LondonThursdayThursday2005 42005Thu, 14 Jul 2005 22:30:41 +0100Thursday14"
|
||||
|
||||
-- instance of classWithToString --
|
||||
string(66) "CThursdaypm4141 PM 2005b14Europe/London2005-07-14T22:30:41+01:0031"
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::format() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
string(0) ""
|
||||
|
||||
-- unset var --
|
||||
string(0) ""
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::format() expects parameter 1 to be string, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,262 +0,0 @@
|
||||
--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 --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string (0) at position 0 (0): Unexpected character in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string (12345) at position 4 (5): Unexpected character in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string (-12345) at position 5 (5): Unexpected character in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#3 (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:05:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string (-10.5) at position 4 (5): Unexpected character in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#3 (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 00:05:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::modify() expects parameter 1 to be string, array given in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::modify() expects parameter 1 to be string, array given in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::modify() expects parameter 1 to be string, array given in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::modify() expects parameter 1 to be string, array given in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string (sTrInG) at position 0 (s): The timezone could not be found in the database in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string (hello world) at position 0 (h): The timezone could not be found in the database in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string (Class A object) at position 0 (C): The timezone could not be found in the database in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::modify() expects parameter 1 to be string, object given in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::modify() expects parameter 1 to be string, resource given in %sDateTime_modify_variation1.php on line 99
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--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) {
|
||||
["date"]=>
|
||||
string(26) "0000-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0001-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(27) "12345-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(28) "-12345-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0010-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(27) "-0010-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0001-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0001-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 1 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--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) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2991-09-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0934-03-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-10-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-02-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 2 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--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) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-07-01 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1997-04-17 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1929-09-11 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-07-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-20 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-07-01 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-07-01 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setDate() expects parameter 3 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--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) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0001-02-13 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(27) "12345-02-13 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(28) "-12345-02-11 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0010-02-16 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(27) "-0010-02-14 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0001-02-13 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0001-02-13 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 1 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--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) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-01 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2199-07-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1726-05-21 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-03-05 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-10-16 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-01 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-01 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 2 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--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) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-11 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1996-11-28 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1929-04-24 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-20 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-31 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-11 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-11 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setISODate() expects parameter 3 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--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) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 01:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2010-06-29 09:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 15:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 14:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 01:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 01:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 1 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--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) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:01:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-02-08 23:45:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 20:15:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:10:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 09:50:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:01:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:01:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 2 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--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) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:01.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 13:38:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 06:47:15.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:12:50.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:01.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:01.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: DateTime::setTime() expects parameter 3 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,252 +0,0 @@
|
||||
--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, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, float 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, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, 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===
|
@ -1,201 +0,0 @@
|
||||
--TEST--
|
||||
Test checkdate() function : usage variation - Passing unexpected values to first argument $month.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool checkdate ( int $month , int $day , int $year )
|
||||
* Description: Checks the validity of the date formed by the arguments.
|
||||
* A date is considered valid if each parameter is properly defined.
|
||||
* Source code: ext/date/php_date.c
|
||||
*/
|
||||
|
||||
echo "*** Testing checkdate() : usage variation - unexpected values to first argument \$month***\n";
|
||||
|
||||
//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(
|
||||
// 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
|
||||
);
|
||||
|
||||
$day = 2;
|
||||
$year = 1963;
|
||||
|
||||
foreach($inputs as $variation =>$month) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( checkdate($month, $day, $year) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing checkdate() : usage variation - unexpected values to first argument $month***
|
||||
|
||||
-- float 10.5 --
|
||||
bool(true)
|
||||
|
||||
-- float -10.5 --
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: checkdate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: checkdate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: checkdate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: checkdate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
bool(true)
|
||||
|
||||
-- lowercase false --
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
bool(true)
|
||||
|
||||
-- uppercase FALSE --
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: checkdate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: checkdate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: checkdate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: checkdate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: checkdate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: checkdate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: checkdate() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: checkdate() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: checkdate() expects parameter 1 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,201 +0,0 @@
|
||||
--TEST--
|
||||
Test checkdate() function : usage variation - Passing unexpected values to second argument $day.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool checkdate ( int $month , int $day , int $year )
|
||||
* Description: Checks the validity of the date formed by the arguments.
|
||||
* A date is considered valid if each parameter is properly defined.
|
||||
* Source code: ext/date/php_date.c
|
||||
*/
|
||||
|
||||
echo "*** Testing checkdate() : usage variation - unexpected values to second argument \$day***\n";
|
||||
|
||||
//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(
|
||||
// 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
|
||||
);
|
||||
|
||||
$month = 7;
|
||||
$year = 1963;
|
||||
|
||||
foreach($inputs as $variation =>$day) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( checkdate($month, $day, $year) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing checkdate() : usage variation - unexpected values to second argument $day***
|
||||
|
||||
-- float 10.5 --
|
||||
bool(true)
|
||||
|
||||
-- float -10.5 --
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: checkdate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: checkdate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: checkdate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: checkdate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
bool(true)
|
||||
|
||||
-- lowercase false --
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
bool(true)
|
||||
|
||||
-- uppercase FALSE --
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: checkdate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: checkdate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: checkdate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: checkdate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: checkdate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: checkdate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: checkdate() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: checkdate() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: checkdate() expects parameter 2 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,201 +0,0 @@
|
||||
--TEST--
|
||||
Test checkdate() function : usage variation - Passing unexpected values to third argument $year.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool checkdate ( int $month , int $day , int $year )
|
||||
* Description: Checks the validity of the date formed by the arguments.
|
||||
* A date is considered valid if each parameter is properly defined.
|
||||
* Source code: ext/date/php_date.c
|
||||
*/
|
||||
|
||||
echo "*** Testing checkdate() : usage variation - unexpected values to third argument \$year***\n";
|
||||
|
||||
//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(
|
||||
// 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
|
||||
);
|
||||
|
||||
$day = 2;
|
||||
$month = 7;
|
||||
|
||||
foreach($inputs as $variation =>$year) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( checkdate($month, $day, $year) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing checkdate() : usage variation - unexpected values to third argument $year***
|
||||
|
||||
-- float 10.5 --
|
||||
bool(true)
|
||||
|
||||
-- float -10.5 --
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: checkdate() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: checkdate() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: checkdate() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: checkdate() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
bool(true)
|
||||
|
||||
-- lowercase false --
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
bool(true)
|
||||
|
||||
-- uppercase FALSE --
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: checkdate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: checkdate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: checkdate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: checkdate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: checkdate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: checkdate() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: checkdate() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: checkdate() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: checkdate() expects parameter 3 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,389 +0,0 @@
|
||||
--TEST--
|
||||
Test date_create() function : usage variation - Passing unexpected values to first argument $time.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_create ([ string $time [, DateTimeZone $timezone ]] )
|
||||
* Description: Returns new DateTime object
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTime::__construct
|
||||
*/
|
||||
|
||||
echo "*** Testing date_create() : 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";
|
||||
var_dump( date_create($time) );
|
||||
var_dump( date_create($time, $timezone) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_create() : usage variation - unexpected values to first argument $time***
|
||||
|
||||
-- int 0 --
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_create() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_create() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_create() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_create() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_create() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_create() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_create() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_create() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string SQ --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- string DQ --
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_create() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_create() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_create() expects parameter 1 to be string, resource given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_create() expects parameter 1 to be string, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,272 +0,0 @@
|
||||
--TEST--
|
||||
Test date_create() function : usage variation - Passing unexpected values to second argument $timezone.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_create ([ string $time [, DateTimeZone $timezone ]] )
|
||||
* Description: Returns new DateTime object
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTime::__construct
|
||||
*/
|
||||
|
||||
echo "*** Testing date_create() : 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";
|
||||
var_dump( date_create($time, $timezone) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_create() : usage variation - unexpected values to second argument $timezone***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2005-07-14 22:30:41.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2005-07-14 22:30:41.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2005-07-14 22:30:41.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2005-07-14 22:30:41.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_create() expects parameter 2 to be DateTimeZone, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,254 +0,0 @@
|
||||
--TEST--
|
||||
Test date_date_set() function : usage variation - Passing unexpected values to first argument $object.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_date_set ( DateTime $object , 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: DateTime::setDate
|
||||
*/
|
||||
|
||||
echo "*** Testing date_date_set() : usage variation - unexpected values to first argument \$object***\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
|
||||
);
|
||||
|
||||
$day = 2;
|
||||
$month = 7;
|
||||
$year = 1963;
|
||||
|
||||
foreach($inputs as $variation =>$object) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_date_set($object, $year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_date_set() : usage variation - unexpected values to first argument $object***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_date_set() expects parameter 1 to be DateTime, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--TEST--
|
||||
Test date_date_set() function : usage variation - Passing unexpected values to second argument $year.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_date_set ( DateTime $object , 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: DateTime::setDate
|
||||
*/
|
||||
|
||||
echo "*** Testing date_date_set() : usage variation - unexpected values to second 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 = date_create("2009-02-27 08:34:10");
|
||||
$day = 2;
|
||||
$month = 7;
|
||||
|
||||
foreach($inputs as $variation =>$year) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_date_set($object, $year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_date_set() : usage variation - unexpected values to second argument $year***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(%d) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0001-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(27) "12345-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(28) "-12345-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0010-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(27) "-0010-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(%d) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_date_set() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_date_set() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_date_set() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_date_set() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(%d) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(%d) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0001-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(%d) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0001-07-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(%d) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_date_set() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_date_set() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_date_set() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_date_set() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(%d) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(%d) "%s"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_date_set() expects parameter 2 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--TEST--
|
||||
Test date_date_set() function : usage variation - Passing unexpected values to third argument $month.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_date_set ( DateTime $object , 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: DateTime::setDate
|
||||
*/
|
||||
|
||||
echo "*** Testing date_date_set() : usage variation - unexpected values to third 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 = date_create("2009-02-27 08:34:10");
|
||||
$day = 2;
|
||||
$year = 1963;
|
||||
|
||||
foreach($inputs as $variation =>$month) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_date_set($object, $year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_date_set() : usage variation - unexpected values to third argument $month***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2991-09-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0934-03-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-10-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-02-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_date_set() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_date_set() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_date_set() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_date_set() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_date_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_date_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_date_set() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_date_set() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-02 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_date_set() expects parameter 3 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--TEST--
|
||||
Test date_date_set() function : usage variation - Passing unexpected values to forth argument $day.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_date_set ( DateTime $object , 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: DateTime::setDate
|
||||
*/
|
||||
|
||||
echo "*** Testing date_date_set() : usage variation - unexpected values to forth 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");
|
||||
$month = 7;
|
||||
$year = 1963;
|
||||
|
||||
foreach($inputs as $variation =>$day) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_date_set($object, $year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_date_set() : usage variation - unexpected values to forth argument $day***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-07-01 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1997-04-17 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1929-09-11 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-07-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-20 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_date_set() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_date_set() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_date_set() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_date_set() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-07-01 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-07-01 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_date_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_date_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_date_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_date_set() expects parameter 4 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_date_set() expects parameter 4 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-06-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_date_set() expects parameter 4 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,200 +0,0 @@
|
||||
--TEST--
|
||||
Test date_default_timezone_set() function : usage variations - Passing unexpected values for time_zone identifier
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool date_default_timezone_set ( string $timezone_identifier )
|
||||
* Description: Sets the default timezone used by all date/time functions in a script.
|
||||
* Source code: ext/standard/data/php_date.c
|
||||
*/
|
||||
|
||||
echo "*** Testing date_default_timezone_set() : usage variations ***\n";
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
abc
|
||||
xyz
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
$inputs = array(
|
||||
// int data
|
||||
/*1*/ 0,
|
||||
1,
|
||||
12345,
|
||||
-2345,
|
||||
|
||||
// float data
|
||||
/*5*/ 10.5,
|
||||
-10.5,
|
||||
12.3456789000e10,
|
||||
12.3456789000E-10,
|
||||
.5,
|
||||
|
||||
// null data
|
||||
/*10*/ NULL,
|
||||
null,
|
||||
|
||||
// boolean data
|
||||
/*12*/ true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// empty data
|
||||
/*16*/ "",
|
||||
'',
|
||||
array(),
|
||||
|
||||
// string data
|
||||
/*19*/ "abcxyz",
|
||||
'abcxyz',
|
||||
$heredoc,
|
||||
|
||||
// undefined data
|
||||
/*22*/ @$undefined_var,
|
||||
|
||||
// unset data
|
||||
/*23*/ @$unset_var,
|
||||
|
||||
// resource variable
|
||||
/*24*/ $fp
|
||||
);
|
||||
|
||||
// loop through each element of $inputs to check the behaviour of date_default_timezone_set()
|
||||
$iterator = 1;
|
||||
foreach($inputs as $input) {
|
||||
echo "\n-- Iteration $iterator --\n";
|
||||
var_dump(date_default_timezone_set($input));
|
||||
$iterator++;
|
||||
};
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing date_default_timezone_set() : usage variations ***
|
||||
|
||||
-- Iteration 1 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '0' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 2 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '1' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 3 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '12345' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 4 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '-2345' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 5 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '10.5' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 6 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '-10.5' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 7 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '123456789000' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 8 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '1.23456789E-9' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 9 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '0.5' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 10 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 11 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 12 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '1' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 13 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 14 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '1' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 15 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 16 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 17 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 18 --
|
||||
|
||||
Warning: date_default_timezone_set() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 19 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID 'abcxyz' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 20 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID 'abcxyz' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 21 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID 'abc
|
||||
xyz' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 22 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 23 --
|
||||
|
||||
Notice: date_default_timezone_set(): Timezone ID '' is invalid in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 24 --
|
||||
|
||||
Warning: date_default_timezone_set() expects parameter 1 to be string, resource given in %s on line %d
|
||||
bool(false)
|
||||
===Done===
|
@ -1,252 +0,0 @@
|
||||
--TEST--
|
||||
Test date_format() function : usage variation - Passing unexpected values to first argument $object.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string date_format ( DateTimeInterface $object , string $format )
|
||||
* Description: Returns date formatted according to given format
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTimeInterface::format
|
||||
*/
|
||||
|
||||
echo "*** Testing date_format() : usage variation - unexpected values to first argument \$object***\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
|
||||
);
|
||||
|
||||
$format = 'H:m:s \m \i\s\ \m\o\n\t\h';
|
||||
|
||||
foreach($inputs as $variation =>$object) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_format($object, $format) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_format() : usage variation - unexpected values to first argument $object***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_format() expects parameter 1 to be DateTimeInterface, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,208 +0,0 @@
|
||||
--TEST--
|
||||
Test date_format() function : usage variation - Passing unexpected values to second argument $format.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string date_format ( DateTime $object , string $format )
|
||||
* Description: Returns date formatted according to given format
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTime::format
|
||||
*/
|
||||
|
||||
echo "*** Testing date_format() : usage variation - unexpected values to second argument \$format***\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("2005-07-14 22:30:41");
|
||||
|
||||
foreach($inputs as $variation =>$format) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_format($object, $format) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_format() : usage variation - unexpected values to second argument $format***
|
||||
|
||||
-- int 0 --
|
||||
string(1) "0"
|
||||
|
||||
-- int 1 --
|
||||
string(1) "1"
|
||||
|
||||
-- int 12345 --
|
||||
string(5) "12345"
|
||||
|
||||
-- int -12345 --
|
||||
string(6) "-12345"
|
||||
|
||||
-- float 10.5 --
|
||||
string(4) "10.5"
|
||||
|
||||
-- float -10.5 --
|
||||
string(5) "-10.5"
|
||||
|
||||
-- float .5 --
|
||||
string(3) "0.5"
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_format() expects parameter 2 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_format() expects parameter 2 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_format() expects parameter 2 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_format() expects parameter 2 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
string(0) ""
|
||||
|
||||
-- lowercase null --
|
||||
string(0) ""
|
||||
|
||||
-- lowercase true --
|
||||
string(1) "1"
|
||||
|
||||
-- lowercase false --
|
||||
string(0) ""
|
||||
|
||||
-- uppercase TRUE --
|
||||
string(1) "1"
|
||||
|
||||
-- uppercase FALSE --
|
||||
string(0) ""
|
||||
|
||||
-- empty string DQ --
|
||||
string(0) ""
|
||||
|
||||
-- empty string SQ --
|
||||
string(0) ""
|
||||
|
||||
-- string DQ --
|
||||
string(40) "4131Thu, 14 Jul 2005 22:30:41 +010030710"
|
||||
|
||||
-- string SQ --
|
||||
string(40) "4131Thu, 14 Jul 2005 22:30:41 +010030710"
|
||||
|
||||
-- mixed case string --
|
||||
string(40) "41BSTThu, 14 Jul 2005 22:30:41 +01001722"
|
||||
|
||||
-- heredoc --
|
||||
string(82) "10Europe/LondonThursdayThursday2005 42005Thu, 14 Jul 2005 22:30:41 +0100Thursday14"
|
||||
|
||||
-- instance of classWithToString --
|
||||
string(66) "CThursdaypm4141 PM 2005b14Europe/London2005-07-14T22:30:41+01:0031"
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_format() expects parameter 2 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
string(0) ""
|
||||
|
||||
-- unset var --
|
||||
string(0) ""
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_format() expects parameter 2 to be string, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,254 +0,0 @@
|
||||
--TEST--
|
||||
Test date_isodate_set() function : usage variation - Passing unexpected values to first argument $object.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_isodate_set ( DateTime $object , 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: DateTime::setISODate
|
||||
*/
|
||||
|
||||
echo "*** Testing date_isodate_set() : usage variation - unexpected values to first argument \$object***\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
|
||||
);
|
||||
|
||||
$day = 2;
|
||||
$month = 7;
|
||||
$year = 1963;
|
||||
|
||||
foreach($inputs as $variation =>$object) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_isodate_set($object, $year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_isodate_set() : usage variation - unexpected values to first argument $object***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 1 to be DateTime, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--TEST--
|
||||
Test date_isodate_set() function : usage variation - Passing unexpected values to second argument $year.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_isodate_set ( DateTime $object , 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: DateTime::setISODate
|
||||
*/
|
||||
|
||||
echo "*** Testing date_isodate_set() : usage variation - unexpected values to second 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 = date_create("2009-02-27 08:34:10");
|
||||
$day = 2;
|
||||
$month = 7;
|
||||
|
||||
foreach($inputs as $variation =>$year) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_isodate_set($object, $year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_isodate_set() : usage variation - unexpected values to second argument $year***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0001-02-13 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(27) "12345-02-13 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(28) "-12345-02-11 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0010-02-16 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(27) "-0010-02-14 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0001-02-13 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0001-02-13 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "0000-02-15 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 2 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--TEST--
|
||||
Test date_isodate_set() function : usage variation - Passing unexpected values to third argument $week.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_isodate_set ( DateTime $object , 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: DateTime::setISODate
|
||||
*/
|
||||
|
||||
echo "*** Testing date_isodate_set() : usage variation - unexpected values to third 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( date_isodate_set($object, $year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_isodate_set() : usage variation - unexpected values to third argument $week***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-01 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2199-07-30 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1726-05-21 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-03-05 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-10-16 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-01 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-01 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1962-12-25 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 3 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--TEST--
|
||||
Test date_isodate_set() function : usage variation - Passing unexpected values to forth argument $day.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_isodate_set ( DateTime $object , 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: DateTime::setISODate
|
||||
*/
|
||||
|
||||
echo "*** Testing date_isodate_set() : usage variation - unexpected values to forth 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( date_isodate_set($object, $year, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_isodate_set() : usage variation - unexpected values to forth argument $day***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-11 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1996-11-28 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1929-04-24 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-20 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-01-31 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-11 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-11 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 4 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 4 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "1963-02-10 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_isodate_set() expects parameter 4 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,252 +0,0 @@
|
||||
--TEST--
|
||||
Test date_modify() function : usage variation - Passing unexpected values to first argument $object.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_modify ( DateTime $object , 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 DateTime DateTime::modify()
|
||||
*/
|
||||
|
||||
echo "*** Testing date_modify() : usage variation - unexpected values to first argument \$object***\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
|
||||
);
|
||||
|
||||
$format = "D, d M Y";
|
||||
|
||||
foreach($inputs as $variation =>$object) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_modify($object, $format) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_modify() : usage variation - unexpected values to first argument $object***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_modify() expects parameter 1 to be DateTime, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,262 +0,0 @@
|
||||
--TEST--
|
||||
Test date_modify() function : usage variation - Passing unexpected values to second argument $format.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_modify ( DateTime $object , 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 DateTime DateTime::modify()
|
||||
*/
|
||||
|
||||
echo "*** Testing date_modify() : usage variation - unexpected values to second argument \$format***\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-01-31 14:28:41");
|
||||
|
||||
foreach($inputs as $variation =>$format) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_modify($object, $format) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_modify() : usage variation - unexpected values to second argument $format***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string (0) at position 0 (0): Unexpected character in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string (12345) at position 4 (5): Unexpected character in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string (-12345) at position 5 (5): Unexpected character in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:05:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string (-10.5) at position 4 (5): Unexpected character in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 00:05:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_modify() expects parameter 2 to be string, array given in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_modify() expects parameter 2 to be string, array given in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_modify() expects parameter 2 to be string, array given in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_modify() expects parameter 2 to be string, array given in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string () at position 0 ( in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string () at position 0 ( in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string () at position 0 ( in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string () at position 0 ( in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string () at position 0 ( in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string () at position 0 ( in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string (sTrInG) at position 0 (s): The timezone could not be found in the database in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string (hello world) at position 0 (h): The timezone could not be found in the database in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string (Class A object) at position 0 (C): The timezone could not be found in the database in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_modify() expects parameter 2 to be string, object given in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string () at position 0 ( in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: date_modify(): Failed to parse time string () at position 0 ( in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_modify() expects parameter 2 to be string, resource given in %sdate_modify_variation2.php on line 99
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,250 +0,0 @@
|
||||
--TEST--
|
||||
Test date_offset_get() function : usage variation - Passing unexpected values to first argument $object.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int date_offset_get ( DateTimeInterface $object )
|
||||
* Description: Returns the daylight saving time offset
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTimeInterface::getOffset
|
||||
*/
|
||||
|
||||
echo "*** Testing date_offset_get() : usage variation - unexpected values to first argument \$object***\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
|
||||
);
|
||||
|
||||
foreach($inputs as $variation =>$object) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_offset_get($object) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_offset_get() : usage variation - unexpected values to first argument $object***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,274 +0,0 @@
|
||||
--TEST--
|
||||
Test date_parse() function : usage variation - Passing unexpected values to first argument $date.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : array date_parse ( string $date )
|
||||
* Description: Returns associative array with detailed info about given date.
|
||||
* Source code: ext/date/php_date.c
|
||||
*/
|
||||
|
||||
echo "*** Testing date_parse() : usage variation - unexpected values to first argument \$date***\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
|
||||
);
|
||||
|
||||
foreach($inputs as $variation =>$date) {
|
||||
echo "\n-- $variation --\n";
|
||||
$result = date_parse($date);
|
||||
if (is_array($result)) {
|
||||
var_dump($result["errors"]);
|
||||
} else {
|
||||
var_dump($result);
|
||||
}
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_parse() : usage variation - unexpected values to first argument $date***
|
||||
|
||||
-- int 0 --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(20) "Unexpected character"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(20) "Unexpected character"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
array(1) {
|
||||
[4]=>
|
||||
string(20) "Unexpected character"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
array(1) {
|
||||
[5]=>
|
||||
string(20) "Unexpected character"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
array(0) {
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
array(1) {
|
||||
[4]=>
|
||||
string(20) "Unexpected character"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
array(0) {
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_parse() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_parse() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_parse() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_parse() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(12) "Empty string"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(12) "Empty string"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(20) "Unexpected character"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(12) "Empty string"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(20) "Unexpected character"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(12) "Empty string"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(12) "Empty string"
|
||||
}
|
||||
|
||||
-- empty string SQ --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(12) "Empty string"
|
||||
}
|
||||
|
||||
-- string DQ --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(47) "The timezone could not be found in the database"
|
||||
}
|
||||
|
||||
-- string SQ --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(47) "The timezone could not be found in the database"
|
||||
}
|
||||
|
||||
-- mixed case string --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(47) "The timezone could not be found in the database"
|
||||
}
|
||||
|
||||
-- heredoc --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(47) "The timezone could not be found in the database"
|
||||
}
|
||||
|
||||
-- instance of classWithToString --
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(47) "The timezone could not be found in the database"
|
||||
[8]=>
|
||||
string(29) "Double timezone specification"
|
||||
}
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_parse() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(12) "Empty string"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(12) "Empty string"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_parse() expects parameter 1 to be string, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,492 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sun_info() function : error variations - Pass unexpected values for time argument
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : array date_sun_info ( int $time , float $latitude , float $longitude )
|
||||
* Description: Returns an array with information about sunset/sunrise and twilight begin/end.
|
||||
* Source code: ext/standard/data/php_date.c
|
||||
*/
|
||||
|
||||
date_default_timezone_set("UTC");
|
||||
|
||||
echo "*** Testing date_sun_info() : usage variations ***\n";
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
abc
|
||||
xyz
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
$inputs = array(
|
||||
// int data
|
||||
/*1*/ 0,
|
||||
1,
|
||||
12345,
|
||||
-2345,
|
||||
|
||||
// float data
|
||||
/*5*/ 10.5,
|
||||
-10.5,
|
||||
12.3456789000e5,
|
||||
12.3456789000E-5,
|
||||
.5,
|
||||
|
||||
// null data
|
||||
/*10*/ NULL,
|
||||
null,
|
||||
|
||||
// boolean data
|
||||
/*12*/ true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// empty data
|
||||
/*16*/ "",
|
||||
'',
|
||||
array(),
|
||||
|
||||
// string data
|
||||
/*19*/ "abcxyz",
|
||||
'abcxyz',
|
||||
$heredoc,
|
||||
|
||||
// undefined data
|
||||
/*22*/ @$undefined_var,
|
||||
|
||||
// unset data
|
||||
/*23*/ @$unset_var,
|
||||
|
||||
// resource variable
|
||||
/*24*/ $fp
|
||||
);
|
||||
|
||||
// loop through each element of $inputs to check the behaviour of date_sun_info()
|
||||
$iterator = 1;
|
||||
foreach($inputs as $input) {
|
||||
echo "\n-- Iteration $iterator --\n";
|
||||
var_dump(date_sun_info($input, 31.7667, 35.2333));
|
||||
$iterator++;
|
||||
};
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing date_sun_info() : usage variations ***
|
||||
|
||||
-- Iteration 1 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 2 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 3 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 4 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(-69672)
|
||||
["sunset"]=>
|
||||
int(-33281)
|
||||
["transit"]=>
|
||||
int(-51476)
|
||||
["civil_twilight_begin"]=>
|
||||
int(-71277)
|
||||
["civil_twilight_end"]=>
|
||||
int(-31675)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(-73100)
|
||||
["nautical_twilight_end"]=>
|
||||
int(-29852)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(-74883)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(-28069)
|
||||
}
|
||||
|
||||
-- Iteration 5 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 6 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(-69672)
|
||||
["sunset"]=>
|
||||
int(-33281)
|
||||
["transit"]=>
|
||||
int(-51476)
|
||||
["civil_twilight_begin"]=>
|
||||
int(-71277)
|
||||
["civil_twilight_end"]=>
|
||||
int(-31675)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(-73100)
|
||||
["nautical_twilight_end"]=>
|
||||
int(-29852)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(-74883)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(-28069)
|
||||
}
|
||||
|
||||
-- Iteration 7 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1226368)
|
||||
["sunset"]=>
|
||||
int(1263442)
|
||||
["transit"]=>
|
||||
int(1244905)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1224792)
|
||||
["civil_twilight_end"]=>
|
||||
int(1265019)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1222996)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1266815)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1221234)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1268576)
|
||||
}
|
||||
|
||||
-- Iteration 8 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 9 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 10 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 11 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 12 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 13 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 14 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 15 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 16 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 17 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 18 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 19 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 20 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 21 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 22 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 23 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 24 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 1 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===Done===
|
@ -1,492 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sun_info() function : error variations - Pass unexpected values for latitude argument
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : array date_sun_info ( int $time , float $latitude , float $longitude )
|
||||
* Description: Returns an array with information about sunset/sunrise and twilight begin/end.
|
||||
* Source code: ext/standard/data/php_date.c
|
||||
*/
|
||||
|
||||
date_default_timezone_set("UTC");
|
||||
|
||||
echo "*** Testing date_sun_info() : usage variations ***\n";
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
abc
|
||||
xyz
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
$inputs = array(
|
||||
// int data
|
||||
/*1*/ 0,
|
||||
1,
|
||||
12345,
|
||||
-2345,
|
||||
|
||||
// float data
|
||||
/*5*/ 10.5,
|
||||
-10.5,
|
||||
12.3456789000e10,
|
||||
12.3456789000E-10,
|
||||
.5,
|
||||
|
||||
// null data
|
||||
/*10*/ NULL,
|
||||
null,
|
||||
|
||||
// boolean data
|
||||
/*12*/ true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// empty data
|
||||
/*16*/ "",
|
||||
'',
|
||||
array(),
|
||||
|
||||
// string data
|
||||
/*19*/ "abcxyz",
|
||||
'abcxyz',
|
||||
$heredoc,
|
||||
|
||||
// undefined data
|
||||
/*22*/ @$undefined_var,
|
||||
|
||||
// unset data
|
||||
/*23*/ @$unset_var,
|
||||
|
||||
// resource variable
|
||||
/*24*/ $fp
|
||||
);
|
||||
|
||||
// loop through each element of $inputs to check the behaviour of date_sun_info()
|
||||
$iterator = 1;
|
||||
foreach($inputs as $input) {
|
||||
echo "\n-- Iteration $iterator --\n";
|
||||
var_dump(date_sun_info(strtotime("2006-12-12"), $input, 35.2333));
|
||||
$iterator++;
|
||||
};
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing date_sun_info() : usage variations ***
|
||||
|
||||
-- Iteration 1 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 2 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894240)
|
||||
["sunset"]=>
|
||||
int(1165937681)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892898)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939024)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891330)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940591)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889758)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942164)
|
||||
}
|
||||
|
||||
-- Iteration 3 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
bool(true)
|
||||
["sunset"]=>
|
||||
bool(true)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
bool(true)
|
||||
["civil_twilight_end"]=>
|
||||
bool(true)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165883368)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165948554)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165890281)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165941641)
|
||||
}
|
||||
|
||||
-- Iteration 4 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894072)
|
||||
["sunset"]=>
|
||||
int(1165937850)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165895418)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165936504)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165896984)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165934938)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165898549)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165933372)
|
||||
}
|
||||
|
||||
-- Iteration 5 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165895221)
|
||||
["sunset"]=>
|
||||
int(1165936701)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165893858)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165938064)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165892278)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165939643)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165890706)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165941215)
|
||||
}
|
||||
|
||||
-- Iteration 6 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165893046)
|
||||
["sunset"]=>
|
||||
int(1165938875)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165891669)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165940253)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165890044)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165941878)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165888392)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165943530)
|
||||
}
|
||||
|
||||
-- Iteration 7 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 8 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 9 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894189)
|
||||
["sunset"]=>
|
||||
int(1165937733)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892846)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939075)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891278)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940643)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889704)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942217)
|
||||
}
|
||||
|
||||
-- Iteration 10 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 11 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 12 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894240)
|
||||
["sunset"]=>
|
||||
int(1165937681)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892898)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939024)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891330)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940591)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889758)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942164)
|
||||
}
|
||||
|
||||
-- Iteration 13 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 14 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894240)
|
||||
["sunset"]=>
|
||||
int(1165937681)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892898)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939024)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891330)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940591)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889758)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942164)
|
||||
}
|
||||
|
||||
-- Iteration 15 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 16 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 2 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 17 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 2 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 18 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 2 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 19 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 2 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 20 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 2 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 21 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 2 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 22 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 23 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 24 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 2 to be float, resource given in %s on line %d
|
||||
bool(false)
|
||||
===Done===
|
@ -1,493 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sun_info() function : usage variations - Pass unexpected values for longitude argument
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : array date_sun_info ( int $time , float $latitude , float $longitude )
|
||||
* Description: Returns an array with information about sunset/sunrise and twilight begin/end.
|
||||
* Source code: ext/standard/data/php_date.c
|
||||
*/
|
||||
|
||||
date_default_timezone_set("UTC");
|
||||
|
||||
echo "*** Testing date_sun_info() : usage variations ***\n";
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
abc
|
||||
xyz
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
$inputs = array(
|
||||
// int data
|
||||
/*1*/ 0,
|
||||
1,
|
||||
12345,
|
||||
-2345,
|
||||
|
||||
// float data
|
||||
/*5*/ 10.5,
|
||||
-10.5,
|
||||
12.3456789000e10,
|
||||
12.3456789000E-10,
|
||||
.5,
|
||||
|
||||
// null data
|
||||
/*10*/ NULL,
|
||||
null,
|
||||
|
||||
// boolean data
|
||||
/*12*/ true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// empty data
|
||||
/*16*/ "",
|
||||
'',
|
||||
array(),
|
||||
|
||||
// string data
|
||||
/*19*/ "abcxyz",
|
||||
'abcxyz',
|
||||
$heredoc,
|
||||
|
||||
// undefined data
|
||||
/*22*/ @$undefined_var,
|
||||
|
||||
// unset data
|
||||
/*23*/ @$unset_var,
|
||||
|
||||
// resource variable
|
||||
/*24*/ $fp
|
||||
);
|
||||
|
||||
// loop through each element of $inputs to check the behaviour of date_sun_info()
|
||||
$iterator = 1;
|
||||
|
||||
foreach($inputs as $input) {
|
||||
echo "\n-- Iteration $iterator --\n";
|
||||
var_dump(date_sun_info(strtotime("2006-12-12"), 31.7667, $input));
|
||||
$iterator++;
|
||||
};
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing date_sun_info() : usage variations ***
|
||||
|
||||
-- Iteration 1 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 2 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165905981)
|
||||
["sunset"]=>
|
||||
int(1165942378)
|
||||
["transit"]=>
|
||||
int(1165924179)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904376)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165943983)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902553)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165945806)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165900771)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947588)
|
||||
}
|
||||
|
||||
-- Iteration 3 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165879309)
|
||||
["sunset"]=>
|
||||
int(1165917937)
|
||||
["transit"]=>
|
||||
int(1165898623)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165877787)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165919460)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165876041)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165921205)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165874319)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165922928)
|
||||
}
|
||||
|
||||
-- Iteration 4 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165864467)
|
||||
["sunset"]=>
|
||||
int(1165900749)
|
||||
["transit"]=>
|
||||
int(1165882608)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165862856)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165902359)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165861029)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165904187)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165859242)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165905973)
|
||||
}
|
||||
|
||||
-- Iteration 5 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165903700)
|
||||
["sunset"]=>
|
||||
int(1165940097)
|
||||
["transit"]=>
|
||||
int(1165921899)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165902095)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165941702)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165900272)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165943525)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165898490)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165945308)
|
||||
}
|
||||
|
||||
-- Iteration 6 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165908743)
|
||||
["sunset"]=>
|
||||
int(1165945138)
|
||||
["transit"]=>
|
||||
int(1165926940)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165907137)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165946743)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165905315)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165948566)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165903532)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165950349)
|
||||
}
|
||||
|
||||
-- Iteration 7 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165920008)
|
||||
["sunset"]=>
|
||||
int(1165970177)
|
||||
["transit"]=>
|
||||
int(1165945092)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165918353)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165971832)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165916371)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165973814)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165914258)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165975927)
|
||||
}
|
||||
|
||||
-- Iteration 8 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 9 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906101)
|
||||
["sunset"]=>
|
||||
int(1165942498)
|
||||
["transit"]=>
|
||||
int(1165924300)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904496)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944103)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902673)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165945926)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165900891)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947708)
|
||||
}
|
||||
|
||||
-- Iteration 10 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 11 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 12 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165905981)
|
||||
["sunset"]=>
|
||||
int(1165942378)
|
||||
["transit"]=>
|
||||
int(1165924179)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904376)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165943983)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902553)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165945806)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165900771)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947588)
|
||||
}
|
||||
|
||||
-- Iteration 13 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 14 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165905981)
|
||||
["sunset"]=>
|
||||
int(1165942378)
|
||||
["transit"]=>
|
||||
int(1165924179)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904376)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165943983)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902553)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165945806)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165900771)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947588)
|
||||
}
|
||||
|
||||
-- Iteration 15 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 16 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 17 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 18 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 19 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 20 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 21 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Iteration 22 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 23 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 24 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 3 to be float, resource given in %s on line %d
|
||||
bool(false)
|
||||
===Done===
|
@ -1,316 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sunrise() function : usage variation - Passing unexpected values to first argument time.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed date_sunrise(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
|
||||
* Description: Returns time of sunrise for a given day and location
|
||||
* Source code: ext/date/php_date.c
|
||||
*/
|
||||
|
||||
echo "*** Testing date_sunrise() : usage variation ***\n";
|
||||
|
||||
//Initialise the variables
|
||||
$latitude = 38.4;
|
||||
$longitude = -9;
|
||||
$zenith = 90;
|
||||
$gmt_offset = 1;
|
||||
$format = SUNFUNCS_RET_STRING;
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
|
||||
//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);
|
||||
|
||||
//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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for time
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( date_sunrise($value, SUNFUNCS_RET_STRING, $latitude, $longitude, $zenith, $gmt_offset) );
|
||||
var_dump( date_sunrise($value, SUNFUNCS_RET_DOUBLE, $latitude, $longitude, $zenith, $gmt_offset) );
|
||||
var_dump( date_sunrise($value, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude, $zenith, $gmt_offset) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_sunrise() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--int 1--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--int 12345--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--int -12345--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--float 10.5--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--float -10.5--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--float .5--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--unset var--
|
||||
string(5) "08:56"
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
===DONE===
|
@ -1,213 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sunrise() function : usage variation - Passing unexpected values to second argument format.
|
||||
--SKIPIF--
|
||||
<?php if (PHP_INT_SIZE != 4) echo "skip this test is for 32-bit only"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed date_sunrise(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
|
||||
* Description: Returns time of sunrise for a given day and location
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing date_sunrise() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$time = mktime(8, 8, 8, 8, 8, 2008);
|
||||
$latitude = 38.4;
|
||||
$longitude = -9;
|
||||
$zenith = 90;
|
||||
$gmt_offset = 1;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for format
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( date_sunrise($time, $value, $latitude, $longitude, $zenith, $gmt_offset) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_sunrise() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
|
||||
Warning: date_sunrise(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
|
||||
Warning: date_sunrise(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
int(1218174468)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
int(1218174468)
|
||||
|
||||
--lowercase null--
|
||||
int(1218174468)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "06:47"
|
||||
|
||||
--lowercase false--
|
||||
int(1218174468)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "06:47"
|
||||
|
||||
--uppercase FALSE--
|
||||
int(1218174468)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: date_sunrise() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
int(1218174468)
|
||||
|
||||
--unset var--
|
||||
int(1218174468)
|
||||
===DONE===
|
@ -1,294 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sunrise() function : usage variation - Passing unexpected values to third argument latitude.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed date_sunrise(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
|
||||
* Description: Returns time of sunrise for a given day and location
|
||||
* Source code: ext/date/php_date.c
|
||||
*/
|
||||
|
||||
echo "*** Testing date_sunrise() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$time = mktime(8, 8, 8, 8, 8, 2008);
|
||||
$longitude = -9;
|
||||
$zenith = 90;
|
||||
$gmt_offset = -5.5;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for latitude
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $value, $longitude, $zenith, $gmt_offset) );
|
||||
var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, $value, $longitude, $zenith, $gmt_offset) );
|
||||
var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $value, $longitude, $zenith, $gmt_offset) );
|
||||
};
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_sunrise() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177629)
|
||||
|
||||
--int 1--
|
||||
string(5) "01:09"
|
||||
float(1.155%d)
|
||||
int(1218177560)
|
||||
|
||||
--int 12345--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177629)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177629)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "01:09"
|
||||
float(1.155%d)
|
||||
int(1218177560)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177629)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "01:09"
|
||||
float(1.155%d)
|
||||
int(1218177560)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177629)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 3 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177629)
|
||||
|
||||
--unset var--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177629)
|
||||
===DONE===
|
@ -1,296 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sunrise() function : usage variation - Passing unexpected values to fourth argument longitude.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed date_sunrise(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
|
||||
* Description: Returns time of sunrise for a given day and location
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing date_sunrise() : usage variation ***\n";
|
||||
|
||||
//Initialise the variables
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$time = mktime(8, 8, 8, 8, 8, 2008);
|
||||
$latitude = 38.4;
|
||||
$zenith = 90;
|
||||
$gmt_offset = 0;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for longitude
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $latitude, $value, $zenith, $gmt_offset) );
|
||||
var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, $latitude, $value, $zenith, $gmt_offset) );
|
||||
var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $value, $zenith, $gmt_offset) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_sunrise() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
|
||||
--int 1--
|
||||
string(5) "05:07"
|
||||
float(5.129%d)
|
||||
int(1218172067)
|
||||
|
||||
--int 12345--
|
||||
string(5) "21:45"
|
||||
float(21.757%d)
|
||||
int(1218145525)
|
||||
|
||||
--int -12345--
|
||||
string(5) "12:41"
|
||||
float(12.694%d)
|
||||
int(1218199301)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "05:07"
|
||||
float(5.129%d)
|
||||
int(1218172067)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "05:07"
|
||||
float(5.129%d)
|
||||
int(1218172067)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 4 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
|
||||
--unset var--
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
===DONE===
|
@ -1,296 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sunrise() function : usage variation - Passing unexpected values to fifth argument zenith
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed date_sunrise(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
|
||||
* Description: Returns time of sunrise for a given day and location
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing date_sunrise() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$time = mktime(8, 8, 8, 8, 8, 2008);
|
||||
$latitude = 38.4;
|
||||
$longitude = -9;
|
||||
$gmt_offset = 5.5;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -12345,
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for zenith
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $latitude, $longitude, $value, $gmt_offset) );
|
||||
var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, $latitude, $longitude, $value, $gmt_offset) );
|
||||
var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude, $value, $gmt_offset) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_sunrise() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
string(5) "09:50"
|
||||
float(9.849%d)
|
||||
int(1218169259)
|
||||
|
||||
--int -12345--
|
||||
string(5) "09:54"
|
||||
float(9.904%d)
|
||||
int(1218169455)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 5 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,295 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sunrise() function : usage variation - Passing unexpected values to sixth argument gmt_offset.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed date_sunrise(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
|
||||
* Description: Returns time of sunrise for a given day and location
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing date_sunrise() : usage variation ***\n";
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$time = mktime(8, 8, 8, 8, 8, 2008);
|
||||
$latitude = 38.4;
|
||||
$longitude = -9;
|
||||
$zenith = 90;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for gmt_offset
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $latitude, $longitude, $zenith, $value) );
|
||||
var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, $latitude, $longitude, $zenith, $value) );
|
||||
var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude, $zenith, $value) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_sunrise() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--int 1--
|
||||
string(5) "06:47"
|
||||
float(6.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--int 12345--
|
||||
string(5) "14:47"
|
||||
float(14.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--int -12345--
|
||||
string(5) "12:47"
|
||||
float(12.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "06:47"
|
||||
float(6.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "06:47"
|
||||
float(6.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunrise() expects parameter 6 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--unset var--
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
===DONE===
|
@ -1,316 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sunset() function : usage variation - Passing unexpected values to first argument time.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed date_sunset(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
|
||||
* Description: Returns time of sunset for a given day and location
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing date_sunset() : usage variation ***\n";
|
||||
|
||||
//Initialise the variables
|
||||
$latitude = 38.4;
|
||||
$longitude = -9;
|
||||
$zenith = 90;
|
||||
$gmt_offset = 1;
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for time
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( date_sunset($value, SUNFUNCS_RET_STRING, $latitude, $longitude, $zenith, $gmt_offset) );
|
||||
var_dump( date_sunset($value, SUNFUNCS_RET_DOUBLE, $latitude, $longitude, $zenith, $gmt_offset) );
|
||||
var_dump( date_sunset($value, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude, $zenith, $gmt_offset) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_sunset() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--int 1--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--int 12345--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--int -12345--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--float 10.5--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--float -10.5--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--float .5--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--unset var--
|
||||
string(5) "18:22"
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
===DONE===
|
@ -1,213 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sunset() function : usage variation - Passing unexpected values to second argument format.
|
||||
--SKIPIF--
|
||||
<?php if (PHP_INT_SIZE != 4) echo "skip this test is for 32-bit only"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed date_sunset(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
|
||||
* Description: Returns time of sunset for a given day and location
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing date_sunset() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$time = mktime(8, 8, 8, 8, 8, 2008);
|
||||
$latitude = 22.34;
|
||||
$longitude = 88.21;
|
||||
$zenith = 90;
|
||||
$gmt_offset = 5.5;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for format
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( date_sunset($time, $value, $latitude, $longitude, $zenith, $gmt_offset) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_sunset() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
|
||||
Warning: date_sunset(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
|
||||
Warning: date_sunset(): Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
int(1218199264)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
int(1218199264)
|
||||
|
||||
--lowercase null--
|
||||
int(1218199264)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "18:11"
|
||||
|
||||
--lowercase false--
|
||||
int(1218199264)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "18:11"
|
||||
|
||||
--uppercase FALSE--
|
||||
int(1218199264)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: date_sunset() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
int(1218199264)
|
||||
|
||||
--unset var--
|
||||
int(1218199264)
|
||||
===DONE===
|
@ -1,297 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sunset() function : usage variation - Passing unexpected values to third argument latitude.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed date_sunset(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
|
||||
* Description: Returns time of sunset for a given day and location
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing date_sunset() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$time = mktime(8, 8, 8, 8, 8, 2008);
|
||||
$longitude = 88.21;
|
||||
$zenith = 90;
|
||||
$gmt_offset = 5.5;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for latitude
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( date_sunset($time, SUNFUNCS_RET_STRING, $value, $longitude, $zenith, $gmt_offset) );
|
||||
var_dump( date_sunset($time, SUNFUNCS_RET_DOUBLE, $value, $longitude, $zenith, $gmt_offset) );
|
||||
var_dump( date_sunset($time, SUNFUNCS_RET_TIMESTAMP, $value, $longitude, $zenith, $gmt_offset) );
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_sunset() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(5) "17:43"
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
|
||||
--int 1--
|
||||
string(5) "17:45"
|
||||
float(17.750%d)
|
||||
int(1218197701)
|
||||
|
||||
--int 12345--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
string(5) "17:35"
|
||||
float(17.598%d)
|
||||
int(1218197155)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "17:43"
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "17:43"
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "17:45"
|
||||
float(17.750%d)
|
||||
int(1218197701)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "17:43"
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "17:45"
|
||||
float(17.750%d)
|
||||
int(1218197701)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "17:43"
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 3 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "17:43"
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
|
||||
--unset var--
|
||||
string(5) "17:43"
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
===DONE===
|
@ -1,296 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sunset() function : usage variation - Passing unexpected values to fourth argument longitude.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed date_sunset(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
|
||||
* Description: Returns time of sunset for a given day and location
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing date_sunset() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$time = mktime(8, 8, 8, 8, 8, 2008);
|
||||
$latitude = 22.34;
|
||||
$zenith = 90;
|
||||
$gmt_offset = 5.5;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for longitude
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( date_sunset($time, SUNFUNCS_RET_STRING, $latitude, $value, $zenith, $gmt_offset) );
|
||||
var_dump( date_sunset($time, SUNFUNCS_RET_DOUBLE, $latitude, $value, $zenith, $gmt_offset) );
|
||||
var_dump( date_sunset($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $value, $zenith, $gmt_offset) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_sunset() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(5) "00:03"
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
|
||||
--int 1--
|
||||
string(5) "23:59"
|
||||
float(23.995%d)
|
||||
int(1218220185)
|
||||
|
||||
--int 12345--
|
||||
string(5) "17:15"
|
||||
float(17.259%d)
|
||||
int(1218195932)
|
||||
|
||||
--int -12345--
|
||||
string(5) "12:19"
|
||||
float(12.319%d)
|
||||
int(1218178151)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "00:03"
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "00:03"
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "23:59"
|
||||
float(23.995%d)
|
||||
int(1218220185)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "00:03"
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "23:59"
|
||||
float(23.995%d)
|
||||
int(1218220185)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "00:03"
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 4 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "00:03"
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
|
||||
--unset var--
|
||||
string(5) "00:03"
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
===DONE===
|
@ -1,296 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sunset() function : usage variation - Passing unexpected values to fifth argument zenith.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed date_sunset(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
|
||||
* Description: Returns time of sunset for a given day and location
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing date_sunset() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$time = mktime(8, 8, 8, 8, 8, 2008);
|
||||
$longitude = 88.21;
|
||||
$latitude = 22.34;
|
||||
$gmt_offset = 5.5;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for zenith
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( date_sunset($time, SUNFUNCS_RET_STRING, $latitude, $longitude, $value, $gmt_offset) );
|
||||
var_dump( date_sunset($time, SUNFUNCS_RET_DOUBLE, $latitude, $longitude, $value, $gmt_offset) );
|
||||
var_dump( date_sunset($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude, $value, $gmt_offset) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_sunset() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
string(5) "19:20"
|
||||
float(19.343%d)
|
||||
int(1218203437)
|
||||
|
||||
--int -12345--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 5 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,296 +0,0 @@
|
||||
--TEST--
|
||||
Test date_sunset() function : usage variation - Passing unexpected values to sixth argument gmt_offset.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed date_sunset(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
|
||||
* Description: Returns time of sunset for a given day and location
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing date_sunset() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$time = mktime(8, 8, 8, 8, 8, 2008);
|
||||
$longitude = 88.21;
|
||||
$latitude = 22.34;
|
||||
$zenith = 90;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for gmt_offset
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( date_sunset($time, SUNFUNCS_RET_STRING, $latitude, $longitude, $zenith, $value) );
|
||||
var_dump( date_sunset($time, SUNFUNCS_RET_DOUBLE, $latitude, $longitude, $zenith, $value) );
|
||||
var_dump( date_sunset($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude, $zenith, $value) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_sunset() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--int 1--
|
||||
string(5) "13:41"
|
||||
float(13.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--int 12345--
|
||||
string(5) "21:41"
|
||||
float(21.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--int -12345--
|
||||
string(5) "19:41"
|
||||
float(19.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "13:41"
|
||||
float(13.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "13:41"
|
||||
float(13.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: date_sunset() expects parameter 6 to be float, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--unset var--
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
===DONE===
|
@ -1,254 +0,0 @@
|
||||
--TEST--
|
||||
Test date_time_set() function : usage variation - Passing unexpected values to first argument $object.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_time_set ( DateTime $object , 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: DateTime::setTime
|
||||
*/
|
||||
|
||||
echo "*** Testing date_time_set() : usage variation - unexpected values to first argument \$object***\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
|
||||
);
|
||||
|
||||
$hour = 10;
|
||||
$minute = 13;
|
||||
$sec = 45;
|
||||
|
||||
foreach($inputs as $variation =>$object) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_time_set($object, $hour, $minute, $sec) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_time_set() : usage variation - unexpected values to first argument $object***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_time_set() expects parameter 1 to be DateTime, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--TEST--
|
||||
Test date_time_set() function : usage variation - Passing unexpected values to second argument $hour.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_time_set ( DateTime $object , 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: DateTime::setTime
|
||||
*/
|
||||
|
||||
echo "*** Testing date_time_set() : usage variation - unexpected values to second 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 = date_create("2009-01-31 15:14:10");
|
||||
$minute = 13;
|
||||
$sec = 45;
|
||||
|
||||
foreach($inputs as $variation =>$hour) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_time_set($object, $hour, $minute, $sec) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_time_set() : usage variation - unexpected values to second argument $hour***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 01:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2010-06-29 09:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 15:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 14:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_time_set() expects parameter 2 to be int, array given in %s
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_time_set() expects parameter 2 to be int, array given in %s
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_time_set() expects parameter 2 to be int, array given in %s
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_time_set() expects parameter 2 to be int, array given in %s
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 01:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 01:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 2 to be int, string given in %s
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 2 to be int, string given in %s
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 2 to be int, string given in %s
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 2 to be int, string given in %s
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_time_set() expects parameter 2 to be int, string given in %s
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_time_set() expects parameter 2 to be int, string given in %s
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_time_set() expects parameter 2 to be int, object given in %s
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_time_set() expects parameter 2 to be int, object given in %s
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-29 00:13:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_time_set() expects parameter 2 to be int, resource given in %s
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--TEST--
|
||||
Test date_time_set() function : usage variation - Passing unexpected values to third argument $minute.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_time_set ( DateTime $object , 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: DateTime::setTime
|
||||
*/
|
||||
|
||||
echo "*** Testing date_time_set() : usage variation - unexpected values to third 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 = date_create("2009-01-31 15:14:10");
|
||||
$hour = 10;
|
||||
$sec = 45;
|
||||
|
||||
foreach($inputs as $variation =>$minute) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_time_set($object, $hour, $minute, $sec) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_time_set() : usage variation - unexpected values to third argument $minute***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#3 (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#3 (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:01:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#3 (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-02-08 23:45:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#3 (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 20:15:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#3 (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:10:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#3 (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 09:50:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#3 (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_time_set() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_time_set() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_time_set() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_time_set() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:01:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:01:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_time_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_time_set() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_time_set() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_time_set() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-30 10:00:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_time_set() expects parameter 3 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,329 +0,0 @@
|
||||
--TEST--
|
||||
Test date_time_set() function : usage variation - Passing unexpected values to forth argument $sec.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_time_set ( DateTime $object , 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: DateTime::setTime
|
||||
*/
|
||||
|
||||
echo "*** Testing date_time_set() : usage variation - unexpected values to forth argument \$sec***\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-01-31 15:14:10");
|
||||
$hour = 10;
|
||||
$minute = 13;
|
||||
|
||||
foreach($inputs as $variation =>$sec) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_time_set($object, $hour, $minute, $sec) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_time_set() : usage variation - unexpected values to forth argument $sec***
|
||||
|
||||
-- int 0 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 1 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:01.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int 12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 13:38:45.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 06:47:15.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float 10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:12:50.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- float .5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_time_set() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_time_set() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_time_set() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_time_set() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase null --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase true --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:01.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- lowercase false --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase TRUE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:01.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- uppercase FALSE --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_time_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_time_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_time_set() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_time_set() expects parameter 4 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_time_set() expects parameter 4 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- unset var --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(26) "2009-01-31 10:13:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
string(13) "Europe/London"
|
||||
}
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_time_set() expects parameter 4 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,250 +0,0 @@
|
||||
--TEST--
|
||||
Test date_timezone_get() function : usage variation - Passing unexpected values to first argument $object.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTimeZone date_timezone_get ( DateTimeInterface $object )
|
||||
* Description: Return time zone relative to given DateTimeInterface
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTimeInterface::getTimezone
|
||||
*/
|
||||
|
||||
echo "*** Testing date_timezone_get() : usage variation - unexpected values to first argument \$object***\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
|
||||
);
|
||||
|
||||
foreach($inputs as $variation =>$object) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_timezone_get($object) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_timezone_get() : usage variation - unexpected values to first argument $object***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,253 +0,0 @@
|
||||
--TEST--
|
||||
Test date_timezone_set() function : usage variation - Passing unexpected values to first argument $object.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_timezone_set ( DateTime $object , DateTimeZone $timezone )
|
||||
* Description: Sets the time zone for the DateTime object
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTime::setTimezone
|
||||
*/
|
||||
|
||||
echo "*** Testing date_timezone_set() : usage variation - unexpected values to first argument \$object***\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 = timezone_open("America/Los_Angeles");
|
||||
|
||||
foreach($inputs as $variation =>$object) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_timezone_set($object, $timezone) );
|
||||
};
|
||||
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_timezone_set() : usage variation - unexpected values to first argument $object***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 1 to be DateTime, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,252 +0,0 @@
|
||||
--TEST--
|
||||
Test date_timezone_set() function : usage variation - Passing unexpected values to second argument $timezone.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTime date_timezone_set ( DateTime $object , DateTimeZone $timezone )
|
||||
* Description: Sets the time zone for the DateTime object
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTime::setTimezone
|
||||
*/
|
||||
|
||||
echo "*** Testing date_timezone_set() : 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
|
||||
);
|
||||
|
||||
$object = date_create("2009-01-30 17:57:32");
|
||||
|
||||
foreach($inputs as $variation =>$timezone) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date_timezone_set($object, $timezone) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_timezone_set() : usage variation - unexpected values to second argument $timezone***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,207 +0,0 @@
|
||||
--TEST--
|
||||
Test date() function : usage variation - Passing unexpected values to first argument $format.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string date ( string $format [, int $timestamp ] )
|
||||
* Description: Format a local time/date.
|
||||
* Source code: ext/date/php_date.c
|
||||
*/
|
||||
|
||||
echo "*** Testing date() : usage variation - unexpected values to first argument \$format***\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
|
||||
);
|
||||
|
||||
$timestamp = mktime(10, 44, 30, 2, 27, 2009);
|
||||
|
||||
foreach($inputs as $variation =>$format) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date($format, $timestamp) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date() : usage variation - unexpected values to first argument $format***
|
||||
|
||||
-- int 0 --
|
||||
string(1) "0"
|
||||
|
||||
-- int 1 --
|
||||
string(1) "1"
|
||||
|
||||
-- int 12345 --
|
||||
string(5) "12345"
|
||||
|
||||
-- int -12345 --
|
||||
string(6) "-12345"
|
||||
|
||||
-- float 10.5 --
|
||||
string(4) "10.5"
|
||||
|
||||
-- float -10.5 --
|
||||
string(5) "-10.5"
|
||||
|
||||
-- float .5 --
|
||||
string(3) "0.5"
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
string(0) ""
|
||||
|
||||
-- lowercase null --
|
||||
string(0) ""
|
||||
|
||||
-- lowercase true --
|
||||
string(1) "1"
|
||||
|
||||
-- lowercase false --
|
||||
string(0) ""
|
||||
|
||||
-- uppercase TRUE --
|
||||
string(1) "1"
|
||||
|
||||
-- uppercase FALSE --
|
||||
string(0) ""
|
||||
|
||||
-- empty string DQ --
|
||||
string(0) ""
|
||||
|
||||
-- empty string SQ --
|
||||
string(0) ""
|
||||
|
||||
-- string DQ --
|
||||
string(40) "3028Fri, 27 Feb 2009 10:44:30 +000044210"
|
||||
|
||||
-- string SQ --
|
||||
string(40) "3028Fri, 27 Feb 2009 10:44:30 +000044210"
|
||||
|
||||
-- mixed case string --
|
||||
string(40) "30GMTFri, 27 Feb 2009 10:44:30 +00000210"
|
||||
|
||||
-- heredoc --
|
||||
string(76) "10Europe/LondonFridayFriday2009 52009Fri, 27 Feb 2009 10:44:30 +0000Friday27"
|
||||
|
||||
-- instance of classWithToString --
|
||||
string(64) "CFridayam3030 AM 2009b27Europe/London2009-02-27T10:44:30+00:0028"
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
string(0) ""
|
||||
|
||||
-- unset var --
|
||||
string(0) ""
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date() expects parameter 1 to be string, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,221 +0,0 @@
|
||||
--TEST--
|
||||
Test date() function : usage variation - Passing unexpected values to second argument $timestamp.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string date ( string $format [, int $timestamp ] )
|
||||
* Description: Format a local time/date.
|
||||
* Source code: ext/date/php_date.c
|
||||
*/
|
||||
|
||||
echo "*** Testing date() : usage variation - unexpected values to second argument \$timestamp***\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
|
||||
);
|
||||
|
||||
$format = "F j, Y, g:i a";
|
||||
|
||||
foreach($inputs as $variation =>$timestamp) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( date($format, $timestamp) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date() : usage variation - unexpected values to second argument $timestamp***
|
||||
|
||||
-- int 0 --
|
||||
string(24) "January 1, 1970, 1:00 am"
|
||||
|
||||
-- int 1 --
|
||||
string(24) "January 1, 1970, 1:00 am"
|
||||
|
||||
-- int 12345 --
|
||||
string(24) "January 1, 1970, 4:25 am"
|
||||
|
||||
-- int -12345 --
|
||||
string(26) "December 31, 1969, 9:34 pm"
|
||||
|
||||
-- float 10.5 --
|
||||
string(24) "January 1, 1970, 1:00 am"
|
||||
|
||||
-- float -10.5 --
|
||||
string(25) "January 1, 1970, 12:59 am"
|
||||
|
||||
-- float .5 --
|
||||
string(24) "January 1, 1970, 1:00 am"
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: date() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: date() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: date() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: date() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
string(24) "January 1, 1970, 1:00 am"
|
||||
|
||||
-- lowercase null --
|
||||
string(24) "January 1, 1970, 1:00 am"
|
||||
|
||||
-- lowercase true --
|
||||
string(24) "January 1, 1970, 1:00 am"
|
||||
|
||||
-- lowercase false --
|
||||
string(24) "January 1, 1970, 1:00 am"
|
||||
|
||||
-- uppercase TRUE --
|
||||
string(24) "January 1, 1970, 1:00 am"
|
||||
|
||||
-- uppercase FALSE --
|
||||
string(24) "January 1, 1970, 1:00 am"
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: date() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: date() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: date() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: date() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: date() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: date() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: date() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: date() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
string(24) "January 1, 1970, 1:00 am"
|
||||
|
||||
-- unset var --
|
||||
string(24) "January 1, 1970, 1:00 am"
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: date() expects parameter 2 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,443 +0,0 @@
|
||||
--TEST--
|
||||
Test getdate() function : usage variation - Passing unexpected values to first argument timestamp.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : array getdate([int timestamp])
|
||||
* Description: Get date/time information
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing getdate() : usage variation ***\n";
|
||||
|
||||
//Set the default time zone
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( getdate($value) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing getdate() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
array(11) {
|
||||
["seconds"]=>
|
||||
int(10)
|
||||
["minutes"]=>
|
||||
int(30)
|
||||
["hours"]=>
|
||||
int(5)
|
||||
["mday"]=>
|
||||
int(1)
|
||||
["wday"]=>
|
||||
int(4)
|
||||
["mon"]=>
|
||||
int(1)
|
||||
["year"]=>
|
||||
int(1970)
|
||||
["yday"]=>
|
||||
int(0)
|
||||
["weekday"]=>
|
||||
string(8) "Thursday"
|
||||
["month"]=>
|
||||
string(7) "January"
|
||||
[0]=>
|
||||
int(10)
|
||||
}
|
||||
|
||||
--float -10.5--
|
||||
array(11) {
|
||||
["seconds"]=>
|
||||
int(50)
|
||||
["minutes"]=>
|
||||
int(29)
|
||||
["hours"]=>
|
||||
int(5)
|
||||
["mday"]=>
|
||||
int(1)
|
||||
["wday"]=>
|
||||
int(4)
|
||||
["mon"]=>
|
||||
int(1)
|
||||
["year"]=>
|
||||
int(1970)
|
||||
["yday"]=>
|
||||
int(0)
|
||||
["weekday"]=>
|
||||
string(8) "Thursday"
|
||||
["month"]=>
|
||||
string(7) "January"
|
||||
[0]=>
|
||||
int(-10)
|
||||
}
|
||||
|
||||
--float .5--
|
||||
array(11) {
|
||||
["seconds"]=>
|
||||
int(0)
|
||||
["minutes"]=>
|
||||
int(30)
|
||||
["hours"]=>
|
||||
int(5)
|
||||
["mday"]=>
|
||||
int(1)
|
||||
["wday"]=>
|
||||
int(4)
|
||||
["mon"]=>
|
||||
int(1)
|
||||
["year"]=>
|
||||
int(1970)
|
||||
["yday"]=>
|
||||
int(0)
|
||||
["weekday"]=>
|
||||
string(8) "Thursday"
|
||||
["month"]=>
|
||||
string(7) "January"
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: getdate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: getdate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: getdate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: getdate() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
array(11) {
|
||||
["seconds"]=>
|
||||
int(0)
|
||||
["minutes"]=>
|
||||
int(30)
|
||||
["hours"]=>
|
||||
int(5)
|
||||
["mday"]=>
|
||||
int(1)
|
||||
["wday"]=>
|
||||
int(4)
|
||||
["mon"]=>
|
||||
int(1)
|
||||
["year"]=>
|
||||
int(1970)
|
||||
["yday"]=>
|
||||
int(0)
|
||||
["weekday"]=>
|
||||
string(8) "Thursday"
|
||||
["month"]=>
|
||||
string(7) "January"
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--lowercase null--
|
||||
array(11) {
|
||||
["seconds"]=>
|
||||
int(0)
|
||||
["minutes"]=>
|
||||
int(30)
|
||||
["hours"]=>
|
||||
int(5)
|
||||
["mday"]=>
|
||||
int(1)
|
||||
["wday"]=>
|
||||
int(4)
|
||||
["mon"]=>
|
||||
int(1)
|
||||
["year"]=>
|
||||
int(1970)
|
||||
["yday"]=>
|
||||
int(0)
|
||||
["weekday"]=>
|
||||
string(8) "Thursday"
|
||||
["month"]=>
|
||||
string(7) "January"
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--lowercase true--
|
||||
array(11) {
|
||||
["seconds"]=>
|
||||
int(1)
|
||||
["minutes"]=>
|
||||
int(30)
|
||||
["hours"]=>
|
||||
int(5)
|
||||
["mday"]=>
|
||||
int(1)
|
||||
["wday"]=>
|
||||
int(4)
|
||||
["mon"]=>
|
||||
int(1)
|
||||
["year"]=>
|
||||
int(1970)
|
||||
["yday"]=>
|
||||
int(0)
|
||||
["weekday"]=>
|
||||
string(8) "Thursday"
|
||||
["month"]=>
|
||||
string(7) "January"
|
||||
[0]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
--lowercase false--
|
||||
array(11) {
|
||||
["seconds"]=>
|
||||
int(0)
|
||||
["minutes"]=>
|
||||
int(30)
|
||||
["hours"]=>
|
||||
int(5)
|
||||
["mday"]=>
|
||||
int(1)
|
||||
["wday"]=>
|
||||
int(4)
|
||||
["mon"]=>
|
||||
int(1)
|
||||
["year"]=>
|
||||
int(1970)
|
||||
["yday"]=>
|
||||
int(0)
|
||||
["weekday"]=>
|
||||
string(8) "Thursday"
|
||||
["month"]=>
|
||||
string(7) "January"
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--uppercase TRUE--
|
||||
array(11) {
|
||||
["seconds"]=>
|
||||
int(1)
|
||||
["minutes"]=>
|
||||
int(30)
|
||||
["hours"]=>
|
||||
int(5)
|
||||
["mday"]=>
|
||||
int(1)
|
||||
["wday"]=>
|
||||
int(4)
|
||||
["mon"]=>
|
||||
int(1)
|
||||
["year"]=>
|
||||
int(1970)
|
||||
["yday"]=>
|
||||
int(0)
|
||||
["weekday"]=>
|
||||
string(8) "Thursday"
|
||||
["month"]=>
|
||||
string(7) "January"
|
||||
[0]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
--uppercase FALSE--
|
||||
array(11) {
|
||||
["seconds"]=>
|
||||
int(0)
|
||||
["minutes"]=>
|
||||
int(30)
|
||||
["hours"]=>
|
||||
int(5)
|
||||
["mday"]=>
|
||||
int(1)
|
||||
["wday"]=>
|
||||
int(4)
|
||||
["mon"]=>
|
||||
int(1)
|
||||
["year"]=>
|
||||
int(1970)
|
||||
["yday"]=>
|
||||
int(0)
|
||||
["weekday"]=>
|
||||
string(8) "Thursday"
|
||||
["month"]=>
|
||||
string(7) "January"
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: getdate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: getdate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: getdate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: getdate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: getdate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: getdate() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: getdate() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: getdate() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
array(11) {
|
||||
["seconds"]=>
|
||||
int(0)
|
||||
["minutes"]=>
|
||||
int(30)
|
||||
["hours"]=>
|
||||
int(5)
|
||||
["mday"]=>
|
||||
int(1)
|
||||
["wday"]=>
|
||||
int(4)
|
||||
["mon"]=>
|
||||
int(1)
|
||||
["year"]=>
|
||||
int(1970)
|
||||
["yday"]=>
|
||||
int(0)
|
||||
["weekday"]=>
|
||||
string(8) "Thursday"
|
||||
["month"]=>
|
||||
string(7) "January"
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--unset var--
|
||||
array(11) {
|
||||
["seconds"]=>
|
||||
int(0)
|
||||
["minutes"]=>
|
||||
int(30)
|
||||
["hours"]=>
|
||||
int(5)
|
||||
["mday"]=>
|
||||
int(1)
|
||||
["wday"]=>
|
||||
int(4)
|
||||
["mon"]=>
|
||||
int(1)
|
||||
["year"]=>
|
||||
int(1970)
|
||||
["yday"]=>
|
||||
int(0)
|
||||
["weekday"]=>
|
||||
string(8) "Thursday"
|
||||
["month"]=>
|
||||
string(7) "January"
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
===DONE===
|
@ -1,284 +0,0 @@
|
||||
--TEST--
|
||||
Test gettimeofday() function : usage variation - Passing unexpected values to get_as_float argument
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : array gettimeofday([bool get_as_float])
|
||||
* Description: Returns the current time as array
|
||||
* Source code: ext/standard/microtime.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing gettimeofday() : usage variation ***\n";
|
||||
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
|
||||
//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);
|
||||
|
||||
//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 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for get_as_float
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( gettimeofday($value) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing gettimeofday() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
array(4) {
|
||||
["sec"]=>
|
||||
int(%d)
|
||||
["usec"]=>
|
||||
int(%d)
|
||||
["minuteswest"]=>
|
||||
int(-330)
|
||||
["dsttime"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--int 1--
|
||||
float(%f)
|
||||
|
||||
--int 12345--
|
||||
float(%f)
|
||||
|
||||
--int -12345--
|
||||
float(%f)
|
||||
|
||||
--float 10.5--
|
||||
float(%f)
|
||||
|
||||
--float -10.5--
|
||||
float(%f)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
float(%f)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
float(%f)
|
||||
|
||||
--float .5--
|
||||
float(%f)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: gettimeofday() expects parameter 1 to be bool, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: gettimeofday() expects parameter 1 to be bool, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: gettimeofday() expects parameter 1 to be bool, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: gettimeofday() expects parameter 1 to be bool, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
--uppercase NULL--
|
||||
array(4) {
|
||||
["sec"]=>
|
||||
int(%d)
|
||||
["usec"]=>
|
||||
int(%d)
|
||||
["minuteswest"]=>
|
||||
int(-330)
|
||||
["dsttime"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--lowercase null--
|
||||
array(4) {
|
||||
["sec"]=>
|
||||
int(%d)
|
||||
["usec"]=>
|
||||
int(%d)
|
||||
["minuteswest"]=>
|
||||
int(-330)
|
||||
["dsttime"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--lowercase true--
|
||||
float(%f)
|
||||
|
||||
--lowercase false--
|
||||
array(4) {
|
||||
["sec"]=>
|
||||
int(%d)
|
||||
["usec"]=>
|
||||
int(%d)
|
||||
["minuteswest"]=>
|
||||
int(-330)
|
||||
["dsttime"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--uppercase TRUE--
|
||||
float(%f)
|
||||
|
||||
--uppercase FALSE--
|
||||
array(4) {
|
||||
["sec"]=>
|
||||
int(%d)
|
||||
["usec"]=>
|
||||
int(%d)
|
||||
["minuteswest"]=>
|
||||
int(-330)
|
||||
["dsttime"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--empty string DQ--
|
||||
array(4) {
|
||||
["sec"]=>
|
||||
int(%d)
|
||||
["usec"]=>
|
||||
int(%d)
|
||||
["minuteswest"]=>
|
||||
int(-330)
|
||||
["dsttime"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--empty string SQ--
|
||||
array(4) {
|
||||
["sec"]=>
|
||||
int(%d)
|
||||
["usec"]=>
|
||||
int(%d)
|
||||
["minuteswest"]=>
|
||||
int(-330)
|
||||
["dsttime"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--string DQ--
|
||||
float(%f)
|
||||
|
||||
--string SQ--
|
||||
float(%f)
|
||||
|
||||
--mixed case string--
|
||||
float(%f)
|
||||
|
||||
--heredoc--
|
||||
float(%f)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: gettimeofday() expects parameter 1 to be bool, object given in %s on line %d
|
||||
NULL
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: gettimeofday() expects parameter 1 to be bool, object given in %s on line %d
|
||||
NULL
|
||||
|
||||
--undefined var--
|
||||
array(4) {
|
||||
["sec"]=>
|
||||
int(%d)
|
||||
["usec"]=>
|
||||
int(%d)
|
||||
["minuteswest"]=>
|
||||
int(-330)
|
||||
["dsttime"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--unset var--
|
||||
array(4) {
|
||||
["sec"]=>
|
||||
int(%d)
|
||||
["usec"]=>
|
||||
int(%d)
|
||||
["minuteswest"]=>
|
||||
int(-330)
|
||||
["dsttime"]=>
|
||||
int(0)
|
||||
}
|
||||
===DONE===
|
@ -1,221 +0,0 @@
|
||||
--TEST--
|
||||
Test gmdate() function : usage variation - Passing unexpected values to format argument .
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string gmdate(string format [, long timestamp])
|
||||
* Description: Format a GMT date/time
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing gmdate() : usage variation ***\n";
|
||||
|
||||
// Initialise all required variables
|
||||
date_default_timezone_set('UTC');
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//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);
|
||||
|
||||
//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 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'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' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
);
|
||||
|
||||
// loop through each element of the array for format
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( gmdate($value, $timestamp) );
|
||||
var_dump( gmdate($value) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing gmdate() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(1) "0"
|
||||
string(1) "0"
|
||||
|
||||
--int 1--
|
||||
string(1) "1"
|
||||
string(1) "1"
|
||||
|
||||
--int 12345--
|
||||
string(5) "12345"
|
||||
string(5) "12345"
|
||||
|
||||
--int -12345--
|
||||
string(6) "-12345"
|
||||
string(6) "-12345"
|
||||
|
||||
--float 10.5--
|
||||
string(4) "10.5"
|
||||
string(4) "10.5"
|
||||
|
||||
--float -10.5--
|
||||
string(5) "-10.5"
|
||||
string(5) "-10.5"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
string(12) "123456789000"
|
||||
string(12) "123456789000"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
string(13) "-123456789000"
|
||||
string(13) "-123456789000"
|
||||
|
||||
--float .5--
|
||||
string(3) "0.5"
|
||||
string(3) "0.5"
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gmdate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
|
||||
--lowercase null--
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
|
||||
--lowercase true--
|
||||
string(1) "1"
|
||||
string(1) "1"
|
||||
|
||||
--lowercase false--
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
|
||||
--uppercase TRUE--
|
||||
string(1) "1"
|
||||
string(1) "1"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
|
||||
--empty string DQ--
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
|
||||
--empty string SQ--
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithToString--
|
||||
string(53) "CFridayam0808 AM 2008b8UTC2008-08-08T08:08:08+00:0031"
|
||||
string(%d) "%s"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: gmdate() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gmdate() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
|
||||
--unset var--
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
===DONE===
|
@ -1,210 +0,0 @@
|
||||
--TEST--
|
||||
Test gmdate() function : usage variation - Passing unexpected values to timestamp argument.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string gmdate(string format [, long timestamp])
|
||||
* Description: Format a GMT date/time
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing gmdate() : usage variation ***\n";
|
||||
|
||||
|
||||
// Initialise all required variables
|
||||
date_default_timezone_set('UTC');
|
||||
$format = DATE_ISO8601;
|
||||
|
||||
//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);
|
||||
|
||||
//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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( gmdate($format, $value) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing gmdate() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(24) "1970-01-01T00:00:00+0000"
|
||||
|
||||
--int 1--
|
||||
string(24) "1970-01-01T00:00:01+0000"
|
||||
|
||||
--int 12345--
|
||||
string(24) "1970-01-01T03:25:45+0000"
|
||||
|
||||
--int -12345--
|
||||
string(24) "1969-12-31T20:34:15+0000"
|
||||
|
||||
--float 10.5--
|
||||
string(24) "1970-01-01T00:00:10+0000"
|
||||
|
||||
--float -10.5--
|
||||
string(24) "1969-12-31T23:59:50+0000"
|
||||
|
||||
--float .5--
|
||||
string(24) "1970-01-01T00:00:00+0000"
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: gmdate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: gmdate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: gmdate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: gmdate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(24) "1970-01-01T00:00:00+0000"
|
||||
|
||||
--lowercase null--
|
||||
string(24) "1970-01-01T00:00:00+0000"
|
||||
|
||||
--lowercase true--
|
||||
string(24) "1970-01-01T00:00:01+0000"
|
||||
|
||||
--lowercase false--
|
||||
string(24) "1970-01-01T00:00:00+0000"
|
||||
|
||||
--uppercase TRUE--
|
||||
string(24) "1970-01-01T00:00:01+0000"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(24) "1970-01-01T00:00:00+0000"
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: gmdate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: gmdate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: gmdate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: gmdate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: gmdate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: gmdate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: gmdate() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: gmdate() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(24) "1970-01-01T00:00:00+0000"
|
||||
|
||||
--unset var--
|
||||
string(24) "1970-01-01T00:00:00+0000"
|
||||
===DONE===
|
@ -1,194 +0,0 @@
|
||||
--TEST--
|
||||
Test gmmktime() function : usage variation - Passing unexpected values to first argument hour.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
|
||||
* Description: Get UNIX timestamp for a GMT date
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing gmmktime() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$min = 8;
|
||||
$sec = 8;
|
||||
$mon = 8;
|
||||
$day = 8;
|
||||
$year = 2008;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for hour
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( gmmktime($value, $min, $sec, $mon, $day, $year) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing gmmktime() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
int(1218190088)
|
||||
|
||||
--float -10.5--
|
||||
int(1218118088)
|
||||
|
||||
--float .5--
|
||||
int(1218154088)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: gmmktime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: gmmktime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: gmmktime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: gmmktime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
int(1218154088)
|
||||
|
||||
--lowercase null--
|
||||
int(1218154088)
|
||||
|
||||
--lowercase true--
|
||||
int(1218157688)
|
||||
|
||||
--lowercase false--
|
||||
int(1218154088)
|
||||
|
||||
--uppercase TRUE--
|
||||
int(1218157688)
|
||||
|
||||
--uppercase FALSE--
|
||||
int(1218154088)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: gmmktime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: gmmktime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: gmmktime() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: gmmktime() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
int(1218154088)
|
||||
|
||||
--unset var--
|
||||
int(1218154088)
|
||||
===DONE===
|
@ -1,194 +0,0 @@
|
||||
--TEST--
|
||||
Test gmmktime() function : usage variation - Passing unexpected values to second argument minute.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
|
||||
* Description: Get UNIX timestamp for a GMT date
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing gmmktime() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$hour = 8;
|
||||
$sec = 8;
|
||||
$mon = 8;
|
||||
$day = 8;
|
||||
$year = 2008;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for min
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( gmmktime($hour, $value, $sec, $mon, $day, $year) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing gmmktime() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
int(1218183008)
|
||||
|
||||
--float -10.5--
|
||||
int(1218181808)
|
||||
|
||||
--float .5--
|
||||
int(1218182408)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: gmmktime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: gmmktime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: gmmktime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: gmmktime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
int(1218182408)
|
||||
|
||||
--lowercase null--
|
||||
int(1218182408)
|
||||
|
||||
--lowercase true--
|
||||
int(1218182468)
|
||||
|
||||
--lowercase false--
|
||||
int(1218182408)
|
||||
|
||||
--uppercase TRUE--
|
||||
int(1218182468)
|
||||
|
||||
--uppercase FALSE--
|
||||
int(1218182408)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: gmmktime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: gmmktime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: gmmktime() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: gmmktime() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
int(1218182408)
|
||||
|
||||
--unset var--
|
||||
int(1218182408)
|
||||
===DONE===
|
@ -1,194 +0,0 @@
|
||||
--TEST--
|
||||
Test gmmktime() function : usage variation - Passing unexpected values to third argument seconds.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
|
||||
* Description: Get UNIX timestamp for a GMT date
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing gmmktime() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$hour = 8;
|
||||
$min = 8;
|
||||
$mon = 8;
|
||||
$day = 8;
|
||||
$year = 2008;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for sec
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( gmmktime($hour, $min, $value, $mon, $day, $year) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing gmmktime() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
int(1218182890)
|
||||
|
||||
--float -10.5--
|
||||
int(1218182870)
|
||||
|
||||
--float .5--
|
||||
int(1218182880)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: gmmktime() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: gmmktime() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: gmmktime() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: gmmktime() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
int(1218182880)
|
||||
|
||||
--lowercase null--
|
||||
int(1218182880)
|
||||
|
||||
--lowercase true--
|
||||
int(1218182881)
|
||||
|
||||
--lowercase false--
|
||||
int(1218182880)
|
||||
|
||||
--uppercase TRUE--
|
||||
int(1218182881)
|
||||
|
||||
--uppercase FALSE--
|
||||
int(1218182880)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: gmmktime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: gmmktime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: gmmktime() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: gmmktime() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
int(1218182880)
|
||||
|
||||
--unset var--
|
||||
int(1218182880)
|
||||
===DONE===
|
@ -1,194 +0,0 @@
|
||||
--TEST--
|
||||
Test gmmktime() function : usage variation - Passing unexpected values to fourth argument month.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
|
||||
* Description: Get UNIX timestamp for a GMT date
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing gmmktime() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$hour = 8;
|
||||
$min = 8;
|
||||
$sec = 8;
|
||||
$day = 8;
|
||||
$year = 2008;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for mon
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( gmmktime($hour, $min, $sec, $value, $day, $year) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing gmmktime() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
int(1223453288)
|
||||
|
||||
--float -10.5--
|
||||
int(1170922088)
|
||||
|
||||
--float .5--
|
||||
int(1197101288)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: gmmktime() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: gmmktime() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: gmmktime() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: gmmktime() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
int(1197101288)
|
||||
|
||||
--lowercase null--
|
||||
int(1197101288)
|
||||
|
||||
--lowercase true--
|
||||
int(1199779688)
|
||||
|
||||
--lowercase false--
|
||||
int(1197101288)
|
||||
|
||||
--uppercase TRUE--
|
||||
int(1199779688)
|
||||
|
||||
--uppercase FALSE--
|
||||
int(1197101288)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: gmmktime() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: gmmktime() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: gmmktime() expects parameter 4 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: gmmktime() expects parameter 4 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
int(1197101288)
|
||||
|
||||
--unset var--
|
||||
int(1197101288)
|
||||
===DONE===
|
@ -1,194 +0,0 @@
|
||||
--TEST--
|
||||
Test gmmktime() function : usage variation - Passing unexpected values to fifth argument day.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
|
||||
* Description: Get UNIX timestamp for a GMT date
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing gmmktime() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$hour = 8;
|
||||
$min = 8;
|
||||
$sec = 8;
|
||||
$mon = 8;
|
||||
$year = 2008;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for day
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( gmmktime($hour, $min, $sec, $mon, $value, $year) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing gmmktime() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
int(1218355688)
|
||||
|
||||
--float -10.5--
|
||||
int(1216627688)
|
||||
|
||||
--float .5--
|
||||
int(1217491688)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: gmmktime() expects parameter 5 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: gmmktime() expects parameter 5 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: gmmktime() expects parameter 5 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: gmmktime() expects parameter 5 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
int(1217491688)
|
||||
|
||||
--lowercase null--
|
||||
int(1217491688)
|
||||
|
||||
--lowercase true--
|
||||
int(1217578088)
|
||||
|
||||
--lowercase false--
|
||||
int(1217491688)
|
||||
|
||||
--uppercase TRUE--
|
||||
int(1217578088)
|
||||
|
||||
--uppercase FALSE--
|
||||
int(1217491688)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 5 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 5 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 5 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 5 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: gmmktime() expects parameter 5 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: gmmktime() expects parameter 5 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: gmmktime() expects parameter 5 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: gmmktime() expects parameter 5 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
int(1217491688)
|
||||
|
||||
--unset var--
|
||||
int(1217491688)
|
||||
===DONE===
|
@ -1,190 +0,0 @@
|
||||
--TEST--
|
||||
Test gmmktime() function : usage variation - Passing unexpected values to sixth argument year.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
|
||||
* Description: Get UNIX timestamp for a GMT date
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing gmmktime() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$hour = 8;
|
||||
$min = 8;
|
||||
$sec = 8;
|
||||
$mon = 8;
|
||||
$day = 8;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// float data
|
||||
'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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for year
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( gmmktime($hour, $min, $sec, $mon, $day, $value) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing gmmktime() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
int(1281254888)
|
||||
|
||||
--float .5--
|
||||
int(965722088)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: gmmktime() expects parameter 6 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: gmmktime() expects parameter 6 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: gmmktime() expects parameter 6 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: gmmktime() expects parameter 6 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
int(965722088)
|
||||
|
||||
--lowercase null--
|
||||
int(965722088)
|
||||
|
||||
--lowercase true--
|
||||
int(997258088)
|
||||
|
||||
--lowercase false--
|
||||
int(965722088)
|
||||
|
||||
--uppercase TRUE--
|
||||
int(997258088)
|
||||
|
||||
--uppercase FALSE--
|
||||
int(965722088)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 6 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 6 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 6 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: gmmktime() expects parameter 6 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: gmmktime() expects parameter 6 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: gmmktime() expects parameter 6 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: gmmktime() expects parameter 6 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: gmmktime() expects parameter 6 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
int(965722088)
|
||||
|
||||
--unset var--
|
||||
int(965722088)
|
||||
===DONE===
|
@ -1,220 +0,0 @@
|
||||
--TEST--
|
||||
Test gmstrftime() function : usage variation - Passing unexpected values to first argument 'format'.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string gmstrftime(string format [, int timestamp])
|
||||
* Description: Format a GMT/UCT time/date according to locale settings
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing gmstrftime() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//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);
|
||||
|
||||
//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 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'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' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
);
|
||||
|
||||
// loop through each element of the array for format
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( gmstrftime($value) );
|
||||
var_dump( gmstrftime($value, $timestamp) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing gmstrftime() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(1) "0"
|
||||
string(1) "0"
|
||||
|
||||
--int 1--
|
||||
string(1) "1"
|
||||
string(1) "1"
|
||||
|
||||
--int 12345--
|
||||
string(5) "12345"
|
||||
string(5) "12345"
|
||||
|
||||
--int -12345--
|
||||
string(6) "-12345"
|
||||
string(6) "-12345"
|
||||
|
||||
--float 10.5--
|
||||
string(4) "10.5"
|
||||
string(4) "10.5"
|
||||
|
||||
--float -10.5--
|
||||
string(5) "-10.5"
|
||||
string(5) "-10.5"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
string(12) "123456789000"
|
||||
string(12) "123456789000"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
string(13) "-123456789000"
|
||||
string(13) "-123456789000"
|
||||
|
||||
--float .5--
|
||||
string(3) "0.5"
|
||||
string(3) "0.5"
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
string(1) "1"
|
||||
string(1) "1"
|
||||
|
||||
--lowercase false--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(1) "1"
|
||||
string(1) "1"
|
||||
|
||||
--uppercase FALSE--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
string(14) "Class A object"
|
||||
string(14) "Class A object"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: gmstrftime() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gmstrftime() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
bool(false)
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,210 +0,0 @@
|
||||
--TEST--
|
||||
Test gmstrftime() function : usage variation - Passing unexpected values to second argument 'timestamp'.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(PHP_INT_SIZE != 4 ) {
|
||||
die("skip Test is not valid for 64-bit");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string gmstrftime(string format [, int timestamp])
|
||||
* Description: Format a GMT/UCT time/date according to locale settings
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing gmstrftime() : usage variation ***\n";
|
||||
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$format = '%b %d %Y %H:%M:%S';
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( gmstrftime($format, $value) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing gmstrftime() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
string(20) "Jan 01 1970 00:00:10"
|
||||
|
||||
--float -10.5--
|
||||
string(20) "Dec 31 1969 23:59:50"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
string(20) "Jan 01 1970 00:00:00"
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(20) "Jan 01 1970 00:00:00"
|
||||
|
||||
--lowercase null--
|
||||
string(20) "Jan 01 1970 00:00:00"
|
||||
|
||||
--lowercase true--
|
||||
string(20) "Jan 01 1970 00:00:01"
|
||||
|
||||
--lowercase false--
|
||||
string(20) "Jan 01 1970 00:00:00"
|
||||
|
||||
--uppercase TRUE--
|
||||
string(20) "Jan 01 1970 00:00:01"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(20) "Jan 01 1970 00:00:00"
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: gmstrftime() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(20) "Jan 01 1970 00:00:00"
|
||||
|
||||
--unset var--
|
||||
string(20) "Jan 01 1970 00:00:00"
|
||||
===DONE===
|
@ -1,301 +0,0 @@
|
||||
--TEST--
|
||||
Test idate() function : usage variation - Passing unexpected values to first argument 'format'.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int idate(string format [, int timestamp])
|
||||
* Description: Format a local time/date as integer
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing idate() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//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);
|
||||
|
||||
//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 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'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' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
);
|
||||
|
||||
// loop through each element of the array for format
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( idate($value) );
|
||||
var_dump( idate($value, $timestamp) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing idate() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
|
||||
Warning: idate(): Unrecognized date format token. in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): Unrecognized date format token. in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
|
||||
Warning: idate(): Unrecognized date format token. in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): Unrecognized date format token. in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float 10.5--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: idate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: idate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: idate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: idate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
|
||||
Warning: idate(): Unrecognized date format token. in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): Unrecognized date format token. in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
|
||||
Warning: idate(): Unrecognized date format token. in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): Unrecognized date format token. in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: idate() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: idate(): idate format is one char in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,191 +0,0 @@
|
||||
--TEST--
|
||||
Test idate() function : usage variation - Passing unexpected values to second optional argument 'timestamp'.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int idate(string format [, int timestamp])
|
||||
* Description: Format a local time/date as integer
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing idate() : usage variation ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$format = 'Y';
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( idate($format, $value) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing idate() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
int(1970)
|
||||
|
||||
--float -10.5--
|
||||
int(1970)
|
||||
|
||||
--float .5--
|
||||
int(1970)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: idate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: idate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: idate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: idate() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
int(1970)
|
||||
|
||||
--lowercase null--
|
||||
int(1970)
|
||||
|
||||
--lowercase true--
|
||||
int(1970)
|
||||
|
||||
--lowercase false--
|
||||
int(1970)
|
||||
|
||||
--uppercase TRUE--
|
||||
int(1970)
|
||||
|
||||
--uppercase FALSE--
|
||||
int(1970)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: idate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: idate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: idate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: idate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: idate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: idate() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: idate() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: idate() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
int(1970)
|
||||
|
||||
--unset var--
|
||||
int(1970)
|
||||
===DONE===
|
@ -1,658 +0,0 @@
|
||||
--TEST--
|
||||
Test localtime() function : usage variation - Passing unexpected values to first argument 'timestamp'.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : array localtime([int timestamp [, bool associative_array]])
|
||||
* Description: Returns the results of the C system call localtime as an associative array
|
||||
* if the associative_array argument is set to 1 other wise it is a regular array
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing localtime() : usage variation ***\n";
|
||||
|
||||
date_default_timezone_set("UTC");
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$is_associative = true;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( localtime($value) );
|
||||
var_dump( localtime($value, $is_associative) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing localtime() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--float -10.5--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(50)
|
||||
[1]=>
|
||||
int(59)
|
||||
[2]=>
|
||||
int(23)
|
||||
[3]=>
|
||||
int(31)
|
||||
[4]=>
|
||||
int(11)
|
||||
[5]=>
|
||||
int(69)
|
||||
[6]=>
|
||||
int(3)
|
||||
[7]=>
|
||||
int(364)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(50)
|
||||
["tm_min"]=>
|
||||
int(59)
|
||||
["tm_hour"]=>
|
||||
int(23)
|
||||
["tm_mday"]=>
|
||||
int(31)
|
||||
["tm_mon"]=>
|
||||
int(11)
|
||||
["tm_year"]=>
|
||||
int(69)
|
||||
["tm_wday"]=>
|
||||
int(3)
|
||||
["tm_yday"]=>
|
||||
int(364)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--float .5--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(0)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(0)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--lowercase null--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(0)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--lowercase true--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(1)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--lowercase false--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(0)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--uppercase TRUE--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(1)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--uppercase FALSE--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(0)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: localtime() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(0)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--unset var--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(0)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
===DONE===
|
@ -1,643 +0,0 @@
|
||||
--TEST--
|
||||
Test localtime() function : usage variation - Passing unexpected values to second argument 'associative_array'.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : array localtime([int timestamp [, bool associative_array]])
|
||||
* Description: Returns the results of the C system call localtime as an associative array
|
||||
* if the associative_array argument is set to 1 other wise it is a regular array
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing localtime() : usage variation ***\n";
|
||||
|
||||
date_default_timezone_set("UTC");
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$timestamp = 10;
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for associative_array
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( localtime($timestamp, $value) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing localtime() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--int 1--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--int 12345--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--int -12345--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--float 10.5--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--float -10.5--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--float 12.3456789000e10--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--float -12.3456789000e10--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--float .5--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: localtime() expects parameter 2 to be bool, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: localtime() expects parameter 2 to be bool, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: localtime() expects parameter 2 to be bool, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: localtime() expects parameter 2 to be bool, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--lowercase null--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--lowercase true--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--lowercase false--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--uppercase TRUE--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--uppercase FALSE--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--empty string DQ--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--empty string SQ--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--string DQ--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--string SQ--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--mixed case string--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--heredoc--
|
||||
array(9) {
|
||||
["tm_sec"]=>
|
||||
int(10)
|
||||
["tm_min"]=>
|
||||
int(0)
|
||||
["tm_hour"]=>
|
||||
int(0)
|
||||
["tm_mday"]=>
|
||||
int(1)
|
||||
["tm_mon"]=>
|
||||
int(0)
|
||||
["tm_year"]=>
|
||||
int(70)
|
||||
["tm_wday"]=>
|
||||
int(4)
|
||||
["tm_yday"]=>
|
||||
int(0)
|
||||
["tm_isdst"]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: localtime() expects parameter 2 to be bool, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: localtime() expects parameter 2 to be bool, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
--unset var--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(0)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(70)
|
||||
[6]=>
|
||||
int(4)
|
||||
[7]=>
|
||||
int(0)
|
||||
[8]=>
|
||||
int(0)
|
||||
}
|
||||
===DONE===
|
@ -1,224 +0,0 @@
|
||||
--TEST--
|
||||
Test mktime() function : usage variation - Passing unexpected values to first argument $hour.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] )
|
||||
* Description: Get Unix timestamp for a date
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mktime() : 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 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
|
||||
);
|
||||
|
||||
$hour = 10;
|
||||
$minute = 30;
|
||||
$sec = 45;
|
||||
$month = 7;
|
||||
$day = 2;
|
||||
$year = 1963;
|
||||
$is_dst = 0;
|
||||
|
||||
foreach($inputs as $variation =>$hour) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( mktime($hour) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mktime() : usage variation - unexpected values to first argument $hour***
|
||||
|
||||
-- int 0 --
|
||||
int(%i)
|
||||
|
||||
-- int 12345 --
|
||||
int(%i)
|
||||
|
||||
-- int -12345 --
|
||||
int(%i)
|
||||
|
||||
-- float 10.5 --
|
||||
int(%i)
|
||||
|
||||
-- float -10.5 --
|
||||
int(%i)
|
||||
|
||||
-- float .5 --
|
||||
int(%i)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: mktime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: mktime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: mktime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: mktime() expects parameter 1 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
int(%i)
|
||||
|
||||
-- lowercase null --
|
||||
int(%i)
|
||||
|
||||
-- lowercase true --
|
||||
int(%i)
|
||||
|
||||
-- lowercase false --
|
||||
int(%i)
|
||||
|
||||
-- uppercase TRUE --
|
||||
int(%i)
|
||||
|
||||
-- uppercase FALSE --
|
||||
int(%i)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: mktime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: mktime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: mktime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: mktime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: mktime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: mktime() expects parameter 1 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: mktime() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: mktime() expects parameter 1 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
int(%i)
|
||||
|
||||
-- unset var --
|
||||
int(%i)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: mktime() expects parameter 1 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,218 +0,0 @@
|
||||
--TEST--
|
||||
Test mktime() function : usage variation - Passing unexpected values to second argument $minute.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] )
|
||||
* Description: Get Unix timestamp for a date
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mktime() : 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 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
|
||||
);
|
||||
|
||||
$hour = 10;
|
||||
|
||||
foreach($inputs as $variation =>$minute) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( mktime($hour, $minute) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mktime() : usage variation - unexpected values to second argument $minute***
|
||||
|
||||
-- int 0 --
|
||||
int(%i)
|
||||
|
||||
-- int 12345 --
|
||||
int(%i)
|
||||
|
||||
-- int -12345 --
|
||||
int(%i)
|
||||
|
||||
-- float 10.5 --
|
||||
int(%i)
|
||||
|
||||
-- float -10.5 --
|
||||
int(%i)
|
||||
|
||||
-- float .5 --
|
||||
int(%i)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: mktime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: mktime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: mktime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: mktime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
int(%i)
|
||||
|
||||
-- lowercase null --
|
||||
int(%i)
|
||||
|
||||
-- lowercase true --
|
||||
int(%i)
|
||||
|
||||
-- lowercase false --
|
||||
int(%i)
|
||||
|
||||
-- uppercase TRUE --
|
||||
int(%i)
|
||||
|
||||
-- uppercase FALSE --
|
||||
int(%i)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: mktime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: mktime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: mktime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: mktime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: mktime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: mktime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: mktime() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: mktime() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
int(%i)
|
||||
|
||||
-- unset var --
|
||||
int(%i)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: mktime() expects parameter 2 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,219 +0,0 @@
|
||||
--TEST--
|
||||
Test mktime() function : usage variation - Passing unexpected values to third argument $second.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] )
|
||||
* Description: Get Unix timestamp for a date
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mktime() : 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 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
|
||||
);
|
||||
|
||||
$hour = 10;
|
||||
$minute = 30;
|
||||
|
||||
foreach($inputs as $variation =>$second) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( mktime($hour, $minute, $second) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mktime() : usage variation - unexpected values to third argument $second***
|
||||
|
||||
-- int 0 --
|
||||
int(%i)
|
||||
|
||||
-- int 12345 --
|
||||
int(%i)
|
||||
|
||||
-- int -12345 --
|
||||
int(%i)
|
||||
|
||||
-- float 10.5 --
|
||||
int(%i)
|
||||
|
||||
-- float -10.5 --
|
||||
int(%i)
|
||||
|
||||
-- float .5 --
|
||||
int(%i)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: mktime() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: mktime() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: mktime() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: mktime() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
int(%i)
|
||||
|
||||
-- lowercase null --
|
||||
int(%i)
|
||||
|
||||
-- lowercase true --
|
||||
int(%i)
|
||||
|
||||
-- lowercase false --
|
||||
int(%i)
|
||||
|
||||
-- uppercase TRUE --
|
||||
int(%i)
|
||||
|
||||
-- uppercase FALSE --
|
||||
int(%i)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: mktime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: mktime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: mktime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: mktime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: mktime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: mktime() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: mktime() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: mktime() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
int(%i)
|
||||
|
||||
-- unset var --
|
||||
int(%i)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: mktime() expects parameter 3 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,220 +0,0 @@
|
||||
--TEST--
|
||||
Test mktime() function : usage variation - Passing unexpected values to forth argument $month.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] )
|
||||
* Description: Get Unix timestamp for a date
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mktime() : usage variation - unexpected values to forth 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 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
|
||||
);
|
||||
|
||||
$hour = 10;
|
||||
$minute = 30;
|
||||
$second = 45;
|
||||
|
||||
foreach($inputs as $variation =>$month) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( mktime($hour, $minute, $second, $month) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mktime() : usage variation - unexpected values to forth argument $month***
|
||||
|
||||
-- int 0 --
|
||||
int(%i)
|
||||
|
||||
-- int 12345 --
|
||||
%rint\(-?[1-9][0-9]*\)|bool\(false\)%r
|
||||
|
||||
-- int -12345 --
|
||||
%rint\(-?[1-9][0-9]*\)|bool\(false\)%r
|
||||
|
||||
-- float 10.5 --
|
||||
int(%i)
|
||||
|
||||
-- float -10.5 --
|
||||
int(%i)
|
||||
|
||||
-- float .5 --
|
||||
int(%i)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: mktime() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: mktime() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: mktime() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: mktime() expects parameter 4 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
int(%i)
|
||||
|
||||
-- lowercase null --
|
||||
int(%i)
|
||||
|
||||
-- lowercase true --
|
||||
int(%i)
|
||||
|
||||
-- lowercase false --
|
||||
int(%i)
|
||||
|
||||
-- uppercase TRUE --
|
||||
int(%i)
|
||||
|
||||
-- uppercase FALSE --
|
||||
int(%i)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: mktime() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: mktime() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: mktime() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: mktime() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: mktime() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: mktime() expects parameter 4 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: mktime() expects parameter 4 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: mktime() expects parameter 4 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
int(%i)
|
||||
|
||||
-- unset var --
|
||||
int(%i)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: mktime() expects parameter 4 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,221 +0,0 @@
|
||||
--TEST--
|
||||
Test mktime() function : usage variation - Passing unexpected values to fifth argument $day.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] )
|
||||
* Description: Get Unix timestamp for a date
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mktime() : usage variation - unexpected values to fifth 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 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
|
||||
);
|
||||
|
||||
$hour = 10;
|
||||
$minute = 30;
|
||||
$second = 45;
|
||||
$month = 7;
|
||||
|
||||
foreach($inputs as $variation =>$day) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( mktime($hour, $minute, $second, $month, $day) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mktime() : usage variation - unexpected values to fifth argument $day***
|
||||
|
||||
-- int 0 --
|
||||
int(%i)
|
||||
|
||||
-- int 12345 --
|
||||
%rint\(-?[1-9][0-9]*\)|bool\(false\)%r
|
||||
|
||||
-- int -12345 --
|
||||
int(%i)
|
||||
|
||||
-- float 10.5 --
|
||||
int(%i)
|
||||
|
||||
-- float -10.5 --
|
||||
int(%i)
|
||||
|
||||
-- float .5 --
|
||||
int(%i)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: mktime() expects parameter 5 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: mktime() expects parameter 5 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: mktime() expects parameter 5 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: mktime() expects parameter 5 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
int(%i)
|
||||
|
||||
-- lowercase null --
|
||||
int(%i)
|
||||
|
||||
-- lowercase true --
|
||||
int(%i)
|
||||
|
||||
-- lowercase false --
|
||||
int(%i)
|
||||
|
||||
-- uppercase TRUE --
|
||||
int(%i)
|
||||
|
||||
-- uppercase FALSE --
|
||||
int(%i)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: mktime() expects parameter 5 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: mktime() expects parameter 5 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: mktime() expects parameter 5 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: mktime() expects parameter 5 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: mktime() expects parameter 5 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: mktime() expects parameter 5 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: mktime() expects parameter 5 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: mktime() expects parameter 5 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
int(%i)
|
||||
|
||||
-- unset var --
|
||||
int(%i)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: mktime() expects parameter 5 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,222 +0,0 @@
|
||||
--TEST--
|
||||
Test mktime() function : usage variation - Passing unexpected values to sixth argument $year.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] )
|
||||
* Description: Get Unix timestamp for a date
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mktime() : usage variation - unexpected values to sixth 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 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
|
||||
);
|
||||
|
||||
$hour = 10;
|
||||
$minute = 30;
|
||||
$second = 45;
|
||||
$month = 7;
|
||||
$day = 2;
|
||||
|
||||
foreach($inputs as $variation =>$year) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( mktime($hour, $minute, $second, $month, $day, $year) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mktime() : usage variation - unexpected values to sixth argument $year***
|
||||
|
||||
-- int 0 --
|
||||
int(%i)
|
||||
|
||||
-- int 12345 --
|
||||
%rint\(-?[1-9][0-9]*\)|bool\(false\)%r
|
||||
|
||||
-- int -12345 --
|
||||
%rint\(-?[1-9][0-9]*\)|bool\(false\)%r
|
||||
|
||||
-- float 10.5 --
|
||||
int(%i)
|
||||
|
||||
-- float -10.5 --
|
||||
%rint\(-?[1-9][0-9]*\)|bool\(false\)%r
|
||||
|
||||
-- float .5 --
|
||||
int(%i)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: mktime() expects parameter 6 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: mktime() expects parameter 6 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: mktime() expects parameter 6 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: mktime() expects parameter 6 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
int(%i)
|
||||
|
||||
-- lowercase null --
|
||||
int(%i)
|
||||
|
||||
-- lowercase true --
|
||||
int(%i)
|
||||
|
||||
-- lowercase false --
|
||||
int(%i)
|
||||
|
||||
-- uppercase TRUE --
|
||||
int(%i)
|
||||
|
||||
-- uppercase FALSE --
|
||||
int(%i)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: mktime() expects parameter 6 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: mktime() expects parameter 6 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: mktime() expects parameter 6 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: mktime() expects parameter 6 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: mktime() expects parameter 6 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: mktime() expects parameter 6 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: mktime() expects parameter 6 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: mktime() expects parameter 6 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
int(%i)
|
||||
|
||||
-- unset var --
|
||||
int(%i)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: mktime() expects parameter 6 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,222 +0,0 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Passing unexpected values to first argument 'format'.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string strftime(string format [, int timestamp])
|
||||
* Description: Format a local time/date according to locale settings
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing strftime() : usage variation ***\n";
|
||||
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$timestamp = 10;
|
||||
|
||||
//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);
|
||||
|
||||
//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 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'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' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
);
|
||||
|
||||
// loop through each element of the array for format
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(1) "0"
|
||||
string(1) "0"
|
||||
|
||||
--int 1--
|
||||
string(1) "1"
|
||||
string(1) "1"
|
||||
|
||||
--int 12345--
|
||||
string(5) "12345"
|
||||
string(5) "12345"
|
||||
|
||||
--int -12345--
|
||||
string(6) "-12345"
|
||||
string(6) "-12345"
|
||||
|
||||
--float 10.5--
|
||||
string(4) "10.5"
|
||||
string(4) "10.5"
|
||||
|
||||
--float -10.5--
|
||||
string(5) "-10.5"
|
||||
string(5) "-10.5"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
string(12) "123456789000"
|
||||
string(12) "123456789000"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
string(13) "-123456789000"
|
||||
string(13) "-123456789000"
|
||||
|
||||
--float .5--
|
||||
string(3) "0.5"
|
||||
string(3) "0.5"
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: strftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: strftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: strftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: strftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strftime() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
string(1) "1"
|
||||
string(1) "1"
|
||||
|
||||
--lowercase false--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(1) "1"
|
||||
string(1) "1"
|
||||
|
||||
--uppercase FALSE--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
string(14) "Class A object"
|
||||
string(14) "Class A object"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: strftime() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strftime() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
bool(false)
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,191 +0,0 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Passing unexpected values to second argument 'timestamp'.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string strftime(string format [, int timestamp])
|
||||
* Description: Format a local time/date according to locale settings
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing strftime() : usage variation ***\n";
|
||||
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
// Initialise all required variables
|
||||
$format = '%b %d %Y %H:%M:%S';
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// 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,
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($format, $value) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
string(20) "Jan 01 1970 05:30:10"
|
||||
|
||||
--float -10.5--
|
||||
string(20) "Jan 01 1970 05:29:50"
|
||||
|
||||
--float .5--
|
||||
string(20) "Jan 01 1970 05:30:00"
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(20) "Jan 01 1970 05:30:00"
|
||||
|
||||
--lowercase null--
|
||||
string(20) "Jan 01 1970 05:30:00"
|
||||
|
||||
--lowercase true--
|
||||
string(20) "Jan 01 1970 05:30:01"
|
||||
|
||||
--lowercase false--
|
||||
string(20) "Jan 01 1970 05:30:00"
|
||||
|
||||
--uppercase TRUE--
|
||||
string(20) "Jan 01 1970 05:30:01"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(20) "Jan 01 1970 05:30:00"
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(20) "Jan 01 1970 05:30:00"
|
||||
|
||||
--unset var--
|
||||
string(20) "Jan 01 1970 05:30:00"
|
||||
===DONE===
|
@ -1,205 +0,0 @@
|
||||
--TEST--
|
||||
Test timezone_name_from_abbr() function : usage variation - Passing unexpected values to first argument $abbr.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string timezone_name_from_abbr ( string $abbr [, int $gmtOffset= -1 [, int $isdst= -1 ]] )
|
||||
* Description: Returns the timezone name from abbrevation
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing timezone_name_from_abbr() : usage variation - unexpected values to first argument \$abbr***\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 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
|
||||
);
|
||||
|
||||
$gmtOffset= 3600;
|
||||
$isdst = 1;
|
||||
|
||||
foreach($inputs as $variation =>$abbr) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( timezone_name_from_abbr($abbr, $gmtOffset, $isdst) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing timezone_name_from_abbr() : usage variation - unexpected values to first argument $abbr***
|
||||
|
||||
-- int 0 --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- int 12345 --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- int -12345 --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- float 10.5 --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- float -10.5 --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- float .5 --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- lowercase null --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- lowercase true --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- lowercase false --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- uppercase TRUE --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- uppercase FALSE --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- empty string DQ --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- empty string SQ --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- string DQ --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- string SQ --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- mixed case string --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- heredoc --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- instance of classWithToString --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- unset var --
|
||||
string(13) "Europe/London"
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 1 to be string, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,219 +0,0 @@
|
||||
--TEST--
|
||||
Test timezone_name_from_abbr() function : usage variation - Passing unexpected values to second argument $gmtOffset.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string timezone_name_from_abbr ( string $abbr [, int $gmtOffset= -1 [, int $isdst= -1 ]] )
|
||||
* Description: Returns the timezone name from abbrevation
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing timezone_name_from_abbr() : usage variation - unexpected values to second argument \$gmtOffset***\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 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
|
||||
);
|
||||
|
||||
$abbr= "GMT";
|
||||
$isdst = 1;
|
||||
|
||||
foreach($inputs as $variation =>$gmtOffset) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( timezone_name_from_abbr($abbr, $gmtOffset, $isdst) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing timezone_name_from_abbr() : usage variation - unexpected values to second argument $gmtOffset***
|
||||
|
||||
-- int 0 --
|
||||
string(3) "UTC"
|
||||
|
||||
-- int 12345 --
|
||||
string(3) "UTC"
|
||||
|
||||
-- int -12345 --
|
||||
string(3) "UTC"
|
||||
|
||||
-- float 10.5 --
|
||||
string(3) "UTC"
|
||||
|
||||
-- float -10.5 --
|
||||
string(3) "UTC"
|
||||
|
||||
-- float .5 --
|
||||
string(3) "UTC"
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 2 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
string(3) "UTC"
|
||||
|
||||
-- lowercase null --
|
||||
string(3) "UTC"
|
||||
|
||||
-- lowercase true --
|
||||
string(3) "UTC"
|
||||
|
||||
-- lowercase false --
|
||||
string(3) "UTC"
|
||||
|
||||
-- uppercase TRUE --
|
||||
string(3) "UTC"
|
||||
|
||||
-- uppercase FALSE --
|
||||
string(3) "UTC"
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 2 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 2 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
string(3) "UTC"
|
||||
|
||||
-- unset var --
|
||||
string(3) "UTC"
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 2 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,219 +0,0 @@
|
||||
--TEST--
|
||||
Test timezone_name_from_abbr() function : usage variation - Passing unexpected values to third argument $isdst.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string timezone_name_from_abbr ( string $abbr [, int $gmtOffset= -1 [, int $isdst= -1 ]] )
|
||||
* Description: Returns the timezone name from abbrevation
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing timezone_name_from_abbr() : usage variation - unexpected values to third argument \$isdst***\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 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
|
||||
);
|
||||
|
||||
$abbr= "GMT";
|
||||
$gmtOffset = 3600;
|
||||
|
||||
foreach($inputs as $variation =>$isdst) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( timezone_name_from_abbr($abbr, $gmtOffset, $isdst) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing timezone_name_from_abbr() : usage variation - unexpected values to third argument $isdst***
|
||||
|
||||
-- int 0 --
|
||||
string(3) "UTC"
|
||||
|
||||
-- int 12345 --
|
||||
string(3) "UTC"
|
||||
|
||||
-- int -12345 --
|
||||
string(3) "UTC"
|
||||
|
||||
-- float 10.5 --
|
||||
string(3) "UTC"
|
||||
|
||||
-- float -10.5 --
|
||||
string(3) "UTC"
|
||||
|
||||
-- float .5 --
|
||||
string(3) "UTC"
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 3 to be int, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
string(3) "UTC"
|
||||
|
||||
-- lowercase null --
|
||||
string(3) "UTC"
|
||||
|
||||
-- lowercase true --
|
||||
string(3) "UTC"
|
||||
|
||||
-- lowercase false --
|
||||
string(3) "UTC"
|
||||
|
||||
-- uppercase TRUE --
|
||||
string(3) "UTC"
|
||||
|
||||
-- uppercase FALSE --
|
||||
string(3) "UTC"
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 3 to be int, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 3 to be int, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
string(3) "UTC"
|
||||
|
||||
-- unset var --
|
||||
string(3) "UTC"
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: timezone_name_from_abbr() expects parameter 3 to be int, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,200 +0,0 @@
|
||||
--TEST--
|
||||
Test timezone_offset_get() function : usage variation - Passing unexpected values to first argument $object.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int timezone_offset_get ( DateTimeZone $object , DateTime $datetime )
|
||||
* Description: Returns the timezone offset from GMT
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTimeZone::getOffset()
|
||||
*/
|
||||
|
||||
echo "*** Testing timezone_offset_get() : usage variation - unexpected values to first argument \$object***\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
|
||||
);
|
||||
|
||||
$datetime = new DateTime("2009-01-31 15:14:10");
|
||||
|
||||
foreach($inputs as $variation =>$object) {
|
||||
echo "\n-- $variation --\n";
|
||||
try {
|
||||
var_dump( timezone_offset_get($object, $datetime) );
|
||||
} catch (Error $ex) {
|
||||
echo $ex->getMessage()."\n";
|
||||
}
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
*** Testing timezone_offset_get() : usage variation - unexpected values to first argument $object***
|
||||
|
||||
-- int 0 --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, int given
|
||||
|
||||
-- int 1 --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, int given
|
||||
|
||||
-- int 12345 --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, int given
|
||||
|
||||
-- int -12345 --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, int given
|
||||
|
||||
-- float 10.5 --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, float given
|
||||
|
||||
-- float -10.5 --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, float given
|
||||
|
||||
-- float .5 --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, float given
|
||||
|
||||
-- empty array --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, array given
|
||||
|
||||
-- int indexed array --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, array given
|
||||
|
||||
-- associative array --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, array given
|
||||
|
||||
-- nested arrays --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, array given
|
||||
|
||||
-- uppercase NULL --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, null given
|
||||
|
||||
-- lowercase null --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, null given
|
||||
|
||||
-- lowercase true --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, bool given
|
||||
|
||||
-- lowercase false --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, bool given
|
||||
|
||||
-- uppercase TRUE --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, bool given
|
||||
|
||||
-- uppercase FALSE --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, bool given
|
||||
|
||||
-- empty string DQ --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, string given
|
||||
|
||||
-- empty string SQ --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, string given
|
||||
|
||||
-- string DQ --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, string given
|
||||
|
||||
-- string SQ --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, string given
|
||||
|
||||
-- mixed case string --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, string given
|
||||
|
||||
-- heredoc --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, string given
|
||||
|
||||
-- instance of classWithToString --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, instance of classWithToString given
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, instance of classWithoutToString given
|
||||
|
||||
-- undefined var --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, null given
|
||||
|
||||
-- unset var --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, null given
|
||||
|
||||
-- resource --
|
||||
Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, resource given
|
||||
===DONE===
|
@ -1,200 +0,0 @@
|
||||
--TEST--
|
||||
Test timezone_offset_get() function : usage variation - Passing unexpected values to second argument $datetime.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int timezone_offset_get ( DateTimeZone $object , DateTime $datetime )
|
||||
* Description: Returns the timezone offset from GMT
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTimeZone::getOffset()
|
||||
*/
|
||||
|
||||
echo "*** Testing timezone_offset_get() : usage variation - unexpected values to second argument \$datetime***\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 DateTimezone("Europe/London");
|
||||
|
||||
foreach($inputs as $variation =>$datetime) {
|
||||
echo "\n-- $variation --\n";
|
||||
try {
|
||||
var_dump( timezone_offset_get($object, $datetime) );
|
||||
} catch (Error $ex) {
|
||||
echo $ex->getMessage()."\n";
|
||||
}
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
*** Testing timezone_offset_get() : usage variation - unexpected values to second argument $datetime***
|
||||
|
||||
-- int 0 --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, int given
|
||||
|
||||
-- int 1 --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, int given
|
||||
|
||||
-- int 12345 --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, int given
|
||||
|
||||
-- int -12345 --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, int given
|
||||
|
||||
-- float 10.5 --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, float given
|
||||
|
||||
-- float -10.5 --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, float given
|
||||
|
||||
-- float .5 --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, float given
|
||||
|
||||
-- empty array --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, array given
|
||||
|
||||
-- int indexed array --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, array given
|
||||
|
||||
-- associative array --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, array given
|
||||
|
||||
-- nested arrays --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, array given
|
||||
|
||||
-- uppercase NULL --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, null given
|
||||
|
||||
-- lowercase null --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, null given
|
||||
|
||||
-- lowercase true --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, bool given
|
||||
|
||||
-- lowercase false --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, bool given
|
||||
|
||||
-- uppercase TRUE --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, bool given
|
||||
|
||||
-- uppercase FALSE --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, bool given
|
||||
|
||||
-- empty string DQ --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, string given
|
||||
|
||||
-- empty string SQ --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, string given
|
||||
|
||||
-- string DQ --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, string given
|
||||
|
||||
-- string SQ --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, string given
|
||||
|
||||
-- mixed case string --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, string given
|
||||
|
||||
-- heredoc --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, string given
|
||||
|
||||
-- instance of classWithToString --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, instance of classWithToString given
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, instance of classWithoutToString given
|
||||
|
||||
-- undefined var --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, null given
|
||||
|
||||
-- unset var --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, null given
|
||||
|
||||
-- resource --
|
||||
Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, resource given
|
||||
===DONE===
|
@ -1,239 +0,0 @@
|
||||
--TEST--
|
||||
Test timezone_open function : usage variation - Passing unexpected values to first argument $timezone.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : DateTimeZone timezone_open ( string $timezone )
|
||||
* Description: Returns new DateTimeZone object
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTime::__construct()
|
||||
*/
|
||||
|
||||
echo "*** Testing timezone_open() : 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,
|
||||
|
||||
// float data
|
||||
'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
|
||||
);
|
||||
|
||||
foreach($inputs as $variation =>$timezone) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( timezone_open($timezone) );
|
||||
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing timezone_open() : usage variation - unexpected values to first argument $timezone***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone (0) in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone (1) in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone (12345) in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone (10.5) in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone (0.5) in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: timezone_open() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: timezone_open() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: timezone_open() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: timezone_open() expects parameter 1 to be string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone (1) in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone (1) in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone (string) in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone (string) in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone (sTrInG) in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone (hello world) in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone (Class A object) in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: timezone_open() expects parameter 1 to be string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: timezone_open() expects parameter 1 to be string, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,250 +0,0 @@
|
||||
--TEST--
|
||||
Test timezone_transitions_get() function : usage variation - Passing unexpected values to first argument $object.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : array timezone_transitions_get ( DateTimeZone $object, [ int $timestamp_begin [, int $timestamp_end ]] )
|
||||
* Description: Returns all transitions for the timezone
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTimeZone::getTransitions()
|
||||
*/
|
||||
|
||||
echo "*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument \$object***\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
|
||||
);
|
||||
|
||||
foreach($inputs as $variation =>$object) {
|
||||
echo "\n-- $variation --\n";
|
||||
var_dump( timezone_transitions_get($object) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument $object***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, int given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, float given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, bool given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, resource given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,279 +0,0 @@
|
||||
--TEST--
|
||||
Test timezone_transitions_get() function : usage variation - Passing unexpected values to first argument $timestamp_begin.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : array timezone_transitions_get ( DateTimeZone $object, [ int $timestamp_begin [, int $timestamp_end ]] )
|
||||
* Description: Returns all transitions for the timezone
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTimeZone::getTransitions()
|
||||
*/
|
||||
|
||||
echo "*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument \$timestamp_begin ***\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
|
||||
);
|
||||
|
||||
$tz = timezone_open("Europe/London");
|
||||
$timestamp_end = mktime(0, 0, 0, 1, 1, 1975);
|
||||
|
||||
foreach($inputs as $variation =>$timestamp_begin) {
|
||||
echo "\n-- $variation --\n";
|
||||
$tran = timezone_transitions_get($tz, $timestamp_begin, $timestamp_end);
|
||||
var_dump( gettype($tran) );
|
||||
var_dump( count($tran) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument $timestamp_begin ***
|
||||
|
||||
-- int 0 --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- int 1 --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- int 12345 --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- int -12345 --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- float 10.5 --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- float -10.5 --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- float .5 --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 2 to be int, array given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 2 to be int, array given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 2 to be int, array given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 2 to be int, array given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- uppercase NULL --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- lowercase null --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- lowercase true --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- lowercase false --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- uppercase TRUE --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- uppercase FALSE --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 2 to be int, string given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 2 to be int, string given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 2 to be int, string given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 2 to be int, string given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 2 to be int, string given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 2 to be int, string given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 2 to be int, object given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 2 to be int, object given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- undefined var --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- unset var --
|
||||
string(5) "array"
|
||||
int(8)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 2 to be int, resource given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
===DONE===
|
@ -1,279 +0,0 @@
|
||||
--TEST--
|
||||
Test timezone_transitions_get() function : usage variation - Passing unexpected values to first argument $timestamp_env.
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : array timezone_transitions_get ( DateTimeZone $object, [ int $timestamp_begin [, int $timestamp_end ]] )
|
||||
* Description: Returns all transitions for the timezone
|
||||
* Source code: ext/date/php_date.c
|
||||
* Alias to functions: DateTimeZone::getTransitions()
|
||||
*/
|
||||
|
||||
echo "*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument \$timestamp_end ***\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
|
||||
);
|
||||
|
||||
$tz = timezone_open("Europe/London");
|
||||
$timestamp_begin = mktime(0, 0, 0, 1, 1, 1975);
|
||||
|
||||
foreach($inputs as $variation =>$timestamp_end) {
|
||||
echo "\n-- $variation --\n";
|
||||
$tran = timezone_transitions_get($tz, $timestamp_begin, $timestamp_end);
|
||||
var_dump( gettype($tran) );
|
||||
var_dump( count($tran) );
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose( $file_handle );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument $timestamp_end ***
|
||||
|
||||
-- int 0 --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- int 1 --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- int 12345 --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- int -12345 --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- float 10.5 --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- float -10.5 --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- float .5 --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 3 to be int, array given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 3 to be int, array given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 3 to be int, array given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 3 to be int, array given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- uppercase NULL --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- lowercase null --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- lowercase true --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- lowercase false --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- uppercase TRUE --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- uppercase FALSE --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 3 to be int, string given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 3 to be int, string given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 3 to be int, string given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 3 to be int, string given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 3 to be int, string given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 3 to be int, string given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 3 to be int, object given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 3 to be int, object given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
|
||||
-- undefined var --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- unset var --
|
||||
string(5) "array"
|
||||
int(1)
|
||||
|
||||
-- resource --
|
||||
|
||||
Warning: timezone_transitions_get() expects parameter 3 to be int, resource given in %s on line %d
|
||||
string(7) "boolean"
|
||||
|
||||
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
|
||||
int(1)
|
||||
===DONE===
|
@ -1,214 +0,0 @@
|
||||
--TEST--
|
||||
Test exif_imagetype() function : usage variations - different types for filename argument
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/* Prototype : int exif_imagetype ( string $filename )
|
||||
* Description: Determine the type of an image
|
||||
* Source code: ext/exif/exif.c
|
||||
*/
|
||||
|
||||
echo "*** Testing exif_imagetype() : different types for filename argument ***\n";
|
||||
// initialize all required variables
|
||||
|
||||
// get an unset variable
|
||||
$unset_var = 'string_val';
|
||||
unset($unset_var);
|
||||
|
||||
// declaring a class
|
||||
class sample {
|
||||
public function __toString() {
|
||||
return "obj'ct";
|
||||
}
|
||||
}
|
||||
|
||||
// Defining resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
// array with different values
|
||||
$values = array (
|
||||
|
||||
// integer values
|
||||
0,
|
||||
1,
|
||||
12345,
|
||||
-2345,
|
||||
|
||||
// float values
|
||||
10.5,
|
||||
-10.5,
|
||||
10.1234567e10,
|
||||
10.7654321E-10,
|
||||
.5,
|
||||
|
||||
// array values
|
||||
array(),
|
||||
array(0),
|
||||
array(1),
|
||||
array(1, 2),
|
||||
array('color' => 'red', 'item' => 'pen'),
|
||||
|
||||
// boolean values
|
||||
true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// empty string
|
||||
"",
|
||||
'',
|
||||
|
||||
// undefined variable
|
||||
$undefined_var,
|
||||
|
||||
// unset variable
|
||||
$unset_var,
|
||||
|
||||
// objects
|
||||
new sample(),
|
||||
|
||||
// resource
|
||||
$file_handle,
|
||||
|
||||
NULL,
|
||||
null
|
||||
);
|
||||
|
||||
|
||||
// loop through each element of the array and check the working of exif_imagetype()
|
||||
// when $filename is supplied with different values
|
||||
|
||||
echo "\n--- Testing exif_imagetype() by supplying different values for 'filename' argument ---\n";
|
||||
$counter = 1;
|
||||
foreach($values as $filename) {
|
||||
echo "-- Iteration $counter --\n";
|
||||
var_dump( exif_imagetype($filename) );
|
||||
$counter ++;
|
||||
}
|
||||
|
||||
// closing the file
|
||||
fclose($file_handle);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing exif_imagetype() : different types for filename argument ***
|
||||
|
||||
Notice: Undefined variable: undefined_var in %s on line %d
|
||||
|
||||
Notice: Undefined variable: unset_var in %s on line %d
|
||||
|
||||
--- Testing exif_imagetype() by supplying different values for 'filename' argument ---
|
||||
-- Iteration 1 --
|
||||
|
||||
Warning: exif_imagetype(0): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 2 --
|
||||
|
||||
Warning: exif_imagetype(1): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 3 --
|
||||
|
||||
Warning: exif_imagetype(12345): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 4 --
|
||||
|
||||
Warning: exif_imagetype(-2345): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 5 --
|
||||
|
||||
Warning: exif_imagetype(10.5): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 6 --
|
||||
|
||||
Warning: exif_imagetype(-10.5): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 7 --
|
||||
|
||||
Warning: exif_imagetype(101234567000): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 8 --
|
||||
|
||||
Warning: exif_imagetype(1.07654321E-9): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 9 --
|
||||
|
||||
Warning: exif_imagetype(0.5): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 10 --
|
||||
|
||||
Warning: exif_imagetype() expects parameter 1 to be a valid path, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 11 --
|
||||
|
||||
Warning: exif_imagetype() expects parameter 1 to be a valid path, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 12 --
|
||||
|
||||
Warning: exif_imagetype() expects parameter 1 to be a valid path, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 13 --
|
||||
|
||||
Warning: exif_imagetype() expects parameter 1 to be a valid path, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 14 --
|
||||
|
||||
Warning: exif_imagetype() expects parameter 1 to be a valid path, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 15 --
|
||||
|
||||
Warning: exif_imagetype(1): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 16 --
|
||||
|
||||
Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 17 --
|
||||
|
||||
Warning: exif_imagetype(1): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 18 --
|
||||
|
||||
Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 19 --
|
||||
|
||||
Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 20 --
|
||||
|
||||
Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 21 --
|
||||
|
||||
Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 22 --
|
||||
|
||||
Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 23 --
|
||||
|
||||
Warning: exif_imagetype(obj'ct): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 24 --
|
||||
|
||||
Warning: exif_imagetype() expects parameter 1 to be a valid path, resource given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 25 --
|
||||
|
||||
Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 26 --
|
||||
|
||||
Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
|
||||
bool(false)
|
||||
Done
|
||||
|
||||
?>
|
||||
===Done===
|
@ -1,182 +0,0 @@
|
||||
--TEST--
|
||||
Test exif_tagname() function : usage variations - different types for index argument
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';
|
||||
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/* Prototype : string exif_tagname ( string $index )
|
||||
* Description: Get the header name for an index
|
||||
* Source code: ext/exif/exif.c
|
||||
*/
|
||||
|
||||
echo "*** Testing exif_tagname() : different types for index argument ***\n";
|
||||
// initialize all required variables
|
||||
|
||||
// get an unset variable
|
||||
$unset_var = 'string_val';
|
||||
unset($unset_var);
|
||||
|
||||
// declaring a class
|
||||
class sample {
|
||||
public function __toString() {
|
||||
return "obj'ct";
|
||||
}
|
||||
}
|
||||
|
||||
// Defining resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
// array with different values
|
||||
$values = array (
|
||||
|
||||
// integer values
|
||||
0,
|
||||
1,
|
||||
12345,
|
||||
-2345,
|
||||
|
||||
// float values
|
||||
10.5,
|
||||
-10.5,
|
||||
10.1234567e10,
|
||||
10.7654321E-10,
|
||||
.5,
|
||||
|
||||
// array values
|
||||
array(),
|
||||
array(0),
|
||||
array(1),
|
||||
array(1, 2),
|
||||
array('color' => 'red', 'item' => 'pen'),
|
||||
|
||||
// boolean values
|
||||
true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// empty string
|
||||
"",
|
||||
'',
|
||||
|
||||
// undefined variable
|
||||
$undefined_var,
|
||||
|
||||
// unset variable
|
||||
$unset_var,
|
||||
|
||||
// objects
|
||||
new sample(),
|
||||
|
||||
// resource
|
||||
$file_handle,
|
||||
|
||||
NULL,
|
||||
null
|
||||
);
|
||||
|
||||
|
||||
// loop through each element of the array and check the working of exif_tagname()
|
||||
// when $index argument is supplied with different values
|
||||
|
||||
echo "\n--- Testing exif_tagname() by supplying different values for 'index' argument ---\n";
|
||||
$counter = 1;
|
||||
foreach($values as $index) {
|
||||
echo "-- Iteration $counter --\n";
|
||||
var_dump( exif_tagname($index) );
|
||||
$counter ++;
|
||||
}
|
||||
|
||||
// closing the file
|
||||
fclose($file_handle);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing exif_tagname() : different types for index argument ***
|
||||
|
||||
Notice: Undefined variable: undefined_var in %s on line %d
|
||||
|
||||
Notice: Undefined variable: unset_var in %s on line %d
|
||||
|
||||
--- Testing exif_tagname() by supplying different values for 'index' argument ---
|
||||
-- Iteration 1 --
|
||||
bool(false)
|
||||
-- Iteration 2 --
|
||||
bool(false)
|
||||
-- Iteration 3 --
|
||||
bool(false)
|
||||
-- Iteration 4 --
|
||||
bool(false)
|
||||
-- Iteration 5 --
|
||||
bool(false)
|
||||
-- Iteration 6 --
|
||||
bool(false)
|
||||
-- Iteration 7 --
|
||||
bool(false)
|
||||
-- Iteration 8 --
|
||||
bool(false)
|
||||
-- Iteration 9 --
|
||||
bool(false)
|
||||
-- Iteration 10 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 11 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 12 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 13 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 14 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 15 --
|
||||
bool(false)
|
||||
-- Iteration 16 --
|
||||
bool(false)
|
||||
-- Iteration 17 --
|
||||
bool(false)
|
||||
-- Iteration 18 --
|
||||
bool(false)
|
||||
-- Iteration 19 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, string given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 20 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, string given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 21 --
|
||||
bool(false)
|
||||
-- Iteration 22 --
|
||||
bool(false)
|
||||
-- Iteration 23 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, object given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 24 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, resource given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 25 --
|
||||
bool(false)
|
||||
-- Iteration 26 --
|
||||
bool(false)
|
||||
Done
|
||||
|
||||
?>
|
||||
===Done===
|
@ -1,174 +0,0 @@
|
||||
--TEST--
|
||||
Test exif_tagname() function : usage variations - different types for index argument
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('exif')) print 'skip exif extension not available'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/* Prototype : string exif_tagname ( string $index )
|
||||
* Description: Get the header name for an index
|
||||
* Source code: ext/exif/exif.c
|
||||
*/
|
||||
|
||||
echo "*** Testing exif_tagname() : different types for index argument ***\n";
|
||||
// initialize all required variables
|
||||
|
||||
// get an unset variable
|
||||
$unset_var = 'string_val';
|
||||
unset($unset_var);
|
||||
|
||||
// declaring a class
|
||||
class sample {
|
||||
public function __toString() {
|
||||
return "obj'ct";
|
||||
}
|
||||
}
|
||||
|
||||
// Defining resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
// array with different values
|
||||
$values = array (
|
||||
|
||||
// integer values
|
||||
0,
|
||||
1,
|
||||
12345,
|
||||
-2345,
|
||||
|
||||
// float values
|
||||
10.5,
|
||||
-10.5,
|
||||
.5,
|
||||
|
||||
// array values
|
||||
array(),
|
||||
array(0),
|
||||
array(1),
|
||||
array(1, 2),
|
||||
array('color' => 'red', 'item' => 'pen'),
|
||||
|
||||
// boolean values
|
||||
true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// empty string
|
||||
"",
|
||||
'',
|
||||
|
||||
// undefined variable
|
||||
$undefined_var,
|
||||
|
||||
// unset variable
|
||||
$unset_var,
|
||||
|
||||
// objects
|
||||
new sample(),
|
||||
|
||||
// resource
|
||||
$file_handle,
|
||||
|
||||
NULL,
|
||||
null
|
||||
);
|
||||
|
||||
|
||||
// loop through each element of the array and check the working of exif_tagname()
|
||||
// when $index argument is supplied with different values
|
||||
|
||||
echo "\n--- Testing exif_tagname() by supplying different values for 'index' argument ---\n";
|
||||
$counter = 1;
|
||||
foreach($values as $index) {
|
||||
echo "-- Iteration $counter --\n";
|
||||
var_dump( exif_tagname($index) );
|
||||
$counter ++;
|
||||
}
|
||||
|
||||
// closing the file
|
||||
fclose($file_handle);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing exif_tagname() : different types for index argument ***
|
||||
|
||||
Notice: Undefined variable: undefined_var in %s on line %d
|
||||
|
||||
Notice: Undefined variable: unset_var in %s on line %d
|
||||
|
||||
--- Testing exif_tagname() by supplying different values for 'index' argument ---
|
||||
-- Iteration 1 --
|
||||
bool(false)
|
||||
-- Iteration 2 --
|
||||
bool(false)
|
||||
-- Iteration 3 --
|
||||
bool(false)
|
||||
-- Iteration 4 --
|
||||
bool(false)
|
||||
-- Iteration 5 --
|
||||
bool(false)
|
||||
-- Iteration 6 --
|
||||
bool(false)
|
||||
-- Iteration 7 --
|
||||
bool(false)
|
||||
-- Iteration 8 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 9 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 10 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 11 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 12 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 13 --
|
||||
bool(false)
|
||||
-- Iteration 14 --
|
||||
bool(false)
|
||||
-- Iteration 15 --
|
||||
bool(false)
|
||||
-- Iteration 16 --
|
||||
bool(false)
|
||||
-- Iteration 17 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, string given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 18 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, string given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 19 --
|
||||
bool(false)
|
||||
-- Iteration 20 --
|
||||
bool(false)
|
||||
-- Iteration 21 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, object given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 22 --
|
||||
|
||||
Warning: exif_tagname() expects parameter 1 to be int, resource given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 23 --
|
||||
bool(false)
|
||||
-- Iteration 24 --
|
||||
bool(false)
|
||||
Done
|
||||
|
||||
?>
|
||||
===Done===
|
@ -1,267 +0,0 @@
|
||||
--TEST--
|
||||
Test imagecolorallocate() function : usage variations - passing different data types to first argument
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')) {
|
||||
die('skip gd extension is not loaded');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue)
|
||||
* Description: Allocate a color for an image
|
||||
* Source code: ext/gd/gd.c
|
||||
*/
|
||||
|
||||
echo "*** Testing imagecolorallocate() : usage variations ***\n";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$red = 10;
|
||||
$green = 10;
|
||||
$blue = 10;
|
||||
|
||||
$fp = tmpfile();
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$values = 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 10.1234567e10' => 10.1234567e10,
|
||||
'float 10.7654321E-10' => 10.7654321E-10,
|
||||
'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
|
||||
"file resource" => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for im
|
||||
foreach($values as $key => $value) {
|
||||
echo "\n-- $key --\n";
|
||||
var_dump( imagecolorallocate($value, $red, $green, $blue) );
|
||||
};
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing imagecolorallocate() : usage variations ***
|
||||
|
||||
-- int 0 --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, int given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- int 1 --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, int given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- int 12345 --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, int given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- int -12345 --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, int given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- float 10.5 --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, float given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- float -10.5 --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, float given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- float 10.1234567e10 --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, float given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- float 10.7654321E-10 --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, float given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- float .5 --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, float given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- empty array --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- int indexed array --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- associative array --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- nested arrays --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- uppercase NULL --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- lowercase null --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- lowercase true --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, bool given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- lowercase false --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, bool given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- uppercase TRUE --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, bool given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- uppercase FALSE --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, bool given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- empty string DQ --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- empty string SQ --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- string DQ --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- string SQ --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- mixed case string --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- heredoc --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- instance of classWithToString --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, object given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- instance of classWithoutToString --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, object given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- undefined var --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- unset var --
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- file resource --
|
||||
|
||||
Warning: imagecolorallocate(): supplied resource is not a valid Image resource in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
@ -1,215 +0,0 @@
|
||||
--TEST--
|
||||
Test imagecolorallocate() function : usage variations - passing different data types to second argument
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')) {
|
||||
die('skip gd extension is not loaded');
|
||||
}
|
||||
if(!function_exists('imagecreatetruecolor')) {
|
||||
die('skip imagecreatetruecolor function is not available');
|
||||
}
|
||||
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue)
|
||||
* Description: Allocate a color for an image
|
||||
* Source code: ext/gd/gd.c
|
||||
*/
|
||||
|
||||
echo "*** Testing imagecolorallocate() : usage variations ***\n";
|
||||
|
||||
$im = imagecreatetruecolor(200, 200);
|
||||
$green = 10;
|
||||
$blue = 10;
|
||||
|
||||
$fp = tmpfile();
|
||||
|
||||
//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);
|
||||
|
||||
//array of values to iterate over
|
||||
$values = array(
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 10.1234567e10' => 10.1234567e10,
|
||||
'float 10.7654321E-10' => 10.7654321E-10,
|
||||
'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
|
||||
"file resource" => $fp
|
||||
);
|
||||
// loop through each element of the array for red
|
||||
foreach($values as $key => $value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( imagecolorallocate($im, $value, $green, $blue) );
|
||||
};
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing imagecolorallocate() : usage variations ***
|
||||
|
||||
--float 10.5--
|
||||
int(657930)
|
||||
|
||||
--float -10.5--
|
||||
bool(false)
|
||||
|
||||
--float 10.1234567e10--
|
||||
bool(false)
|
||||
|
||||
--float 10.7654321E-10--
|
||||
int(2570)
|
||||
|
||||
--float .5--
|
||||
int(2570)
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 2 to be int, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 2 to be int, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 2 to be int, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 2 to be int, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
--uppercase NULL--
|
||||
int(2570)
|
||||
|
||||
--lowercase null--
|
||||
int(2570)
|
||||
|
||||
--lowercase true--
|
||||
int(68106)
|
||||
|
||||
--lowercase false--
|
||||
int(2570)
|
||||
|
||||
--uppercase TRUE--
|
||||
int(68106)
|
||||
|
||||
--uppercase FALSE--
|
||||
int(2570)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 2 to be int, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 2 to be int, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 2 to be int, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 2 to be int, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 2 to be int, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 2 to be int, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 2 to be int, object given in %s on line %d
|
||||
NULL
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 2 to be int, object given in %s on line %d
|
||||
NULL
|
||||
|
||||
--undefined var--
|
||||
int(2570)
|
||||
|
||||
--unset var--
|
||||
int(2570)
|
||||
|
||||
--file resource--
|
||||
|
||||
Warning: imagecolorallocate() expects parameter 2 to be int, resource given in %s on line %d
|
||||
NULL
|
||||
===DONE===
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user