mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Add tests for DatePeriod properties
This commit is contained in:
committed by
Nikita Popov
parent
3051147019
commit
5d67271db0
37
ext/date/tests/DatePeriod_properties1.phpt
Normal file
37
ext/date/tests/DatePeriod_properties1.phpt
Normal file
@@ -0,0 +1,37 @@
|
||||
--TEST--
|
||||
DatePeriod: Test read only properties
|
||||
--INI--
|
||||
date.timezone=UTC
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$start = new DateTime;
|
||||
$interval = new DateInterval('P1D');
|
||||
$end = new DateTime;
|
||||
$period = new DatePeriod($start, $interval, $end);
|
||||
|
||||
echo "recurrences: ";
|
||||
var_dump($period->recurrences);
|
||||
|
||||
echo "include_start_date: ";
|
||||
var_dump($period->include_start_date);
|
||||
|
||||
echo "start: ";
|
||||
var_dump($period->start == $start);
|
||||
|
||||
echo "current: ";
|
||||
var_dump($period->current);
|
||||
|
||||
echo "end: ";
|
||||
var_dump($period->end == $end);
|
||||
|
||||
echo "interval: ";
|
||||
var_dump($period->interval->format("%R%d"));
|
||||
?>
|
||||
--EXPECT--
|
||||
recurrences: int(1)
|
||||
include_start_date: bool(true)
|
||||
start: bool(true)
|
||||
current: NULL
|
||||
end: bool(true)
|
||||
interval: string(2) "+1"
|
||||
46
ext/date/tests/DatePeriod_properties2.phpt
Normal file
46
ext/date/tests/DatePeriod_properties2.phpt
Normal file
@@ -0,0 +1,46 @@
|
||||
--TEST--
|
||||
DatePeriod: Test cannot modify read only properties
|
||||
--INI--
|
||||
date.timezone=UTC
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$period = new DatePeriod(new DateTime, new DateInterval('P1D'), new DateTime);
|
||||
|
||||
$properties = [
|
||||
"recurrences",
|
||||
"include_start_date",
|
||||
"start",
|
||||
"current",
|
||||
"end",
|
||||
"interval",
|
||||
];
|
||||
|
||||
foreach ($properties as $property) {
|
||||
try {
|
||||
$period->$property = "new";
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
try {
|
||||
$period->$property[] = "extra";
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Writing to DatePeriod properties is unsupported
|
||||
Retrieval of DatePeriod properties for modification is unsupported
|
||||
Writing to DatePeriod properties is unsupported
|
||||
Retrieval of DatePeriod properties for modification is unsupported
|
||||
Writing to DatePeriod properties is unsupported
|
||||
Retrieval of DatePeriod properties for modification is unsupported
|
||||
Writing to DatePeriod properties is unsupported
|
||||
Retrieval of DatePeriod properties for modification is unsupported
|
||||
Writing to DatePeriod properties is unsupported
|
||||
Retrieval of DatePeriod properties for modification is unsupported
|
||||
Writing to DatePeriod properties is unsupported
|
||||
Retrieval of DatePeriod properties for modification is unsupported
|
||||
Reference in New Issue
Block a user