diff options
author | Lior Kaplan <kaplanlior@gmail.com> | 2014-01-11 13:43:40 +0200 |
---|---|---|
committer | Lior Kaplan <kaplanlior@gmail.com> | 2014-01-11 13:43:40 +0200 |
commit | 650fb41a77b3a24ab4130b05fff243b64b241877 (patch) | |
tree | b64f1cfd733f03ce1db807733ddf87ac8d62a903 /tests | |
parent | 5a58c4dae727fbc8bd92770c2708baf9e7688857 (diff) | |
download | php-650fb41a77b3a24ab4130b05fff243b64b241877.tar.gz |
Imported Upstream version 5.5.8+dfsgupstream/5.5.8+dfsg
Diffstat (limited to 'tests')
-rw-r--r-- | tests/classes/autoload_021.phpt | 13 | ||||
-rw-r--r-- | tests/classes/bug65768.phpt | 36 | ||||
-rw-r--r-- | tests/strings/001.phpt | 19 |
3 files changed, 66 insertions, 2 deletions
diff --git a/tests/classes/autoload_021.phpt b/tests/classes/autoload_021.phpt new file mode 100644 index 000000000..13562b400 --- /dev/null +++ b/tests/classes/autoload_021.phpt @@ -0,0 +1,13 @@ +--TEST-- +Validation of class names in the autoload process +--FILE-- +<?php +function __autoload($name) { + echo "$name\n"; +} +$a = "../BUG"; +$x = new $a; +echo "BUG\n"; +?> +--EXPECTF-- +Fatal error: Class '../BUG' not found in %sautoload_021.php on line 6 diff --git a/tests/classes/bug65768.phpt b/tests/classes/bug65768.phpt new file mode 100644 index 000000000..17ec93cf2 --- /dev/null +++ b/tests/classes/bug65768.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #65768: date_diff accepts only DateTime instance even though docs say about DateTimeInterface +--INI-- +date.timezone=Europe/London +--FILE-- +<?php + +$dt1 = new DateTime("2010-10-20"); +$dti1 = new DateTimeImmutable("2010-10-25"); +$dti2 = new DateTimeImmutable("2010-10-28"); + +$diff1 = $dt1->diff($dti1); +echo $diff1->y, " ", $diff1->m, " ", $diff1->d, " ", + $diff1->h, " ", $diff1->i, " ", $diff1->s, "\n"; + +$diff2 = $dti1->diff($dti2); +echo $diff2->y, " ", $diff2->m, " ", $diff2->d, " ", + $diff2->h, " ", $diff2->i, " ", $diff2->s, "\n"; + +$diff3 = date_diff($dt1, $dti2); +echo $diff3->y, " ", $diff3->m, " ", $diff3->d, " ", + $diff3->h, " ", $diff3->i, " ", $diff3->s, "\n"; + +class cdt1 extends DateTime implements DateTimeInterface {} + +class cdt2 extends DateTimeImmutable implements DateTimeInterface {} + +class cdt3 implements DateTimeInterface {} + +?> +--EXPECTF-- +0 0 5 0 0 0 +0 0 3 0 0 0 +0 0 8 0 0 0 + +Fatal error: DateTimeInterface can't be implemented by user classes in %sbug65768.php on line %d diff --git a/tests/strings/001.phpt b/tests/strings/001.phpt index 3bfd3dbc3..98ceceb35 100644 --- a/tests/strings/001.phpt +++ b/tests/strings/001.phpt @@ -177,9 +177,23 @@ if ($ss == "\$'") { } -echo "Testing uniqid: "; +echo "Testing uniqid(true): "; +$str = "prefix"; +$ui1 = uniqid($str, true); +$ui2 = uniqid($str, true); + +$len = 29; + +if (strlen($ui1) == strlen($ui2) && strlen($ui1) == $len && $ui1 != $ui2) { + echo("passed\n"); +} else { + echo("failed!\n"); +} + +echo "Testing uniqid(false): "; $str = "prefix"; $ui1 = uniqid($str); +usleep( 1 ); $ui2 = uniqid($str); $len = strncasecmp(PHP_OS, 'CYGWIN', 6) ? 19 : 29; @@ -207,4 +221,5 @@ Testing ufirst: passed Testing strtr: passed Testing addslashes: passed Testing stripslashes: passed -Testing uniqid: passed +Testing uniqid(true): passed +Testing uniqid(false): passed |