From 5d67271db07b94321cd57c5679bc6ab02070bc11 Mon Sep 17 00:00:00 2001 From: Craig Duncan Date: Tue, 28 May 2019 20:49:14 +0100 Subject: [PATCH] Add tests for DatePeriod properties --- ext/date/tests/DatePeriod_properties1.phpt | 37 +++++++++++++++++ ext/date/tests/DatePeriod_properties2.phpt | 46 ++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 ext/date/tests/DatePeriod_properties1.phpt create mode 100644 ext/date/tests/DatePeriod_properties2.phpt diff --git a/ext/date/tests/DatePeriod_properties1.phpt b/ext/date/tests/DatePeriod_properties1.phpt new file mode 100644 index 00000000000..32ede7d2183 --- /dev/null +++ b/ext/date/tests/DatePeriod_properties1.phpt @@ -0,0 +1,37 @@ +--TEST-- +DatePeriod: Test read only properties +--INI-- +date.timezone=UTC +--FILE-- +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 00000000000..01858e68d4c --- /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-- +$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