Skip to content

Commit 32e72dc

Browse files
committed
Add test for cloning TimecopDateTime / Remove some useless codes
1 parent d94e229 commit 32e72dc

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

tests/013.phpt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Check for clone TimecopDateTime instance
3+
--SKIPIF--
4+
<?php
5+
extension_loaded('timecop') or die('skip timecop not available');
6+
$required_class = array("timecopdatetime");
7+
foreach ($required_class as $class_name) {
8+
if (!class_exists($class_name)) {
9+
die("skip $class_name class is not available.");
10+
}
11+
}
12+
--INI--
13+
date.timezone=America/Los_Angeles
14+
timecop.func_override=0
15+
--FILE--
16+
<?php
17+
$dt1 = new TimecopDateTime("2012-01-01 12:00:00 GMT");
18+
$dt2 = clone $dt1;
19+
var_dump($dt2->format("c"));
20+
--EXPECT--
21+
string(25) "2012-01-01T12:00:00+00:00"

timecop.c

-4
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,6 @@ static int update_request_time(long unixtime TSRMLS_DC)
538538
MAKE_STD_ZVAL(tmp);
539539
ZVAL_LONG(tmp, unixtime);
540540
add_assoc_zval(*server_vars, "REQUEST_TIME", tmp);
541-
zval_dtor(tmp);
542541
}
543542

544543
return SUCCESS;
@@ -556,7 +555,6 @@ static int restore_request_time(TSRMLS_D)
556555
Z_TYPE_PP(server_vars) == IS_ARRAY &&
557556
zend_hash_find(Z_ARRVAL_PP(server_vars), "REQUEST_TIME", sizeof("REQUEST_TIME"), (void **) &request_time) == SUCCESS) {
558557
add_assoc_zval(*server_vars, "REQUEST_TIME", orig_request_time);
559-
zval_dtor(orig_request_time);
560558
TIMECOP_G(orig_request_time) = NULL;
561559
}
562560
return SUCCESS;
@@ -629,8 +627,6 @@ static int fix_datetime_timestamp(zval **datetime_obj, zval *time, zval *timezon
629627
}
630628
}
631629

632-
//zend_call_method_with_1_params(NULL, NULL, NULL, "var_dump", NULL, &now);
633-
634630
zend_call_method_with_0_params(datetime_obj, Z_OBJCE_PP(datetime_obj), NULL, "gettimestamp", &orig_timestamp);
635631
if (timezone_obj) {
636632
zval *zonename;

0 commit comments

Comments
 (0)