1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\MediaBundle\Tests\Metadata; |
15
|
|
|
|
16
|
|
|
use Aws\S3\Enum\Storage; |
17
|
|
|
use PHPUnit\Framework\TestCase; |
18
|
|
|
use Sonata\MediaBundle\Metadata\AmazonMetadataBuilder; |
19
|
|
|
use Sonata\MediaBundle\Model\MediaInterface; |
20
|
|
|
|
21
|
|
|
class AmazonMetadataBuilderTest extends TestCase |
22
|
|
|
{ |
23
|
|
|
public function testAmazon(): void |
24
|
|
|
{ |
25
|
|
|
$media = $this->createMock(MediaInterface::class); |
26
|
|
|
$filename = '/test/folder/testfile.png'; |
27
|
|
|
|
28
|
|
|
foreach ($this->provider() as $provider) { |
29
|
|
|
[$a, $b] = $provider; |
|
|
|
|
30
|
|
|
$amazonmetadatabuilder = new AmazonMetadataBuilder($a); |
31
|
|
|
$this->assertSame($b, $amazonmetadatabuilder->get($media, $filename)); |
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function provider(): array |
36
|
|
|
{ |
37
|
|
|
return [ |
38
|
|
|
[['acl' => 'private'], ['ACL' => AmazonMetadataBuilder::PRIVATE_ACCESS, 'contentType' => 'image/png']], |
39
|
|
|
[['acl' => 'public'], ['ACL' => AmazonMetadataBuilder::PUBLIC_READ, 'contentType' => 'image/png']], |
40
|
|
|
[['acl' => 'open'], ['ACL' => AmazonMetadataBuilder::PUBLIC_READ_WRITE, 'contentType' => 'image/png']], |
41
|
|
|
[['acl' => 'auth_read'], ['ACL' => AmazonMetadataBuilder::AUTHENTICATED_READ, 'contentType' => 'image/png']], |
42
|
|
|
[['acl' => 'owner_read'], ['ACL' => AmazonMetadataBuilder::BUCKET_OWNER_READ, 'contentType' => 'image/png']], |
43
|
|
|
[['acl' => 'owner_full_control'], ['ACL' => AmazonMetadataBuilder::BUCKET_OWNER_FULL_CONTROL, 'contentType' => 'image/png']], |
44
|
|
|
[['storage' => 'standard'], ['storage' => AmazonMetadataBuilder::STORAGE_STANDARD, 'contentType' => 'image/png']], |
45
|
|
|
[['storage' => 'reduced'], ['storage' => AmazonMetadataBuilder::STORAGE_REDUCED, 'contentType' => 'image/png']], |
46
|
|
|
[['cache_control' => 'max-age=86400'], ['CacheControl' => 'max-age=86400', 'contentType' => 'image/png']], |
47
|
|
|
[['encryption' => 'aes256'], ['encryption' => 'AES256', 'contentType' => 'image/png']], |
48
|
|
|
[['meta' => ['key' => 'value']], ['meta' => ['key' => 'value'], 'contentType' => 'image/png']], |
49
|
|
|
[['acl' => 'public', 'storage' => 'standard', 'cache_control' => 'max-age=86400', 'encryption' => 'aes256', 'meta' => ['key' => 'value']], ['ACL' => AmazonMetadataBuilder::PUBLIC_READ, 'storage' => Storage::STANDARD, 'meta' => ['key' => 'value'], 'CacheControl' => 'max-age=86400', 'encryption' => 'AES256', 'contentType' => 'image/png']], |
50
|
|
|
]; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.