com php-src: Add tests for DatePeriod properties: ext/date/test s/DatePeriod_properties1.phpt ext/date/tests/DatePeriod _properties2.phpt

From: Date: Wed, 29 May 2019 07:47:10 +0000
Subject: com php-src: Add tests for DatePeriod properties: ext/date/test s/DatePeriod_properties1.phpt ext/date/tests/DatePeriod _properties2.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-106430@lists.php.net to get a copy of this message
Commit: 5d67271db07b94321cd57c5679bc6ab02070bc11 Author: Craig Duncan <git@duncanc.co.uk> Tue, 28 May 2019 20:49:14 +0100 Committer: Nikita Popov <nikita.ppv@gmail.com> Wed, 29 May 2019 09:47:10 +0200 Parents: 3051147019943832eb91eb7fce1089b0e22a8369 Branches: PHP-7.2 PHP-7.3 PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5d67271db07b94321cd57c5679bc6ab02070bc11 Log: Add tests for DatePeriod properties Changed paths: A ext/date/tests/DatePeriod_properties1.phpt A ext/date/tests/DatePeriod_properties2.phpt Diff: diff --git a/ext/date/tests/DatePeriod_properties1.phpt b/ext/date/tests/DatePeriod_properties1.phpt new file mode 100644 index 0000000..32ede7d --- /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 0000000..01858e6 --- /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

« previous php.cvs (#106430) next »