File tree Expand file tree Collapse file tree 2 files changed +83
-0
lines changed Expand file tree Collapse file tree 2 files changed +83
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ DatePeriod: Test read only properties
3
+ --INI--
4
+ date.timezone=UTC
5
+ --FILE--
6
+ <?php
7
+
8
+ $ start = new DateTime ;
9
+ $ interval = new DateInterval ('P1D ' );
10
+ $ end = new DateTime ;
11
+ $ period = new DatePeriod ($ start , $ interval , $ end );
12
+
13
+ echo "recurrences: " ;
14
+ var_dump ($ period ->recurrences );
15
+
16
+ echo "include_start_date: " ;
17
+ var_dump ($ period ->include_start_date );
18
+
19
+ echo "start: " ;
20
+ var_dump ($ period ->start == $ start );
21
+
22
+ echo "current: " ;
23
+ var_dump ($ period ->current );
24
+
25
+ echo "end: " ;
26
+ var_dump ($ period ->end == $ end );
27
+
28
+ echo "interval: " ;
29
+ var_dump ($ period ->interval ->format ("%R%d " ));
30
+ ?>
31
+ --EXPECT--
32
+ recurrences: int(1)
33
+ include_start_date: bool(true)
34
+ start: bool(true)
35
+ current: NULL
36
+ end: bool(true)
37
+ interval: string(2) "+1"
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ DatePeriod: Test cannot modify read only properties
3
+ --INI--
4
+ date.timezone=UTC
5
+ --FILE--
6
+ <?php
7
+
8
+ $ period = new DatePeriod (new DateTime , new DateInterval ('P1D ' ), new DateTime );
9
+
10
+ $ properties = [
11
+ "recurrences " ,
12
+ "include_start_date " ,
13
+ "start " ,
14
+ "current " ,
15
+ "end " ,
16
+ "interval " ,
17
+ ];
18
+
19
+ foreach ($ properties as $ property ) {
20
+ try {
21
+ $ period ->$ property = "new " ;
22
+ } catch (Error $ e ) {
23
+ echo $ e ->getMessage () . "\n" ;
24
+ }
25
+
26
+ try {
27
+ $ period ->$ property [] = "extra " ;
28
+ } catch (Error $ e ) {
29
+ echo $ e ->getMessage () . "\n" ;
30
+ }
31
+ }
32
+
33
+ ?>
34
+ --EXPECT--
35
+ Writing to DatePeriod properties is unsupported
36
+ Retrieval of DatePeriod properties for modification is unsupported
37
+ Writing to DatePeriod properties is unsupported
38
+ Retrieval of DatePeriod properties for modification is unsupported
39
+ Writing to DatePeriod properties is unsupported
40
+ Retrieval of DatePeriod properties for modification is unsupported
41
+ Writing to DatePeriod properties is unsupported
42
+ Retrieval of DatePeriod properties for modification is unsupported
43
+ Writing to DatePeriod properties is unsupported
44
+ Retrieval of DatePeriod properties for modification is unsupported
45
+ Writing to DatePeriod properties is unsupported
46
+ Retrieval of DatePeriod properties for modification is unsupported
You can’t perform that action at this time.
0 commit comments