@@ -106,19 +106,19 @@ public function extractCrumb_invalidStringGiven_throwApiException(): void
106106 */
107107 public function transformHistoricalDataResult_csvGiven_returnArrayOfHistoricalData (): void
108108 {
109- $ returnedResult = $ this ->resultDecoder ->transformHistoricalDataResult (file_get_contents (__DIR__ .'/fixtures/historicalData.csv ' ));
109+ $ returnedResult = $ this ->resultDecoder ->transformHistoricalDataResult (file_get_contents (__DIR__ .'/fixtures/historicalData.json ' ));
110110
111111 $ this ->assertIsArray ($ returnedResult );
112112 $ this ->assertContainsOnlyInstancesOf (HistoricalData::class, $ returnedResult );
113113
114114 $ expectedExchangeRate = new HistoricalData (
115- new \DateTime ('2017-07-11 ' ),
116- 144.729996 ,
117- 145.850006 ,
118- 144.380005 ,
119- 145.529999 ,
120- 145.529999 ,
121- 19781800
115+ new \DateTime ('2024-09-30 ' , new \ DateTimeZone ( ' UTC ' ) ),
116+ 230.0399932861328 ,
117+ 233.0 ,
118+ 229.64999389648438 ,
119+ 233.0 ,
120+ 233.0 ,
121+ 54541900
122122 );
123123 $ this ->assertEquals ($ expectedExchangeRate , $ returnedResult [0 ]);
124124 }
@@ -129,7 +129,7 @@ public function transformHistoricalDataResult_csvGiven_returnArrayOfHistoricalDa
129129 public function transformHistoricalDataResult_invalidColumnsCsvGiven_throwApiException (): void
130130 {
131131 $ this ->expectException (ApiException::class);
132- $ this ->expectExceptionMessage ('CSV did not contain correct number of columns ' );
132+ $ this ->expectExceptionMessage ('Response is not a valid JSON ' );
133133
134134 $ this ->resultDecoder ->transformHistoricalDataResult (file_get_contents (__DIR__ .'/fixtures/invalidColumnsHistoricalData.csv ' ));
135135 }
@@ -140,7 +140,7 @@ public function transformHistoricalDataResult_invalidColumnsCsvGiven_throwApiExc
140140 public function transformHistoricalDataResult_unexpectedHeaderLineCsvGiven_throwApiException (): void
141141 {
142142 $ this ->expectException (ApiException::class);
143- $ this ->expectExceptionMessage ('CSV header line did not match expected header line, given: 12345 1234567, expected: Date,Open,High,Low,Close,Adj Close,Volume ' );
143+ $ this ->expectExceptionMessage ('Response is not a valid JSON ' );
144144
145145 $ invalidCsvString = "12345 \t1234567 \t" ;
146146 $ this ->resultDecoder ->transformHistoricalDataResult ($ invalidCsvString );
@@ -152,7 +152,7 @@ public function transformHistoricalDataResult_unexpectedHeaderLineCsvGiven_throw
152152 public function transformHistoricalDataResult_invalidDateTimeFormatCsvGiven_throwApiException (): void
153153 {
154154 $ this ->expectException (ApiException::class);
155- $ this ->expectExceptionMessage ('Not a date in column "Date":2017-07 ' );
155+ $ this ->expectExceptionMessage ('Response is not a valid JSON ' );
156156
157157 $ this ->resultDecoder ->transformHistoricalDataResult (file_get_contents (__DIR__ .'/fixtures/invalidDateTimeFormatHistoricalData.csv ' ));
158158 }
@@ -163,7 +163,7 @@ public function transformHistoricalDataResult_invalidDateTimeFormatCsvGiven_thro
163163 public function transformHistoricalDataResult_invalidNumericStringCsvGiven_throwApiException (): void
164164 {
165165 $ this ->expectException (ApiException::class);
166- $ this ->expectExceptionMessage ('Not a number in column "High": this_is_not_numeric_string ' );
166+ $ this ->expectExceptionMessage ('Response is not a valid JSON ' );
167167
168168 $ this ->resultDecoder ->transformHistoricalDataResult (file_get_contents (__DIR__ .'/fixtures/invalidNumericStringHistoricalData.csv ' ));
169169 }
@@ -173,16 +173,17 @@ public function transformHistoricalDataResult_invalidNumericStringCsvGiven_throw
173173 */
174174 public function transformDividendDataResult_csvGiven_returnArrayOfDividendData (): void
175175 {
176- $ returnedResult = $ this ->resultDecoder ->transformDividendDataResult (file_get_contents (__DIR__ .'/fixtures/dividendData.csv ' ));
176+ $ returnedResult = $ this ->resultDecoder ->transformDividendDataResult (file_get_contents (__DIR__ .'/fixtures/dividendData.json ' ));
177177
178178 $ this ->assertIsArray ($ returnedResult );
179179 $ this ->assertContainsOnlyInstancesOf (DividendData::class, $ returnedResult );
180+ $ firstResult = array_shift ($ returnedResult );
180181
181182 $ expectedExchangeRate = new DividendData (
182- new \DateTime ('2017-07-11 ' ),
183- 0.205
183+ new \DateTime ('2019-11-07 ' , new \ DateTimeZone ( ' UTC ' ) ),
184+ 0.1925
184185 );
185- $ this ->assertEquals ($ expectedExchangeRate , $ returnedResult [ 0 ] );
186+ $ this ->assertEquals ($ expectedExchangeRate , $ firstResult );
186187 }
187188
188189 /**
@@ -191,7 +192,7 @@ public function transformDividendDataResult_csvGiven_returnArrayOfDividendData()
191192 public function transformDividendDataResult_invalidColumnsCsvGiven_throwApiException (): void
192193 {
193194 $ this ->expectException (ApiException::class);
194- $ this ->expectExceptionMessage ('CSV did not contain correct number of columns ' );
195+ $ this ->expectExceptionMessage ('Response is not a valid JSON ' );
195196
196197 $ this ->resultDecoder ->transformDividendDataResult (file_get_contents (__DIR__ .'/fixtures/invalidColumnsDividendData.csv ' ));
197198 }
@@ -202,7 +203,7 @@ public function transformDividendDataResult_invalidColumnsCsvGiven_throwApiExcep
202203 public function transformDividendDataResult_unexpectedHeaderLineCsvGiven_throwApiException (): void
203204 {
204205 $ this ->expectException (ApiException::class);
205- $ this ->expectExceptionMessage ('CSV header line did not match expected header line, given: 12345 1234567, expected: Date,Dividends ' );
206+ $ this ->expectExceptionMessage ('Response is not a valid JSON ' );
206207
207208 $ invalidCsvString = "12345 \t1234567 \t" ;
208209 $ this ->resultDecoder ->transformDividendDataResult ($ invalidCsvString );
@@ -214,7 +215,7 @@ public function transformDividendDataResult_unexpectedHeaderLineCsvGiven_throwAp
214215 public function transformDividendDataResult_invalidDateTimeFormatCsvGiven_throwApiException (): void
215216 {
216217 $ this ->expectException (ApiException::class);
217- $ this ->expectExceptionMessage ('Not a date in column "Date":2017-07 ' );
218+ $ this ->expectExceptionMessage ('Response is not a valid JSON ' );
218219
219220 $ this ->resultDecoder ->transformDividendDataResult (file_get_contents (__DIR__ .'/fixtures/invalidDateTimeFormatDividendData.csv ' ));
220221 }
@@ -225,7 +226,7 @@ public function transformDividendDataResult_invalidDateTimeFormatCsvGiven_throwA
225226 public function transformDividendDataResult_invalidNumericStringCsvGiven_throwApiException (): void
226227 {
227228 $ this ->expectException (ApiException::class);
228- $ this ->expectExceptionMessage ('Not a number in column Dividends: this_is_not_numeric_string ' );
229+ $ this ->expectExceptionMessage ('Response is not a valid JSON ' );
229230
230231 $ this ->resultDecoder ->transformDividendDataResult (file_get_contents (__DIR__ .'/fixtures/invalidNumericStringDividendData.csv ' ));
231232 }
@@ -235,16 +236,17 @@ public function transformDividendDataResult_invalidNumericStringCsvGiven_throwAp
235236 */
236237 public function transformSplitDataResult_csvGiven_returnArrayOfSplitData (): void
237238 {
238- $ returnedResult = $ this ->resultDecoder ->transformSplitDataResult (file_get_contents (__DIR__ .'/fixtures/splitData.csv ' ));
239+ $ returnedResult = $ this ->resultDecoder ->transformSplitDataResult (file_get_contents (__DIR__ .'/fixtures/splitData.json ' ));
239240
240241 $ this ->assertIsArray ($ returnedResult );
241242 $ this ->assertContainsOnlyInstancesOf (SplitData::class, $ returnedResult );
243+ $ firstResult = array_shift ($ returnedResult );
242244
243245 $ expectedExchangeRate = new SplitData (
244- new \DateTime ('2017-07-11 ' ),
246+ new \DateTime ('2020-08-31 ' , new \ DateTimeZone ( ' UTC ' ) ),
245247 '4:1 '
246248 );
247- $ this ->assertEquals ($ expectedExchangeRate , $ returnedResult [ 0 ] );
249+ $ this ->assertEquals ($ expectedExchangeRate , $ firstResult );
248250 }
249251
250252 /**
@@ -253,7 +255,7 @@ public function transformSplitDataResult_csvGiven_returnArrayOfSplitData(): void
253255 public function transformSplitDataResult_invalidColumnsCsvGiven_throwApiException (): void
254256 {
255257 $ this ->expectException (ApiException::class);
256- $ this ->expectExceptionMessage ('CSV did not contain correct number of columns ' );
258+ $ this ->expectExceptionMessage ('Response is not a valid JSON ' );
257259
258260 $ this ->resultDecoder ->transformSplitDataResult (file_get_contents (__DIR__ .'/fixtures/invalidColumnsSplitData.csv ' ));
259261 }
@@ -264,7 +266,7 @@ public function transformSplitDataResult_invalidColumnsCsvGiven_throwApiExceptio
264266 public function transformSplitDataResult_unexpectedHeaderLineCsvGiven_throwApiException (): void
265267 {
266268 $ this ->expectException (ApiException::class);
267- $ this ->expectExceptionMessage ('CSV header line did not match expected header line, given: 12345 1234567, expected: Date,Stock Splits ' );
269+ $ this ->expectExceptionMessage ('Response is not a valid JSON ' );
268270
269271 $ invalidCsvString = "12345 \t1234567 \t" ;
270272 $ this ->resultDecoder ->transformSplitDataResult ($ invalidCsvString );
@@ -276,7 +278,7 @@ public function transformSplitDataResult_unexpectedHeaderLineCsvGiven_throwApiEx
276278 public function transformSplitDataResult_invalidDateTimeFormatCsvGiven_throwApiException (): void
277279 {
278280 $ this ->expectException (ApiException::class);
279- $ this ->expectExceptionMessage ('Not a date in column "Date":2017-07 ' );
281+ $ this ->expectExceptionMessage ('Response is not a valid JSON ' );
280282
281283 $ this ->resultDecoder ->transformSplitDataResult (file_get_contents (__DIR__ .'/fixtures/invalidDateTimeFormatSplitData.csv ' ));
282284 }
0 commit comments