Skip to content

Commit 4d51e4d

Browse files
authored
Merge pull request #190 from GromNaN/drop-yaml
chore: Drop Yaml requirement, use PHP config for tests
2 parents 0bc7a1a + dd7d326 commit 4d51e4d

11 files changed

+276
-231
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
"symfony/dotenv": "^5.4 || ^6.0 || ^7.0",
5151
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
5252
"symfony/phpunit-bridge": "^5.4 || ^6.0 || ^7.0",
53-
"symfony/var-dumper": "^5.4 || ^6.0 || ^7.0",
54-
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
53+
"symfony/var-dumper": "^5.4 || ^6.0 || ^7.0"
5554
},
5655
"config": {
5756
"preferred-install": {

tests/Adapter/AdapterDefinitionFactoryTest.php

Lines changed: 92 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,112 @@
1414
use League\FlysystemBundle\Adapter\AdapterDefinitionFactory;
1515
use PHPUnit\Framework\TestCase;
1616
use Symfony\Component\DependencyInjection\Definition;
17-
use Symfony\Component\Yaml\Yaml;
1817

1918
class AdapterDefinitionFactoryTest extends TestCase
2019
{
2120
public static function provideConfigOptions(): \Generator
2221
{
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+
];
2430

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+
];
28113
}
29114

30115
/**
31116
* @dataProvider provideConfigOptions
32117
*/
33-
public function testCreateDefinition($name, $options): void
118+
public static function testCreateDefinition($name, $options): void
34119
{
35120
$factory = new AdapterDefinitionFactory();
36121

37122
$definition = $factory->createDefinition($name, $options);
38-
$this->assertInstanceOf(Definition::class, $definition);
123+
self::assertInstanceOf(Definition::class, $definition);
39124
}
40125
}

tests/Adapter/options.yaml

Lines changed: 0 additions & 71 deletions
This file was deleted.

tests/Kernel/FlysystemAppKernel.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,9 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
3939
}
4040
});
4141

42-
$loader->load(__DIR__.'/config/framework.yaml', 'yaml');
43-
$loader->load(__DIR__.'/config/flysystem.yaml', 'yaml');
44-
$loader->load(__DIR__.'/config/services.yaml', 'yaml');
45-
46-
if (self::VERSION_ID > 40300) {
47-
$loader->load(__DIR__.'/config/tagged_collection.yaml', 'yaml');
48-
}
42+
$loader->load(__DIR__.'/config/flysystem.php');
43+
$loader->load(__DIR__.'/config/framework.php');
44+
$loader->load(__DIR__.'/config/services.php');
4945
}
5046

5147
public function setAdapterClients(array $adapterClients): void

tests/Kernel/config/flysystem.php

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<?php
2+
3+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
4+
5+
return static function (ContainerConfigurator $container) {
6+
$container->extension('flysystem', [
7+
'storages' => [
8+
'fs_asyncaws' => [
9+
'adapter' => 'asyncaws',
10+
'options' => [
11+
'client' => 'asyncaws_client_service',
12+
'bucket' => '%env(AWS_BUCKET)%',
13+
'prefix' => 'optional/path/prefix',
14+
],
15+
],
16+
'fs_aws' => [
17+
'adapter' => 'aws',
18+
'options' => [
19+
'client' => 'aws_client_service',
20+
'bucket' => '%env(AWS_BUCKET)%',
21+
'prefix' => 'optional/path/prefix',
22+
],
23+
],
24+
'fs_azure' => [
25+
'adapter' => 'azure',
26+
'options' => [
27+
'client' => 'azure_client_service',
28+
'container' => 'container_name',
29+
'prefix' => 'optional/path/prefix',
30+
],
31+
],
32+
'fs_custom' => [
33+
'adapter' => 'custom_adapter',
34+
],
35+
'fs_ftp' => [
36+
'adapter' => 'ftp',
37+
'options' => [
38+
'host' => 'ftp.example.com',
39+
'username' => 'username',
40+
'password' => 'password',
41+
'port' => '%env(int:FTP_PORT)%',
42+
'root' => '/path/to/root',
43+
'passive' => true,
44+
'ssl' => true,
45+
'timeout' => 30,
46+
'utf8' => false,
47+
],
48+
],
49+
'fs_gcloud' => [
50+
'adapter' => 'gcloud',
51+
'options' => [
52+
'client' => 'gcloud_client_service',
53+
'bucket' => 'bucket_name',
54+
'prefix' => 'optional/path/prefix',
55+
],
56+
],
57+
'fs_lazy' => [
58+
'adapter' => 'lazy',
59+
'options' => [
60+
'source' => '%env(LAZY_SOURCE)%',
61+
],
62+
],
63+
'fs_local' => [
64+
'adapter' => 'local',
65+
'options' => [
66+
'directory' => '/tmp/storage',
67+
'lock' => 0,
68+
'skip_links' => false,
69+
'permissions' => [
70+
'file' => [
71+
'public' => 0744,
72+
'private' => 0700,
73+
],
74+
'dir' => [
75+
'public' => 0755,
76+
'private' => 0700,
77+
],
78+
],
79+
],
80+
],
81+
'fs_memory' => [
82+
'adapter' => 'memory',
83+
],
84+
'fs_sftp' => [
85+
'adapter' => 'sftp',
86+
'options' => [
87+
'host' => 'example.com',
88+
'port' => 22,
89+
'username' => 'username',
90+
'password' => 'password',
91+
'privateKey' => 'path/to/or/contents/of/privatekey',
92+
'root' => '/path/to/root',
93+
'timeout' => 10,
94+
],
95+
],
96+
'fs_public_url' => [
97+
'adapter' => 'local',
98+
'options' => [
99+
'directory' => '/tmp/storage',
100+
],
101+
'public_url' => 'https://example.org/assets/',
102+
],
103+
'fs_public_urls' => [
104+
'adapter' => 'local',
105+
'options' => [
106+
'directory' => '/tmp/storage',
107+
],
108+
'public_url' => [
109+
'https://cdn1.example.org/',
110+
'https://cdn2.example.org/',
111+
'https://cdn3.example.org/',
112+
],
113+
],
114+
'fs_url_generator' => [
115+
'adapter' => 'local',
116+
'options' => [
117+
'directory' => '/tmp/storage',
118+
],
119+
'public_url_generator' => 'flysystem.test.public_url_generator',
120+
'temporary_url_generator' => 'flysystem.test.temporary_url_generator',
121+
],
122+
'fs_read_only' => [
123+
'adapter' => 'local',
124+
'options' => [
125+
'directory' => '/tmp/storage',
126+
],
127+
'read_only' => true,
128+
],
129+
],
130+
]);
131+
};

0 commit comments

Comments
 (0)