File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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 "
You can’t perform that action at this time.
0 commit comments