|
17 | 17 | use Mockery;
|
18 | 18 | use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNAdapter;
|
19 | 19 | use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNClient;
|
| 20 | +use PlatformCommunity\Flysystem\BunnyCDN\Exceptions\BunnyCDNException; |
20 | 21 | use PlatformCommunity\Flysystem\BunnyCDN\Util;
|
21 | 22 | use Throwable;
|
22 | 23 |
|
@@ -172,4 +173,53 @@ public function test_regression_pr_20()
|
172 | 173 | $this->assertEquals($image, stream_get_contents($stream));
|
173 | 174 | });
|
174 | 175 | }
|
| 176 | + |
| 177 | + /** |
| 178 | + * Github Issue - 21 |
| 179 | + * https://github.com/PlatformCommunity/flysystem-bunnycdn/issues/21 |
| 180 | + * |
| 181 | + * Issue present where the date format can come back in either one of the following formats: |
| 182 | + * - 2022-04-10T17:43:49.297 |
| 183 | + * - 2022-04-10T17:43:49 |
| 184 | + * |
| 185 | + * Pretty sure I'm just going to create a static method called "parse_bunny_date" within the client to handle this. |
| 186 | + * @throws FilesystemException |
| 187 | + */ |
| 188 | + public function test_regression_issue_21() |
| 189 | + { |
| 190 | + $client = new MockClient(self::STORAGE_ZONE, 'api-key'); |
| 191 | + |
| 192 | + $client->add_response( |
| 193 | + new Response(200, [], json_encode( |
| 194 | + [ |
| 195 | + /** |
| 196 | + * First with the milliseconds |
| 197 | + */ |
| 198 | + array_merge( |
| 199 | + $client::example_file('/example_image.png', self::STORAGE_ZONE), |
| 200 | + [ |
| 201 | + 'LastChanged' => date('Y-m-d\TH:i:s.v'), |
| 202 | + 'DateCreated' => date('Y-m-d\TH:i:s.v'), |
| 203 | + ] |
| 204 | + ), |
| 205 | + /** |
| 206 | + * Then without |
| 207 | + */ |
| 208 | + array_merge( |
| 209 | + $client::example_file('/example_image.png', self::STORAGE_ZONE), |
| 210 | + [ |
| 211 | + 'LastChanged' => date('Y-m-d\TH:i:s'), |
| 212 | + 'DateCreated' => date('Y-m-d\TH:i:s'), |
| 213 | + ] |
| 214 | + ) |
| 215 | + ] |
| 216 | + )) |
| 217 | + ); |
| 218 | + |
| 219 | + $adapter = new Filesystem(new BunnyCDNAdapter($client)); |
| 220 | + $response = $adapter->listContents('/')->toArray(); |
| 221 | + |
| 222 | + $this->assertIsArray($response); |
| 223 | + $this->assertCount(2, $response); |
| 224 | + } |
175 | 225 | }
|
0 commit comments