diff options
| author | Ondřej Surý <ondrej@sury.org> | 2014-06-20 12:01:47 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2014-06-20 12:01:47 +0200 |
| commit | 60d44b592c4c4fdcbbf92db2882a97a9cc54713c (patch) | |
| tree | 58f7068d9acde2338841263461fbf95d77a9ee2e /ext/date/tests | |
| parent | c63e1a09f5cbd757f59beb729fb0fb36516819a9 (diff) | |
| download | php-60d44b592c4c4fdcbbf92db2882a97a9cc54713c.tar.gz | |
New upstream version 5.6.0~rc1+dfsgupstream/5.6.0_rc1+dfsg
Diffstat (limited to 'ext/date/tests')
| -rw-r--r-- | ext/date/tests/bug41523.phpt | 2 | ||||
| -rw-r--r-- | ext/date/tests/bug67118.phpt | 18 | ||||
| -rw-r--r-- | ext/date/tests/bug67118_2.phpt | 35 |
3 files changed, 45 insertions, 10 deletions
diff --git a/ext/date/tests/bug41523.phpt b/ext/date/tests/bug41523.phpt index 05c591f06..68fe1bd6a 100644 --- a/ext/date/tests/bug41523.phpt +++ b/ext/date/tests/bug41523.phpt @@ -46,7 +46,7 @@ array(12) { bool(false) object(DateTime)#1 (3) { ["date"]=> - string(20) "-0001-11-30 00:00:00.000000" + string(27) "-0001-11-30 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> diff --git a/ext/date/tests/bug67118.phpt b/ext/date/tests/bug67118.phpt index 637175764..973b4eb8d 100644 --- a/ext/date/tests/bug67118.phpt +++ b/ext/date/tests/bug67118.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #67118 php-cgi crashes regularly on IIS 7 +Bug #67118 crashes in DateTime when this used after failed __construct --INI-- date.timezone=Europe/Berlin --FILE-- @@ -11,17 +11,17 @@ class mydt extends datetime if (!empty($tz) && !is_object($tz)) { $tz = new DateTimeZone($tz); } - - @parent::__construct($time, $tz); + try { + @parent::__construct($time, $tz); + } catch (Exception $e) { + echo "Bad date" . $this->format("Y") . "\n"; + } } }; new mydt("Funktionsansvarig rådgivning och juridik", "UTC"); +?> --EXPECTF-- -Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (Funktionsansvarig rådgivning och juridik) at position 0 (F): The timezone could not be found in the database' in %sbug67118.php:%d -Stack trace: -#0 %sbug67118.php(%d): DateTime->__construct('Funktionsansvar...', Object(DateTimeZone)) -#1 %sbug67118.php(%d): mydt->__construct('Funktionsansvar...', 'UTC') -#2 {main} - thrown in %sbug67118.php on line %d +Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in %sbug67118.php on line %d +Bad date diff --git a/ext/date/tests/bug67118_2.phpt b/ext/date/tests/bug67118_2.phpt new file mode 100644 index 000000000..b4904a158 --- /dev/null +++ b/ext/date/tests/bug67118_2.phpt @@ -0,0 +1,35 @@ +--TEST-- +Regression introduce in fix for Bug #67118 +--INI-- +date.timezone=Europe/Paris +--FILE-- +<?php +class Foo extends DateTime { + public function __construct($time = null) { + $tz = new DateTimeZone('UTC'); + try { + echo "First try\n"; + parent::__construct($time, $tz); + return; + } catch (Exception $e) { + echo "Second try\n"; + parent::__construct($time.'C', $tz); + } + } +} +$date = '12 Sep 2007 15:49:12 UT'; +var_dump(new Foo($date)); +?> +Done +--EXPECTF-- +First try +Second try +object(Foo)#1 (3) { + ["date"]=> + string(%d) "2007-09-12 15:49:%s" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(3) "UTC" +} +Done |
