smantoor                Fri Dec  5 05:35:39 2008 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/date/tests     date_sunrise_variation4.phpt 
                                date_sunrise_variation5.phpt 
                                date_sunrise_variation6.phpt 
                                date_sunrise_variation7.phpt 
                                date_sunrise_error.phpt 
                                date_sunrise_variation8.phpt 
                                date_sunrise_variation9.phpt 
                                date_sunrise_variation1.phpt 
                                date_sunrise_variation2.phpt 
                                date_sunrise_variation3.phpt 
  Log:
  New testcases for date_sunrise function
  
http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/date_sunrise_variation4.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/date_sunrise_variation4.phpt
+++ php-src/ext/date/tests/date_sunrise_variation4.phpt
--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--
unicode(5) "05:12"
float(5.200%d)
int(1218172321)

--int 1--
unicode(5) "05:08"
float(5.133%d)
int(1218172081)

--int 12345--
unicode(5) "21:45"
float(21.759%d)
int(1218145534)

--int -12345--
unicode(5) "12:41"
float(12.698%d)
int(1218199315)

--empty array--

Warning: date_sunrise() expects parameter 4 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, array given in %s on 
line %d
bool(false)

--int indexed array--

Warning: date_sunrise() expects parameter 4 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, array given in %s on 
line %d
bool(false)

--associative array--

Warning: date_sunrise() expects parameter 4 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, array given in %s on 
line %d
bool(false)

--nested arrays--

Warning: date_sunrise() expects parameter 4 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, array given in %s on 
line %d
bool(false)

--uppercase NULL--
unicode(5) "05:12"
float(5.200%d)
int(1218172321)

--lowercase null--
unicode(5) "05:12"
float(5.200%d)
int(1218172321)

--lowercase true--
unicode(5) "05:08"
float(5.133%d)
int(1218172081)

--lowercase false--
unicode(5) "05:12"
float(5.200%d)
int(1218172321)

--uppercase TRUE--
unicode(5) "05:08"
float(5.133%d)
int(1218172081)

--uppercase FALSE--
unicode(5) "05:12"
float(5.200%d)
int(1218172321)

--empty string DQ--

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

--empty string SQ--

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

--string DQ--

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

--string SQ--

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

--mixed case string--

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

--heredoc--

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, Unicode string given 
in %s on line %d
bool(false)

--instance of classWithToString--

Warning: date_sunrise() expects parameter 4 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, object given in %s on 
line %d
bool(false)

--instance of classWithoutToString--

Warning: date_sunrise() expects parameter 4 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 4 to be double, object given in %s on 
line %d
bool(false)

--undefined var--
unicode(5) "05:12"
float(5.200%d)
int(1218172321)

--unset var--
unicode(5) "05:12"
float(5.200%d)
int(1218172321)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/date_sunrise_variation5.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/date_sunrise_variation5.phpt
+++ php-src/ext/date/tests/date_sunrise_variation5.phpt
--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--
unicode(5) "09:52"
float(9.882%d)
int(1218169377)

--int -12345--
unicode(5) "09:54"
float(9.909%d)
int(1218169475)

--empty array--

Warning: date_sunrise() expects parameter 5 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, array given in %s on 
line %d
bool(false)

--int indexed array--

Warning: date_sunrise() expects parameter 5 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, array given in %s on 
line %d
bool(false)

--associative array--

Warning: date_sunrise() expects parameter 5 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, array given in %s on 
line %d
bool(false)

--nested arrays--

Warning: date_sunrise() expects parameter 5 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, 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 double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

--empty string SQ--

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

--string DQ--

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

--string SQ--

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

--mixed case string--

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

--heredoc--

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, Unicode string given 
in %s on line %d
bool(false)

--instance of classWithToString--

Warning: date_sunrise() expects parameter 5 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, object given in %s on 
line %d
bool(false)

--instance of classWithoutToString--

Warning: date_sunrise() expects parameter 5 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 5 to be double, 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===

http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/date_sunrise_variation6.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/date_sunrise_variation6.phpt
+++ php-src/ext/date/tests/date_sunrise_variation6.phpt
--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--
unicode(5) "05:48"
float(5.800%d)
int(1218174483)

--int 1--
unicode(5) "06:48"
float(6.800%d)
int(1218174483)

--int 12345--
unicode(5) "14:48"
float(14.800%d)
int(1218174483)

--int -12345--
unicode(5) "12:48"
float(12.800%d)
int(1218174483)

--empty array--

Warning: date_sunrise() expects parameter 6 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, array given in %s on 
line %d
bool(false)

--int indexed array--

Warning: date_sunrise() expects parameter 6 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, array given in %s on 
line %d
bool(false)

--associative array--

Warning: date_sunrise() expects parameter 6 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, array given in %s on 
line %d
bool(false)

--nested arrays--

Warning: date_sunrise() expects parameter 6 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, array given in %s on 
line %d
bool(false)

--uppercase NULL--
unicode(5) "05:48"
float(5.800%d)
int(1218174483)

--lowercase null--
unicode(5) "05:48"
float(5.800%d)
int(1218174483)

--lowercase true--
unicode(5) "06:48"
float(6.800%d)
int(1218174483)

--lowercase false--
unicode(5) "05:48"
float(5.800%d)
int(1218174483)

--uppercase TRUE--
unicode(5) "06:48"
float(6.800%d)
int(1218174483)

--uppercase FALSE--
unicode(5) "05:48"
float(5.800%d)
int(1218174483)

--empty string DQ--

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

--empty string SQ--

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

--string DQ--

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

--string SQ--

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

--mixed case string--

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

--heredoc--

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, Unicode string given 
in %s on line %d
bool(false)

--instance of classWithToString--

Warning: date_sunrise() expects parameter 6 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, object given in %s on 
line %d
bool(false)

--instance of classWithoutToString--

Warning: date_sunrise() expects parameter 6 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 6 to be double, object given in %s on 
line %d
bool(false)

--undefined var--
unicode(5) "05:48"
float(5.800%d)
int(1218174483)

--unset var--
unicode(5) "05:48"
float(5.800%d)
int(1218174483)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/date_sunrise_variation7.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/date_sunrise_variation7.phpt
+++ php-src/ext/date/tests/date_sunrise_variation7.phpt
--TEST--
Test date_sunrise() function : usage variation -  Checking sunrise for 
consecutive days in specific timezone
--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";

//Timezones with required data for date_sunrise
$inputs = array (
                //Timezone with Latitude, Longitude and GMT offset
                "Pacific/Samoa" => array ("Latitude" => -14.24, "Longitude" => 
-170.72, "GMT" => -11),
                "US/Alaska" => array ("Latitude" => 61, "Longitude" => -150 , 
"GMT" => -9),
                "America/Chicago" => array ("Latitude" => 41.85, "Longitude" => 
-87.65 , "GMT" => -5),
                "America/Montevideo" => array ("Latitude" => -34.88, 
"Longitude" => -56.18 , "GMT" => -3),
                "Africa/Casablanca" => array ("Latitude" => 33.65, "Longitude" 
=> -7.58, "GMT" => 0),
                "Europe/Moscow" => array ("Latitude" => 55.75, "Longitude" => 
37.58, "GMT" => 4),
                "Asia/Hong_Kong" => array ("Latitude" => 22.28, "Longitude" => 
114.15 , "GMT" => 8),
                "Australia/Brisbane" => array ("Latitude" => -27.46, 
"Longitude" => 153.2 , "GMT" => 10),
                "Pacific/Wallis" => array ("Latitude" => -13.3, "Longitude" => 
-176.16, "GMT" => 12),
);

foreach($inputs as $timezone => $value) {
         date_default_timezone_set($timezone);
         $time = mktime(8, 8, 8, 8, 11, 2008);
         var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $value["Latitude"], 
$value["Longitude"], 90, $value["GMT"] ));
         $time = mktime(8, 8, 8, 8, 12, 2008); 
         var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $value["Latitude"], 
$value["Longitude"], 90, $value["GMT"]) );
}

?>
===DONE===
--EXPECTF--
*** Testing date_sunrise() : usage variation ***
unicode(5) "06:41"
unicode(5) "06:41"
unicode(5) "05:09"
unicode(5) "05:11"
unicode(5) "05:59"
unicode(5) "06:00"
unicode(5) "07:30"
unicode(5) "07:29"
unicode(5) "05:53"
unicode(5) "05:53"
unicode(5) "05:59"
unicode(5) "06:01"
unicode(5) "06:01"
unicode(5) "06:02"
unicode(5) "06:23"
unicode(5) "06:22"
unicode(5) "06:03"
unicode(5) "06:02"
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/date_sunrise_error.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/date_sunrise_error.phpt
+++ php-src/ext/date/tests/date_sunrise_error.phpt
--TEST--
Test date_sunrise() function : error conditions 
--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() : error conditions ***\n";

//Initialise the variables
$time = time();
$latitude = 38.4;
$longitude = -9;
$zenith = 90;
$gmt_offset = 1;
$extra_arg = 10;

// Zero arguments
echo "\n-- Testing date_sunrise() function with Zero arguments --\n";
var_dump( date_sunrise() );

//Test date_sunrise with one more than the expected number of arguments
echo "\n-- Testing date_sunrise() function with more than expected no. of 
arguments --\n";
var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $latitude, $longitude, 
$zenith, $gmt_offset, $extra_arg) );
?>
===DONE===
--EXPECTF--
*** Testing date_sunrise() : error conditions ***

-- Testing date_sunrise() function with Zero arguments --

Warning: date_sunrise() expects at least 1 parameter, 0 given in %s on line %d
bool(false)

-- Testing date_sunrise() function with more than expected no. of arguments --

Warning: date_sunrise() expects at most 6 parameters, 7 given in %s on line %d
bool(false)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/date_sunrise_variation8.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/date_sunrise_variation8.phpt
+++ php-src/ext/date/tests/date_sunrise_variation8.phpt
--TEST--
Test date_sunrise() function : usage variation -  Checking with North and South 
poles when Sun is up and down all day
--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";

// GMT is zero for the timezone
date_default_timezone_set("Africa/Casablanca");
$time_date = array (

                //Date at which Sun is up all day at North Pole
                "12 Aug 2008" => mktime(8, 8, 8, 8, 12, 2008),
                "13 Aug 2008" => mktime(8, 8, 8, 8, 13, 2008),

                //Date at which Sun is up all day at South Pole
                "12 Nov 2008" => mktime(8, 8, 8, 11, 12, 2008),
                "13 Nov 2008" => mktime(8, 8, 8, 11, 13, 2008),
);

//Iterate over different date and time
foreach( $time_date as $date => $time ){
        echo "\n--$date--\n";
        var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, 90, 0 ) );
        var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, 90, 0 ) );
        var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, 90, 0 ) );        
        
        var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, -90, 0 ) );
        var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, -90, 0 ) );
        var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, -90, 0 ) );       
        
}

?>
===DONE===
--EXPECTF--
*** Testing date_sunrise() : usage variation ***

--12 Aug 2008--
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)

--13 Aug 2008--
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)

--12 Nov 2008--
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)

--13 Nov 2008--
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/date_sunrise_variation9.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/date_sunrise_variation9.phpt
+++ php-src/ext/date/tests/date_sunrise_variation9.phpt
--TEST--
Test date_sunrise() function : usage variation -  Passing high positive and 
negative float values to time argument.
--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";

// GMT is zero for the timezone
date_default_timezone_set("Asia/Calcutta");
//Initialise the variables
$latitude = 38.4;
$longitude = -9;
$zenith = 90;
$gmt_offset = 1;

echo "\n-- Testing date_sunrise() function by passing float 12.3456789000e10 
value to time --\n";
$time = 12.3456789000e10;
var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $latitude, $longitude, 
$zenith, $gmt_offset) );
var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, $latitude, $longitude, 
$zenith, $gmt_offset) );
var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude, 
$zenith, $gmt_offset) );

echo "\n-- Testing date_sunrise() function by passing float -12.3456789000e10 
value to time --\n";
$time = -12.3456789000e10;
var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $latitude, $longitude, 
$zenith, $gmt_offset) );
var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, $latitude, $longitude, 
$zenith, $gmt_offset) );
var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude, 
$zenith, $gmt_offset) );

?>
===DONE===
--EXPECTREGEX--
\*\*\* Testing date_sunrise\(\) : usage variation \*\*\*

-- Testing date_sunrise\(\) function by passing float 12.3456789000e10 value to 
time --
unicode\(5\) "(08:53|07:49)"
float\((8.883[0-9]*|8.883[0-9]*|7.821[0-9]*)\)
int\((-2147466915|123456811756)\)

-- Testing date_sunrise\(\) function by passing float -12.3456789000e10 value 
to time --
unicode\(5\) "(08:48|08:04)"
float\((8.810[0-9]*|8.074[0-9]*)\)
int\((-2147443882|-123456761731)\)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/date_sunrise_variation1.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/date_sunrise_variation1.phpt
+++ php-src/ext/date/tests/date_sunrise_variation1.phpt
--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' => -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_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--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--int 1--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--int 12345--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--int -12345--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--float 10.5--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--float -10.5--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--float .5--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--empty array--

Warning: date_sunrise() expects parameter 1 to be long, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, array given in %s on 
line %d
bool(false)

--int indexed array--

Warning: date_sunrise() expects parameter 1 to be long, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, array given in %s on 
line %d
bool(false)

--associative array--

Warning: date_sunrise() expects parameter 1 to be long, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, array given in %s on 
line %d
bool(false)

--nested arrays--

Warning: date_sunrise() expects parameter 1 to be long, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, array given in %s on 
line %d
bool(false)

--uppercase NULL--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--lowercase null--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--lowercase true--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--lowercase false--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--uppercase TRUE--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--uppercase FALSE--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--empty string DQ--

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

--empty string SQ--

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

--string DQ--

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

--string SQ--

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

--mixed case string--

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

--heredoc--

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, Unicode string given in 
%s on line %d
bool(false)

--instance of classWithToString--

Warning: date_sunrise() expects parameter 1 to be long, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, object given in %s on 
line %d
bool(false)

--instance of classWithoutToString--

Warning: date_sunrise() expects parameter 1 to be long, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 1 to be long, object given in %s on 
line %d
bool(false)

--undefined var--
unicode(5) "08:56"
float(8.944%d)
int(28599)

--unset var--
unicode(5) "08:56"
float(8.944%d)
int(28599)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/date_sunrise_variation2.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/date_sunrise_variation2.phpt
+++ php-src/ext/date/tests/date_sunrise_variation2.phpt
--TEST--
Test date_sunrise() function : usage variation - Passing unexpected values to 
second argument format.
--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(): 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(): 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 .5--
int(1218174483)

--empty array--

Warning: date_sunrise() expects parameter 2 to be long, array given in %s on 
line %d
bool(false)

--int indexed array--

Warning: date_sunrise() expects parameter 2 to be long, array given in %s on 
line %d
bool(false)

--associative array--

Warning: date_sunrise() expects parameter 2 to be long, array given in %s on 
line %d
bool(false)

--nested arrays--

Warning: date_sunrise() expects parameter 2 to be long, array given in %s on 
line %d
bool(false)

--uppercase NULL--
int(1218174483)

--lowercase null--
int(1218174483)

--lowercase true--
unicode(5) "06:48"

--lowercase false--
int(1218174483)

--uppercase TRUE--
unicode(5) "06:48"

--uppercase FALSE--
int(1218174483)

--empty string DQ--

Warning: date_sunrise() expects parameter 2 to be long, Unicode string given in 
%s on line %d
bool(false)

--empty string SQ--

Warning: date_sunrise() expects parameter 2 to be long, Unicode string given in 
%s on line %d
bool(false)

--string DQ--

Warning: date_sunrise() expects parameter 2 to be long, Unicode string given in 
%s on line %d
bool(false)

--string SQ--

Warning: date_sunrise() expects parameter 2 to be long, Unicode string given in 
%s on line %d
bool(false)

--mixed case string--

Warning: date_sunrise() expects parameter 2 to be long, Unicode string given in 
%s on line %d
bool(false)

--heredoc--

Warning: date_sunrise() expects parameter 2 to be long, Unicode string given in 
%s on line %d
bool(false)

--instance of classWithToString--

Warning: date_sunrise() expects parameter 2 to be long, object given in %s on 
line %d
bool(false)

--instance of classWithoutToString--

Warning: date_sunrise() expects parameter 2 to be long, object given in %s on 
line %d
bool(false)

--undefined var--
int(1218174483)

--unset var--
int(1218174483)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/date_sunrise_variation3.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/date_sunrise_variation3.phpt
+++ php-src/ext/date/tests/date_sunrise_variation3.phpt
--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--
unicode(5) "01:10"
float(1.174%d)
int(1218177627)

--int 1--
unicode(5) "01:09"
float(1.155%d)
int(1218177558)

--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 double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, array given in %s on 
line %d
bool(false)

--int indexed array--

Warning: date_sunrise() expects parameter 3 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, array given in %s on 
line %d
bool(false)

--associative array--

Warning: date_sunrise() expects parameter 3 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, array given in %s on 
line %d
bool(false)

--nested arrays--

Warning: date_sunrise() expects parameter 3 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, array given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, array given in %s on 
line %d
bool(false)

--uppercase NULL--
unicode(5) "01:10"
float(1.174%d)
int(1218177627)

--lowercase null--
unicode(5) "01:10"
float(1.174%d)
int(1218177627)

--lowercase true--
unicode(5) "01:09"
float(1.155%d)
int(1218177558)

--lowercase false--
unicode(5) "01:10"
float(1.174%d)
int(1218177627)

--uppercase TRUE--
unicode(5) "01:09"
float(1.155%d)
int(1218177558)

--uppercase FALSE--
unicode(5) "01:10"
float(1.174%d)
int(1218177627)

--empty string DQ--

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

--empty string SQ--

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

--string DQ--

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

--string SQ--

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

--mixed case string--

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

--heredoc--

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, Unicode string given 
in %s on line %d
bool(false)

--instance of classWithToString--

Warning: date_sunrise() expects parameter 3 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, object given in %s on 
line %d
bool(false)

--instance of classWithoutToString--

Warning: date_sunrise() expects parameter 3 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, object given in %s on 
line %d
bool(false)

Warning: date_sunrise() expects parameter 3 to be double, object given in %s on 
line %d
bool(false)

--undefined var--
unicode(5) "01:10"
float(1.174%d)
int(1218177627)

--unset var--
unicode(5) "01:10"
float(1.174%d)
int(1218177627)
===DONE===

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to