Skip to content

Commit 821fa0b

Browse files
Ion Bazancs278
authored andcommitted
Add a couple of tests imported from PR
hnw#31
1 parent cccc7b4 commit 821fa0b

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

tests/issue_005.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
Check for issue #5 (DateTime reflection)
3+
--SKIPIF--
4+
<?php
5+
$required_version = "5.3";
6+
$required_func = array("timecop_freeze");
7+
$required_class = array("TimecopDateTime");
8+
include(__DIR__."/tests-skipcheck.inc.php");
9+
--INI--
10+
date.timezone=GMT
11+
timecop.func_override=1
12+
--FILE--
13+
<?php
14+
class Test
15+
{
16+
public function setCreatedAt(DateTime $createdAt)
17+
{
18+
$this->createdAt = $createdAt;
19+
}
20+
}
21+
$test = new Test();
22+
$reflection = new ReflectionClass($test);
23+
$params = $reflection->getMethod('setCreatedAt')->getParameters();
24+
foreach ($params as $param) {
25+
var_dump($param->getClass());
26+
}
27+
--EXPECT--
28+
object(ReflectionClass)#3 (1) {
29+
["name"]=>
30+
string(8) "DateTime"
31+
}

tests/issue_030.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Check for issue #30 (DateTimeImmutable::createFromFormat with ! returns DateTime)
3+
--SKIPIF--
4+
<?php
5+
$required_version = "5.5";
6+
$required_func = array("timecop_freeze");
7+
$required_class = array("TimecopDateTimeImmutable");
8+
include(__DIR__."/tests-skipcheck.inc.php");
9+
--INI--
10+
date.timezone=GMT
11+
timecop.func_override=1
12+
--FILE--
13+
<?php
14+
$dt1 = \DateTimeImmutable::createFromFormat('!Y-m-d', '2017-10-03');
15+
$dt2 = \DateTimeImmutable::createFromFormat('!Y-m-d', '2017-10-03');
16+
var_dump(get_class($dt1));
17+
var_dump($dt1->format('c'));
18+
var_dump(get_class($dt2));
19+
var_dump($dt2->format('c'));
20+
--EXPECT--
21+
string(17) "DateTimeImmutable"
22+
string(25) "2017-10-03T00:00:00+00:00"
23+
string(17) "DateTimeImmutable"
24+
string(25) "2017-10-03T00:00:00+00:00"

0 commit comments

Comments
 (0)