summaryrefslogtreecommitdiff
path: root/ext/date
diff options
context:
space:
mode:
authorCraig Duncan <git@duncanc.co.uk>2019-05-28 20:49:14 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-05-29 09:47:10 +0200
commit5d67271db07b94321cd57c5679bc6ab02070bc11 (patch)
treeb271a2e18866241d05b875a544fbbe04a019a7d2 /ext/date
parent3051147019943832eb91eb7fce1089b0e22a8369 (diff)
downloadphp-git-5d67271db07b94321cd57c5679bc6ab02070bc11.tar.gz
Add tests for DatePeriod properties
Diffstat (limited to 'ext/date')
-rw-r--r--ext/date/tests/DatePeriod_properties1.phpt37
-rw-r--r--ext/date/tests/DatePeriod_properties2.phpt46
2 files changed, 83 insertions, 0 deletions
diff --git a/ext/date/tests/DatePeriod_properties1.phpt b/ext/date/tests/DatePeriod_properties1.phpt
new file mode 100644
index 0000000000..32ede7d218
--- /dev/null
+++ b/ext/date/tests/DatePeriod_properties1.phpt
@@ -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"
diff --git a/ext/date/tests/DatePeriod_properties2.phpt b/ext/date/tests/DatePeriod_properties2.phpt
new file mode 100644
index 0000000000..01858e68d4
--- /dev/null
+++ b/ext/date/tests/DatePeriod_properties2.phpt
@@ -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