Skip to content

Commit

Permalink
missing tests for bug #53437
Browse files Browse the repository at this point in the history
  • Loading branch information
weltling committed Jun 11, 2013
1 parent 18403e4 commit f16143f
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ext/date/tests/bug53437_var1.phpt
@@ -0,0 +1,13 @@
--TEST--
Bug #53437 (Crash when using unserialized DatePeriod instance), variation 2
--FILE--
<?php
$s = 'O:10:"DatePeriod":0:{}';

$dp = unserialize($s);

var_dump($dp);
?>
==DONE==
--EXPECTF--
Fatal error: Invalid serialization data for DatePeriod object in %sbug53437_var1.php on line %d
80 changes: 80 additions & 0 deletions ext/date/tests/bug53437_var2.phpt
@@ -0,0 +1,80 @@
--TEST--
Bug #53437 DateInterval basic serialization
--FILE--
<?php
$di0 = new DateInterval('P2Y4DT6H8M');

$s = serialize($di0);

$di1 = unserialize($s);

var_dump($di0, $di1);

?>
==DONE==
--EXPECT--
object(DateInterval)#1 (15) {
["y"]=>
int(2)
["m"]=>
int(0)
["d"]=>
int(4)
["h"]=>
int(6)
["i"]=>
int(8)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
bool(false)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
object(DateInterval)#2 (15) {
["y"]=>
int(2)
["m"]=>
int(0)
["d"]=>
int(4)
["h"]=>
int(6)
["i"]=>
int(8)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(0)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
==DONE==
47 changes: 47 additions & 0 deletions ext/date/tests/bug53437_var3.phpt
@@ -0,0 +1,47 @@
--TEST--
Bug #53437 DateInterval unserialize bad data, 32 bit
--SKIPIF--
<?php if (PHP_INT_SIZE != 4) { die('skip 32 bit only'); } ?>
--FILE--
<?php
$s = 'O:12:"DateInterval":15:{s:1:"y";s:1:"2";s:1:"m";s:1:"0";s:1:"d";s:3:"bla";s:1:"h";s:1:"6";s:1:"i";s:1:"8";s:1:"s";s:1:"0";s:7:"weekday";i:10;s:16:"weekday_behavior";i:10;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";s:4:"aoeu";s:12:"special_type";i:0;s:14:"special_amount";s:21:"234523452345234532455";s:21:"have_weekday_relative";i:21474836489;s:21:"have_special_relative";s:3:"bla";}';

$di = unserialize($s);
var_dump($di);

?>
==DONE==
--EXPECT--
object(DateInterval)#1 (15) {
["y"]=>
int(2)
["m"]=>
int(0)
["d"]=>
int(0)
["h"]=>
int(6)
["i"]=>
int(8)
["s"]=>
int(0)
["weekday"]=>
int(10)
["weekday_behavior"]=>
int(10)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(0)
["special_type"]=>
int(0)
["special_amount"]=>
int(-1)
["have_weekday_relative"]=>
int(9)
["have_special_relative"]=>
int(0)
}
==DONE==
64 changes: 64 additions & 0 deletions ext/date/tests/bug53437_var4.phpt
@@ -0,0 +1,64 @@
--TEST--
Bug #53437 (Check that var_dump out is the same using the whole object or it's single properties), variation 4
--INI--
date.timezone = Europe/Berlin
--FILE--
<?php
$dt = new DateTime('2009-10-11');

$df = $dt->diff(new DateTime('2009-10-13'));

var_dump($df,
$df->y,
$df->m,
$df->d,
$df->h,
$df->i,
$df->s,
$df->invert,
$df->days);

?>
==DONE==
--EXPECTF--
object(DateInterval)#%d (15) {
["y"]=>
int(0)
["m"]=>
int(0)
["d"]=>
int(2)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(2)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
int(0)
int(0)
int(2)
int(0)
int(0)
int(0)
int(0)
int(2)
==DONE==
47 changes: 47 additions & 0 deletions ext/date/tests/bug53437_var5.phpt
@@ -0,0 +1,47 @@
--TEST--
Bug #53437 DateInterval unserialize bad data, 64 bit
--SKIPIF--
<?php if (PHP_INT_SIZE != 8) { die('skip true 64 bit only'); } ?>
--FILE--
<?php
$s = 'O:12:"DateInterval":15:{s:1:"y";s:1:"2";s:1:"m";s:1:"0";s:1:"d";s:3:"bla";s:1:"h";s:1:"6";s:1:"i";s:1:"8";s:1:"s";s:1:"0";s:7:"weekday";i:10;s:16:"weekday_behavior";i:10;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";s:4:"aoeu";s:12:"special_type";i:0;s:14:"special_amount";s:21:"234523452345234532455";s:21:"have_weekday_relative";i:21474836489;s:21:"have_special_relative";s:3:"bla";}';

$di = unserialize($s);
var_dump($di);

?>
==DONE==
--EXPECT--
object(DateInterval)#1 (15) {

This comment has been minimized.

Copy link
@laruence

laruence Jun 11, 2013

Member

trivial one #1 -> #%d here :)

["y"]=>
int(2)
["m"]=>
int(0)
["d"]=>
int(0)
["h"]=>
int(6)
["i"]=>
int(8)
["s"]=>
int(0)
["weekday"]=>
int(10)
["weekday_behavior"]=>
int(10)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(0)
["special_type"]=>
int(0)
["special_amount"]=>
int(9223372036854775807)
["have_weekday_relative"]=>
int(9)
["have_special_relative"]=>
int(0)
}
==DONE==

0 comments on commit f16143f

Please sign in to comment.