@@ -19,10 +19,11 @@ public function testEncode(): void
19
19
);
20
20
}
21
21
22
- public static function providesDecodeCases (): array
22
+ public static function providesValidDecodeCases (): array
23
23
{
24
24
return [
25
25
// UTC
26
+ ['2018-04-05T17:31:00Z ' , '2018-04-05t17:31:00Z ' ],
26
27
['2018-04-05T17:31:00Z ' , '2018-04-05T17:31:00Z ' ],
27
28
['1985-04-12T23:20:50.100000Z ' , '1985-04-12T23:20:50.1Z ' ],
28
29
['1985-04-12T23:20:50.100000Z ' , '1985-04-12T23:20:50.10Z ' ],
@@ -41,6 +42,7 @@ public static function providesDecodeCases(): array
41
42
['1985-04-12T23:20:50.123456Z ' , '1985-04-12T23:20:50.123456789Z ' ],
42
43
43
44
// +01:00
45
+ ['2018-04-05T16:31:00Z ' , '2018-04-05t17:31:00+01:00 ' ],
44
46
['2018-04-05T16:31:00Z ' , '2018-04-05T17:31:00+01:00 ' ],
45
47
['1985-04-12T22:20:50.100000Z ' , '1985-04-12T23:20:50.1+01:00 ' ],
46
48
['1985-04-12T22:20:50.100000Z ' , '1985-04-12T23:20:50.10+01:00 ' ],
@@ -57,12 +59,17 @@ public static function providesDecodeCases(): array
57
59
['1985-04-12T22:20:50.123456Z ' , '1985-04-12T23:20:50.1234567+01:00 ' ],
58
60
['1985-04-12T22:20:50.123456Z ' , '1985-04-12T23:20:50.12345678+01:00 ' ],
59
61
['1985-04-12T22:20:50.123456Z ' , '1985-04-12T23:20:50.123456789+01:00 ' ],
60
- ['1985-04-12T22:20:50.123456Z ' , '1985-04-12T23:20:50.1234567890+01:00 ' ],
62
+
63
+ // -05:00
64
+ ['2018-04-05T22:31:00Z ' , '2018-04-05t17:31:00-05:00 ' ],
65
+ ['2018-04-05T22:31:00Z ' , '2018-04-05T17:31:00-05:00 ' ],
66
+ ['1985-04-13T04:20:50.123456Z ' , '1985-04-12T23:20:50.123456-05:00 ' ],
67
+ ['1985-04-13T04:20:50.123456Z ' , '1985-04-12T23:20:50.123456789-05:00 ' ],
61
68
];
62
69
}
63
70
64
71
/**
65
- * @dataProvider providesDecodeCases
72
+ * @dataProvider providesValidDecodeCases
66
73
*/
67
74
public function testDecode (string $ expected , string $ input ): void
68
75
{
@@ -88,14 +95,30 @@ public function testDecodeEmpty(): void
88
95
);
89
96
}
90
97
91
- public function testDecodeInvalidTime (): void
98
+ public static function providesInvalidDecodeCases (): array
99
+ {
100
+ return [
101
+ ['' ],
102
+ ['123 ' ],
103
+ ['2018asdsdsafd ' ],
104
+ ['2018-04-05 ' ],
105
+ ['2018-04-05 17:31:00Z ' ],
106
+ ['2018-04-05T17:31:00.Z ' ],
107
+ ['2018-04-05T17:31:00ZZ ' ],
108
+ ];
109
+ }
110
+
111
+ /**
112
+ * @dataProvider providesInvalidDecodeCases
113
+ */
114
+ public function testDecodeInvalidTime (string $ input ): void
92
115
{
93
116
$ this ->expectException (ValueError::class);
94
117
95
118
$ this ->expectExceptionMessage (
96
119
'CloudEvents \\Utilities \\TimeFormatter::decode(): Argument #1 ($time) is not a valid RFC3339 timestamp '
97
120
);
98
121
99
- TimeFormatter::decode (' 2018asdsdsafd ' );
122
+ TimeFormatter::decode ($ input );
100
123
}
101
124
}
0 commit comments