xref: /PHP-8.2/ext/date/tests/bug74639.phpt (revision 3cfbbf29)
1--TEST--
2Bug #74639 Cloning DatePeriod leads to segfault
3--FILE--
4<?php
5
6$start = new DateTime('2017-05-22 09:00:00');
7$end = new DateTime('2017-08-24 18:00:00');
8$interval = $start->diff($end);
9
10$period = new DatePeriod($start, $interval, $end);
11$clonedPeriod = clone $period;
12$clonedInterval = clone $interval;
13
14if ($period->getStartDate() != $clonedPeriod->getStartDate()) {
15    echo "failure\n";
16}
17
18if ($period->getEndDate() != $clonedPeriod->getEndDate()) {
19    echo "failure\n";
20}
21
22if ($interval->format('Y-m-d H:i:s') != $clonedInterval->format('Y-m-d H:i:s')) {
23    echo "failure\n";
24}
25
26echo 'success';
27?>
28--EXPECT--
29success
30