|
14 | 14 | use League\FlysystemBundle\Adapter\AdapterDefinitionFactory;
|
15 | 15 | use PHPUnit\Framework\TestCase;
|
16 | 16 | use Symfony\Component\DependencyInjection\Definition;
|
17 |
| -use Symfony\Component\Yaml\Yaml; |
18 | 17 |
|
19 | 18 | class AdapterDefinitionFactoryTest extends TestCase
|
20 | 19 | {
|
21 | 20 | public static function provideConfigOptions(): \Generator
|
22 | 21 | {
|
23 |
| - $config = Yaml::parseFile(__DIR__.'/options.yaml'); |
| 22 | + yield 'fs_async_aws' => [ |
| 23 | + 'adapter' => 'asyncaws', |
| 24 | + 'options' => [ |
| 25 | + 'client' => 'aws_client_service', |
| 26 | + 'bucket' => 'bucket_name', |
| 27 | + 'prefix' => 'optional/path/prefix', |
| 28 | + ], |
| 29 | + ]; |
24 | 30 |
|
25 |
| - foreach ($config as $fs) { |
26 |
| - yield $fs['adapter'] => [$fs['adapter'], $fs['options'] ?? []]; |
27 |
| - } |
| 31 | + yield 'fs_aws' => [ |
| 32 | + 'adapter' => 'aws', |
| 33 | + 'options' => [ |
| 34 | + 'client' => 'aws_client_service', |
| 35 | + 'bucket' => 'bucket_name', |
| 36 | + 'prefix' => 'optional/path/prefix', |
| 37 | + ], |
| 38 | + ]; |
| 39 | + |
| 40 | + yield 'fs_azure' => [ |
| 41 | + 'adapter' => 'azure', |
| 42 | + 'options' => [ |
| 43 | + 'client' => 'azure_client_service', |
| 44 | + 'container' => 'container_name', |
| 45 | + 'prefix' => 'optional/path/prefix', |
| 46 | + ], |
| 47 | + ]; |
| 48 | + |
| 49 | + yield 'fs_ftp' => [ |
| 50 | + 'adapter' => 'ftp', |
| 51 | + 'options' => [ |
| 52 | + 'host' => 'ftp.example.com', |
| 53 | + 'username' => 'username', |
| 54 | + 'password' => 'password', |
| 55 | + 'port' => 21, |
| 56 | + 'root' => '/path/to/root', |
| 57 | + 'passive' => true, |
| 58 | + 'ssl' => true, |
| 59 | + 'timeout' => 30, |
| 60 | + 'ignore_passive_address' => true, |
| 61 | + ], |
| 62 | + ]; |
| 63 | + |
| 64 | + yield 'fs_gcloud' => [ |
| 65 | + 'adapter' => 'gcloud', |
| 66 | + 'options' => [ |
| 67 | + 'client' => 'gcloud_client_service', |
| 68 | + 'bucket' => 'bucket_name', |
| 69 | + 'prefix' => 'optional/path/prefix', |
| 70 | + ], |
| 71 | + ]; |
| 72 | + |
| 73 | + yield 'fs_local' => [ |
| 74 | + 'adapter' => 'local', |
| 75 | + 'options' => [ |
| 76 | + 'directory' => '%kernel.project_dir%/storage', |
| 77 | + 'lock' => 0, |
| 78 | + 'skip_links' => false, |
| 79 | + 'lazy_root_creation' => false, |
| 80 | + 'permissions' => [ |
| 81 | + 'file' => [ |
| 82 | + 'public' => '0744', |
| 83 | + 'private' => '0700', |
| 84 | + ], |
| 85 | + 'dir' => [ |
| 86 | + 'public' => '0755', |
| 87 | + 'private' => '0700', |
| 88 | + ], |
| 89 | + ], |
| 90 | + ], |
| 91 | + ]; |
| 92 | + |
| 93 | + yield 'fs_memory' => [ |
| 94 | + 'adapter' => 'memory', |
| 95 | + 'options' => [], |
| 96 | + ]; |
| 97 | + |
| 98 | + yield 'fs_sftp' => [ |
| 99 | + 'adapter' => 'sftp', |
| 100 | + 'options' => [ |
| 101 | + 'host' => 'example.com', |
| 102 | + 'port' => 22, |
| 103 | + 'username' => 'username', |
| 104 | + 'password' => 'password', |
| 105 | + 'privateKey' => 'path/to/or/contents/of/privatekey', |
| 106 | + 'root' => '/path/to/root', |
| 107 | + 'timeout' => 10, |
| 108 | + 'preferredAlgorithms' => [ |
| 109 | + 'hostkey' => ['rsa-sha2-256', 'ssh-rsa'], |
| 110 | + ], |
| 111 | + ], |
| 112 | + ]; |
28 | 113 | }
|
29 | 114 |
|
30 | 115 | /**
|
31 | 116 | * @dataProvider provideConfigOptions
|
32 | 117 | */
|
33 |
| - public function testCreateDefinition($name, $options): void |
| 118 | + public static function testCreateDefinition($name, $options): void |
34 | 119 | {
|
35 | 120 | $factory = new AdapterDefinitionFactory();
|
36 | 121 |
|
37 | 122 | $definition = $factory->createDefinition($name, $options);
|
38 |
| - $this->assertInstanceOf(Definition::class, $definition); |
| 123 | + self::assertInstanceOf(Definition::class, $definition); |
39 | 124 | }
|
40 | 125 | }
|
0 commit comments