|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the flysystem-bundle project. |
| 5 | + * |
| 6 | + * (c) Titouan Galopin <galopintitouan@gmail.com> |
| 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 Tests\League\FlysystemBundle\Adapter\Builder; |
| 13 | + |
| 14 | +use AsyncAws\Flysystem\S3\S3FilesystemV1; |
| 15 | +use League\FlysystemBundle\Adapter\Builder\AsyncAwsAdapterDefinitionBuilder; |
| 16 | +use PHPUnit\Framework\TestCase; |
| 17 | +use Symfony\Component\DependencyInjection\Reference; |
| 18 | + |
| 19 | +/** |
| 20 | + * @requires PHP 7.2 |
| 21 | + */ |
| 22 | +class AsyncAwsAdapterDefinitionBuilderTest extends TestCase |
| 23 | +{ |
| 24 | + public function createBuilder() |
| 25 | + { |
| 26 | + return new AsyncAwsAdapterDefinitionBuilder(); |
| 27 | + } |
| 28 | + |
| 29 | + public function provideValidOptions() |
| 30 | + { |
| 31 | + yield 'minimal' => [[ |
| 32 | + 'client' => 'my_client', |
| 33 | + 'bucket' => 'bucket', |
| 34 | + ]]; |
| 35 | + |
| 36 | + yield 'prefix' => [[ |
| 37 | + 'client' => 'my_client', |
| 38 | + 'bucket' => 'bucket', |
| 39 | + 'prefix' => 'prefix/path', |
| 40 | + ]]; |
| 41 | + |
| 42 | + yield 'options' => [[ |
| 43 | + 'client' => 'my_client', |
| 44 | + 'bucket' => 'bucket', |
| 45 | + 'options' => [ |
| 46 | + 'ServerSideEncryption' => 'AES256', |
| 47 | + ], |
| 48 | + ]]; |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * @dataProvider provideValidOptions |
| 53 | + */ |
| 54 | + public function testCreateDefinition($options) |
| 55 | + { |
| 56 | + $this->assertSame(S3FilesystemV1::class, $this->createBuilder()->createDefinition($options)->getClass()); |
| 57 | + } |
| 58 | + |
| 59 | + public function testOptionsBehavior() |
| 60 | + { |
| 61 | + $definition = $this->createBuilder()->createDefinition([ |
| 62 | + 'client' => 'my_client', |
| 63 | + 'bucket' => 'bucket', |
| 64 | + 'prefix' => 'prefix/path', |
| 65 | + 'options' => [ |
| 66 | + 'ServerSideEncryption' => 'AES256', |
| 67 | + ], |
| 68 | + ]); |
| 69 | + |
| 70 | + $this->assertSame(S3FilesystemV1::class, $definition->getClass()); |
| 71 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 72 | + $this->assertSame('my_client', (string) $definition->getArgument(0)); |
| 73 | + $this->assertSame('bucket', $definition->getArgument(1)); |
| 74 | + $this->assertSame('prefix/path', $definition->getArgument(2)); |
| 75 | + $this->assertSame(['ServerSideEncryption' => 'AES256'], $definition->getArgument(3)); |
| 76 | + } |
| 77 | +} |
0 commit comments