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