|
3 | 3 | namespace PlatformCommunity\Flysystem\BunnyCDN\Tests;
|
4 | 4 |
|
5 | 5 | use Exception;
|
| 6 | +use GuzzleHttp\Psr7\Response; |
6 | 7 | use League\Flysystem\Config;
|
7 | 8 | use League\Flysystem\FileExistsException;
|
8 | 9 | use League\Flysystem\FileNotFoundException;
|
|
15 | 16 | use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNAdapter;
|
16 | 17 | use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNClient;
|
17 | 18 | use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNRegion;
|
| 19 | +use PlatformCommunity\Flysystem\BunnyCDN\Exceptions\BunnyCDNException; |
18 | 20 | use Prophecy\Argument;
|
19 | 21 | use RuntimeException;
|
20 | 22 |
|
@@ -385,22 +387,53 @@ public function it_cant_get_public_url()
|
385 | 387 | }
|
386 | 388 |
|
387 | 389 | /**
|
388 |
| - * Fix issue where `fopen` complains when opening downloaded image file#20 |
389 |
| - * https://github.com/PlatformCommunity/flysystem-bunnycdn/pull/20 |
| 390 | + * Github Issue - 21 |
| 391 | + * https://github.com/PlatformCommunity/flysystem-bunnycdn/issues/21 |
390 | 392 | *
|
391 |
| - * Seems to not be an issue out of v1, only v2 & v3 |
392 |
| - * @throws FileNotFoundException |
| 393 | + * Issue present where the date format can come back in either one of the following formats: |
| 394 | + * - 2022-04-10T17:43:49.297 |
| 395 | + * - 2022-04-10T17:43:49 |
| 396 | + * |
| 397 | + * Pretty sure I'm just going to create a static method called "parse_bunny_date" within the client to handle this. |
| 398 | + * @throws BunnyCDNException |
393 | 399 | */
|
394 | 400 | public function test_regression_pr_20()
|
395 | 401 | {
|
396 |
| - $image = base64_decode("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg=="); |
397 |
| - $this->givenItHasFile('path.png', $image); |
398 | 402 |
|
399 |
| - $filesystem = new Filesystem($this->adapter); |
| 403 | + $client = new MockClient(self::STORAGE_ZONE, 'api-key'); |
| 404 | + |
| 405 | + $client->add_response( |
| 406 | + new Response(200, [], json_encode( |
| 407 | + [ |
| 408 | + /** |
| 409 | + * First with the milliseconds |
| 410 | + */ |
| 411 | + array_merge( |
| 412 | + $client::example_file('/subfolder/example_image.png', self::STORAGE_ZONE), |
| 413 | + [ |
| 414 | + 'LastChanged' => date('Y-m-d\TH:i:s.v'), |
| 415 | + 'DateCreated' => date('Y-m-d\TH:i:s.v'), |
| 416 | + ] |
| 417 | + ), |
| 418 | + /** |
| 419 | + * Then without |
| 420 | + */ |
| 421 | + array_merge( |
| 422 | + $client::example_file('/subfolder/example_image.png', self::STORAGE_ZONE), |
| 423 | + [ |
| 424 | + 'LastChanged' => date('Y-m-d\TH:i:s'), |
| 425 | + 'DateCreated' => date('Y-m-d\TH:i:s'), |
| 426 | + ] |
| 427 | + ) |
| 428 | + ] |
| 429 | + )) |
| 430 | + ); |
400 | 431 |
|
401 |
| - $stream = $filesystem->readStream('path.png'); |
| 432 | + $adapter = new BunnyCDNAdapter($client); |
| 433 | + $response = $adapter->listContents('/'); |
402 | 434 |
|
403 |
| - $this->assertIsResource($stream); |
404 |
| - $this->assertEquals($image, stream_get_contents($stream)); |
| 435 | + $this->assertIsArray($response); |
| 436 | + $this->assertCount(2, $response); |
405 | 437 | }
|
| 438 | + |
406 | 439 | }
|
0 commit comments