mirror of
https://github.com/php/php-src.git
synced 2024-09-26 20:37:29 +00:00
New testcases for strftime function
This commit is contained in:
parent
637684ed85
commit
23f3a4428a
30
ext/date/tests/strftime_basic.phpt
Normal file
30
ext/date/tests/strftime_basic.phpt
Normal file
@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Test strftime() function : basic functionality
|
||||
--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() : basic functionality ***\n";
|
||||
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
// Initialise all required variables
|
||||
$format = '%b %d %Y %H:%M:%S';
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
// Calling strftime() with all possible arguments
|
||||
var_dump( strftime($format, $timestamp) );
|
||||
|
||||
// Calling strftime() with mandatory arguments
|
||||
var_dump( strftime($format) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : basic functionality ***
|
||||
unicode(20) "Aug 08 2008 08:08:08"
|
||||
unicode(%d) "%s %d %d %d:%d:%d"
|
||||
===DONE===
|
30
ext/date/tests/strftime_error.phpt
Normal file
30
ext/date/tests/strftime_error.phpt
Normal file
@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Test strftime() function : error conditions
|
||||
--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() : error conditions ***\n";
|
||||
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
//Test strftime with one more than the expected number of arguments
|
||||
echo "\n-- Testing strftime() function with more than expected no. of arguments --\n";
|
||||
$format = '%b %d %Y %H:%M:%S';
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
$extra_arg = 10;
|
||||
var_dump( strftime($format, $timestamp, $extra_arg) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : error conditions ***
|
||||
|
||||
-- Testing strftime() function with more than expected no. of arguments --
|
||||
|
||||
Warning: strftime() expects at most 2 parameters, 3 given in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
222
ext/date/tests/strftime_variation1.phpt
Normal file
222
ext/date/tests/strftime_variation1.phpt
Normal file
@ -0,0 +1,222 @@
|
||||
--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--
|
||||
unicode(1) "0"
|
||||
unicode(1) "0"
|
||||
|
||||
--int 1--
|
||||
unicode(1) "1"
|
||||
unicode(1) "1"
|
||||
|
||||
--int 12345--
|
||||
unicode(5) "12345"
|
||||
unicode(5) "12345"
|
||||
|
||||
--int -12345--
|
||||
unicode(6) "-12345"
|
||||
unicode(6) "-12345"
|
||||
|
||||
--float 10.5--
|
||||
unicode(4) "10.5"
|
||||
unicode(4) "10.5"
|
||||
|
||||
--float -10.5--
|
||||
unicode(5) "-10.5"
|
||||
unicode(5) "-10.5"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
unicode(12) "123456789000"
|
||||
unicode(12) "123456789000"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
unicode(13) "-123456789000"
|
||||
unicode(13) "-123456789000"
|
||||
|
||||
--float .5--
|
||||
unicode(3) "0.5"
|
||||
unicode(3) "0.5"
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: strftime() expects parameter 1 to be binary string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strftime() expects parameter 1 to be binary string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: strftime() expects parameter 1 to be binary string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strftime() expects parameter 1 to be binary string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: strftime() expects parameter 1 to be binary string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strftime() expects parameter 1 to be binary string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: strftime() expects parameter 1 to be binary string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strftime() expects parameter 1 to be binary string, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
unicode(1) "1"
|
||||
unicode(1) "1"
|
||||
|
||||
--lowercase false--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
unicode(1) "1"
|
||||
unicode(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--
|
||||
unicode(14) "Class A object"
|
||||
unicode(14) "Class A object"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: strftime() expects parameter 1 to be binary string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strftime() expects parameter 1 to be binary string, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
bool(false)
|
||||
bool(false)
|
||||
===DONE===
|
50
ext/date/tests/strftime_variation10.phpt
Normal file
50
ext/date/tests/strftime_variation10.phpt
Normal file
@ -0,0 +1,50 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking week related formats which are supported other than on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||
die("skip Test is not valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'The ISO 8601:1988 week number' => "%V",
|
||||
'Weekday as decimal' => "%u",
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
}
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--The ISO 8601:1988 week number--
|
||||
unicode(%d) "%d"
|
||||
unicode(2) "32"
|
||||
|
||||
--Weekday as decimal--
|
||||
unicode(%d) "%d"
|
||||
unicode(1) "5"
|
||||
===DONE===
|
37
ext/date/tests/strftime_variation11.phpt
Normal file
37
ext/date/tests/strftime_variation11.phpt
Normal file
@ -0,0 +1,37 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking month related formats which are not supported on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
|
||||
die("skip Test is valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
echo "\n-- Testing strftime() function with Abbreviated month name format %h --\n";
|
||||
$format = "%h";
|
||||
var_dump( strftime($format) );
|
||||
var_dump( strftime($format, $timestamp) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
-- Testing strftime() function with Abbreviated month name format %h --
|
||||
bool(false)
|
||||
bool(false)
|
||||
===DONE===
|
37
ext/date/tests/strftime_variation12.phpt
Normal file
37
ext/date/tests/strftime_variation12.phpt
Normal file
@ -0,0 +1,37 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking month related formats which are supported other than on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||
die("skip Test is not valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
echo "\n-- Testing strftime() function with Abbreviated month name format %h --\n";
|
||||
$format = "%h";
|
||||
var_dump( strftime($format) );
|
||||
var_dump( strftime($format, $timestamp) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
-- Testing strftime() function with Abbreviated month name format %h --
|
||||
unicode(%d) "%s"
|
||||
unicode(3) "Aug"
|
||||
===DONE===
|
60
ext/date/tests/strftime_variation13.phpt
Normal file
60
ext/date/tests/strftime_variation13.phpt
Normal file
@ -0,0 +1,60 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking date related formats which are not supported on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
|
||||
die("skip Test is valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'Century number' => "%C",
|
||||
'Month Date Year' => "%D",
|
||||
'Year with century' => "%G",
|
||||
'Year without century' => "%g",
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
}
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--Century number--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--Month Date Year--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--Year with century--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--Year without century--
|
||||
bool(false)
|
||||
bool(false)
|
||||
===DONE===
|
60
ext/date/tests/strftime_variation14.phpt
Normal file
60
ext/date/tests/strftime_variation14.phpt
Normal file
@ -0,0 +1,60 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking date related formats which are supported other than on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||
die("skip Test is not valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'Century number' => "%C",
|
||||
'Month Date Year' => "%D",
|
||||
'Year with century' => "%G",
|
||||
'Year without century' => "%g",
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
}
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--Century number--
|
||||
unicode(%d) "%d"
|
||||
unicode(2) "20"
|
||||
|
||||
--Month Date Year--
|
||||
unicode(%d) "%d/%d/%d"
|
||||
unicode(8) "08/08/08"
|
||||
|
||||
--Year with century--
|
||||
unicode(%d) "%d"
|
||||
unicode(4) "2008"
|
||||
|
||||
--Year without century--
|
||||
unicode(%d) "%d"
|
||||
unicode(2) "08"
|
||||
===DONE===
|
55
ext/date/tests/strftime_variation15.phpt
Normal file
55
ext/date/tests/strftime_variation15.phpt
Normal file
@ -0,0 +1,55 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking time related formats which are not supported on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
|
||||
die("skip Test is valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'Time in a.m/p.m notation' => "%r",
|
||||
'Time in 24 hour notation' => "%R",
|
||||
'Current time %H:%M:%S format' => "%T",
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
}
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--Time in a.m/p.m notation--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--Time in 24 hour notation--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--Current time %H:%M:%S format--
|
||||
bool(false)
|
||||
bool(false)
|
||||
===DONE===
|
55
ext/date/tests/strftime_variation16.phpt
Normal file
55
ext/date/tests/strftime_variation16.phpt
Normal file
@ -0,0 +1,55 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking time related formats which are supported other than on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||
die("skip Test is not valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'Time in a.m/p.m notation' => "%r",
|
||||
'Time in 24 hour notation' => "%R",
|
||||
'Current time %H:%M:%S format' => "%T",
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
}
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--Time in a.m/p.m notation--
|
||||
unicode(%d) "%d:%d:%d %s"
|
||||
unicode(11) "08:08:08 AM"
|
||||
|
||||
--Time in 24 hour notation--
|
||||
unicode(%d) "%d:%d"
|
||||
unicode(5) "08:08"
|
||||
|
||||
--Current time %H:%M:%S format--
|
||||
unicode(%d) "%d:%d:%d"
|
||||
unicode(8) "08:08:08"
|
||||
===DONE===
|
36
ext/date/tests/strftime_variation17.phpt
Normal file
36
ext/date/tests/strftime_variation17.phpt
Normal file
@ -0,0 +1,36 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking day related formats which are not supported on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
|
||||
die("skip Test is valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
echo "\n-- Testing strftime() function with Day of the month as decimal single digit format --\n";
|
||||
$format = "%e";
|
||||
var_dump( strftime($format) );
|
||||
var_dump( strftime($format, $timestamp) );
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
-- Testing strftime() function with Day of the month as decimal single digit format --
|
||||
bool(false)
|
||||
bool(false)
|
||||
===DONE===
|
36
ext/date/tests/strftime_variation18.phpt
Normal file
36
ext/date/tests/strftime_variation18.phpt
Normal file
@ -0,0 +1,36 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking day related formats which are supported other than on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||
die("skip Test is not valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
echo "\n-- Testing strftime() function with Day of the month as decimal single digit format --\n";
|
||||
$format = "%e";
|
||||
var_dump( strftime($format) );
|
||||
var_dump( strftime($format, $timestamp) );
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
-- Testing strftime() function with Day of the month as decimal single digit format --
|
||||
unicode(%d) "%d"
|
||||
unicode(2) " 8"
|
||||
===DONE===
|
50
ext/date/tests/strftime_variation19.phpt
Normal file
50
ext/date/tests/strftime_variation19.phpt
Normal file
@ -0,0 +1,50 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking newline and tab formats which are not supported on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
|
||||
die("skip Test is valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'Newline character' => "%n",
|
||||
'Tab character' => "%t"
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
}
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--Newline character--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--Tab character--
|
||||
bool(false)
|
||||
bool(false)
|
||||
===DONE===
|
191
ext/date/tests/strftime_variation2.phpt
Normal file
191
ext/date/tests/strftime_variation2.phpt
Normal file
@ -0,0 +1,191 @@
|
||||
--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--
|
||||
unicode(20) "Jan 01 1970 05:30:10"
|
||||
|
||||
--float -10.5--
|
||||
unicode(20) "Jan 01 1970 05:29:50"
|
||||
|
||||
--float .5--
|
||||
unicode(20) "Jan 01 1970 05:30:00"
|
||||
|
||||
--empty array--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
unicode(20) "Jan 01 1970 05:30:00"
|
||||
|
||||
--lowercase null--
|
||||
unicode(20) "Jan 01 1970 05:30:00"
|
||||
|
||||
--lowercase true--
|
||||
unicode(20) "Jan 01 1970 05:30:01"
|
||||
|
||||
--lowercase false--
|
||||
unicode(20) "Jan 01 1970 05:30:00"
|
||||
|
||||
--uppercase TRUE--
|
||||
unicode(20) "Jan 01 1970 05:30:01"
|
||||
|
||||
--uppercase FALSE--
|
||||
unicode(20) "Jan 01 1970 05:30:00"
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string DQ--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--string SQ--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--mixed case string--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--heredoc--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
|
||||
Warning: strftime() expects parameter 2 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
unicode(20) "Jan 01 1970 05:30:00"
|
||||
|
||||
--unset var--
|
||||
unicode(20) "Jan 01 1970 05:30:00"
|
||||
===DONE===
|
52
ext/date/tests/strftime_variation20.phpt
Normal file
52
ext/date/tests/strftime_variation20.phpt
Normal file
@ -0,0 +1,52 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking newline and tab formats which are supported other than on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||
die("skip Test is not valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'Newline character' => "%n",
|
||||
'Tab character' => "%t"
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
}
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTREGEX--
|
||||
\*\*\* Testing strftime\(\) : usage variation \*\*\*
|
||||
|
||||
--Newline character--
|
||||
unicode\(1\) "
|
||||
"
|
||||
unicode\(1\) "
|
||||
"
|
||||
|
||||
--Tab character--
|
||||
unicode\(1\) "\s"
|
||||
unicode\(1\) "\s"
|
||||
===DONE===
|
55
ext/date/tests/strftime_variation21.phpt
Normal file
55
ext/date/tests/strftime_variation21.phpt
Normal file
@ -0,0 +1,55 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking Preferred date and time representation on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
|
||||
die("skip Test is valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'Preferred date and time representation' => "%c",
|
||||
'Preferred date representation' => "%x",
|
||||
'Preferred time representation' => "%X",
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
}
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--Preferred date and time representation--
|
||||
unicode(%d) "%d/%d/%d %d:%d:%d"
|
||||
unicode(17) "08/08/08 08:08:08"
|
||||
|
||||
--Preferred date representation--
|
||||
unicode(%d) "%d/%d/%d"
|
||||
unicode(8) "08/08/08"
|
||||
|
||||
--Preferred time representation--
|
||||
unicode(%d) "%d:%d:%d"
|
||||
unicode(8) "08:08:08"
|
||||
===DONE===
|
55
ext/date/tests/strftime_variation22.phpt
Normal file
55
ext/date/tests/strftime_variation22.phpt
Normal file
@ -0,0 +1,55 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking Preferred date and time representation other than on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||
die("skip Test is not valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'Preferred date and time representation' => "%c",
|
||||
'Preferred date representation' => "%x",
|
||||
'Preferred time representation' => "%X",
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
}
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--Preferred date and time representation--
|
||||
unicode(%d) "%s %s %d %d:%d:%d %d"
|
||||
unicode(24) "Fri Aug 8 08:08:08 2008"
|
||||
|
||||
--Preferred date representation--
|
||||
unicode(%d) "%d/%d/%d"
|
||||
unicode(8) "08/08/08"
|
||||
|
||||
--Preferred time representation--
|
||||
unicode(%d) "%d:%d:%d"
|
||||
unicode(8) "08:08:08"
|
||||
===DONE===
|
36
ext/date/tests/strftime_variation23.phpt
Normal file
36
ext/date/tests/strftime_variation23.phpt
Normal file
@ -0,0 +1,36 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking large positive and negative float values to 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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("UTC");
|
||||
$format = '%b %d %Y %H:%M:%S';
|
||||
|
||||
echo "\n-- Testing strftime() function with float 12.3456789000e10 to timestamp --\n";
|
||||
$timestamp = 12.3456789000e10;
|
||||
var_dump( strftime($format, $timestamp) );
|
||||
|
||||
echo "\n-- Testing strftime() function with float -12.3456789000e10 to timestamp --\n";
|
||||
$timestamp = -12.3456789000e10;
|
||||
var_dump( strftime($format, $timestamp) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTREGEX--
|
||||
\*\*\* Testing strftime\(\) : usage variation \*\*\*
|
||||
|
||||
-- Testing strftime\(\) function with float 12.3456789000e10 to timestamp --
|
||||
unicode\(\d*\)\s"(Jan|Mar)\s(19|11)\s(2038|5882)\s(03|00):(14|30):(07|00)"
|
||||
|
||||
-- Testing strftime\(\) function with float -12.3456789000e10 to timestamp --
|
||||
unicode\(\d*\)\s"(Dec|Oct)\s(13|22)\s(1901|-1943)\s(20|23):(45|30):(52|00)"
|
||||
===DONE===
|
52
ext/date/tests/strftime_variation3.phpt
Normal file
52
ext/date/tests/strftime_variation3.phpt
Normal file
@ -0,0 +1,52 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Passing week related format strings to format argument.
|
||||
--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 = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'Abbreviated weekday name' => "%a",
|
||||
'Full weekday name' => "%A",
|
||||
'Week number of the year' => "%U",
|
||||
'Week number of the year in decimal number' => "%W",
|
||||
);
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--Abbreviated weekday name--
|
||||
unicode(%d) "%s"
|
||||
unicode(3) "Fri"
|
||||
|
||||
--Full weekday name--
|
||||
unicode(%d) "%s"
|
||||
unicode(6) "Friday"
|
||||
|
||||
--Week number of the year--
|
||||
unicode(%d) "%d"
|
||||
unicode(2) "31"
|
||||
|
||||
--Week number of the year in decimal number--
|
||||
unicode(%d) "%d"
|
||||
unicode(2) "31"
|
||||
===DONE===
|
48
ext/date/tests/strftime_variation4.phpt
Normal file
48
ext/date/tests/strftime_variation4.phpt
Normal file
@ -0,0 +1,48 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Passing month related format strings to format argument.
|
||||
--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 = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'Abbreviated month name' => "%b",
|
||||
'Full month name' => "%B",
|
||||
'Month as decimal' => "%m",
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--Abbreviated month name--
|
||||
unicode(%d) "%s"
|
||||
unicode(3) "Aug"
|
||||
|
||||
--Full month name--
|
||||
unicode(%d) "%s"
|
||||
unicode(6) "August"
|
||||
|
||||
--Month as decimal--
|
||||
unicode(%d) "%d"
|
||||
unicode(2) "08"
|
||||
===DONE===
|
50
ext/date/tests/strftime_variation5.phpt
Normal file
50
ext/date/tests/strftime_variation5.phpt
Normal file
@ -0,0 +1,50 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Passing date related format strings to format argument.
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'Year as decimal number without a century' => "%y",
|
||||
'Year as decimal number including the century' => "%Y",
|
||||
'Time zone offset' => "%Z",
|
||||
'Time zone offset' => "%z",
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--Year as decimal number without a century--
|
||||
unicode(%d) "%d"
|
||||
unicode(2) "08"
|
||||
|
||||
--Year as decimal number including the century--
|
||||
unicode(%d) "%d"
|
||||
unicode(4) "2008"
|
||||
|
||||
--Time zone offset--
|
||||
unicode(%d) "%s"
|
||||
unicode(%d) "%s"
|
||||
===DONE===
|
60
ext/date/tests/strftime_variation6.phpt
Normal file
60
ext/date/tests/strftime_variation6.phpt
Normal file
@ -0,0 +1,60 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Passing time related format strings to format argument.
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(18, 8, 8, 8, 8, 2008);
|
||||
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'Hour as decimal by 24-hour format' => "%H",
|
||||
'Hour as decimal by 12-hour format' => "%I",
|
||||
'Minute as decimal number' => "%M",
|
||||
'AM/PM format for a time' => "%p",
|
||||
'Second as decimal number' => "%S",
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--Hour as decimal by 24-hour format--
|
||||
unicode(%d) "%d"
|
||||
unicode(2) "18"
|
||||
|
||||
--Hour as decimal by 12-hour format--
|
||||
unicode(%d) "%d"
|
||||
unicode(2) "06"
|
||||
|
||||
--Minute as decimal number--
|
||||
unicode(%d) "%d"
|
||||
unicode(2) "08"
|
||||
|
||||
--AM/PM format for a time--
|
||||
unicode(%d) "%s"
|
||||
unicode(2) "PM"
|
||||
|
||||
--Second as decimal number--
|
||||
unicode(%d) "%d"
|
||||
unicode(2) "08"
|
||||
===DONE===
|
50
ext/date/tests/strftime_variation7.phpt
Normal file
50
ext/date/tests/strftime_variation7.phpt
Normal file
@ -0,0 +1,50 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Passing day related format strings to format argument.
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(18, 8, 8, 8, 8, 2008);
|
||||
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'Day of the month as a decimal number' => "%d",
|
||||
'Day of the year as a decimal number' => "%j",
|
||||
'Day of the week as a decimal number' => "%w"
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
};
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--Day of the month as a decimal number--
|
||||
unicode(%d) "%d"
|
||||
unicode(2) "08"
|
||||
|
||||
--Day of the year as a decimal number--
|
||||
unicode(%d) "%d"
|
||||
unicode(3) "221"
|
||||
|
||||
--Day of the week as a decimal number--
|
||||
unicode(%d) "%d"
|
||||
unicode(1) "5"
|
||||
===DONE===
|
31
ext/date/tests/strftime_variation8.phpt
Normal file
31
ext/date/tests/strftime_variation8.phpt
Normal file
@ -0,0 +1,31 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Passing literal related strings to format argument.
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
$format = "%%";
|
||||
|
||||
echo "\n-- Testing strftime() function with a literal % character to format --\n";
|
||||
var_dump( strftime($format) );
|
||||
var_dump( strftime($format, $timestamp) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
-- Testing strftime() function with a literal % character to format --
|
||||
unicode(1) "%"
|
||||
unicode(1) "%"
|
||||
===DONE===
|
50
ext/date/tests/strftime_variation9.phpt
Normal file
50
ext/date/tests/strftime_variation9.phpt
Normal file
@ -0,0 +1,50 @@
|
||||
--TEST--
|
||||
Test strftime() function : usage variation - Checking week related formats which are not supported on Windows.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
|
||||
die("skip Test is valid for Windows");
|
||||
}
|
||||
?>
|
||||
--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";
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
locale_set_default("en_US");
|
||||
date_default_timezone_set("Asia/Calcutta");
|
||||
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
'The ISO 8601:1988 week number' => "%V",
|
||||
'Weekday as decimal' => "%u",
|
||||
);
|
||||
|
||||
// loop through each element of the array for timestamp
|
||||
|
||||
foreach($inputs as $key =>$value) {
|
||||
echo "\n--$key--\n";
|
||||
var_dump( strftime($value) );
|
||||
var_dump( strftime($value, $timestamp) );
|
||||
}
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing strftime() : usage variation ***
|
||||
|
||||
--The ISO 8601:1988 week number--
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
--Weekday as decimal--
|
||||
bool(false)
|
||||
bool(false)
|
||||
===DONE===
|
Loading…
Reference in New Issue
Block a user