]> granicus.if.org Git - php/commitdiff
Add tests for previous commit
authorNikita Popov <nikic@php.net>
Tue, 6 May 2014 20:04:58 +0000 (22:04 +0200)
committerNikita Popov <nikic@php.net>
Tue, 6 May 2014 20:04:58 +0000 (22:04 +0200)
ext/date/tests/call_function_from_method.phpt [new file with mode: 0644]

diff --git a/ext/date/tests/call_function_from_method.phpt b/ext/date/tests/call_function_from_method.phpt
new file mode 100644 (file)
index 0000000..7cbe684
--- /dev/null
@@ -0,0 +1,29 @@
+--TEST--
+Call to date function from a method and call to date method from call_user_func
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+
+class Date {
+    public function __construct($in) {
+        $this->date = date_create($in);
+    }
+
+    public function getYear1() {
+        return date_format($this->date, 'Y');
+    }
+
+    public function getYear2() {
+        return call_user_func([$this->date, 'format'], 'Y');
+    }
+}
+
+$d = new Date('NOW');
+var_dump($d->getYear1());
+var_dump($d->getYear2());
+
+?>
+--EXPECTF--
+string(4) "%d"
+string(4) "%d"