Skip to content

Commit 8274494

Browse files
committed
Drop Yaml requirement, use PHP config for tests
1 parent 0bc7a1a commit 8274494

File tree

9 files changed

+184
-153
lines changed

9 files changed

+184
-153
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/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+
};

tests/Kernel/config/flysystem.yaml

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

tests/Kernel/config/framework.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
4+
5+
return static function (ContainerConfigurator $container) {
6+
$container->extension('framework', [
7+
'secret' => 'test_secret',
8+
'test' => true,
9+
'http_method_override' => false,
10+
]);
11+
};

tests/Kernel/config/framework.yaml

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

tests/Kernel/config/services.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
use League\Flysystem\InMemory\InMemoryFilesystemAdapter;
4+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
5+
use Tests\League\FlysystemBundle\PublicUrlGeneratorMock;
6+
use Tests\League\FlysystemBundle\TemporaryUrlGeneratorMock;
7+
8+
use function Symfony\Component\DependencyInjection\Loader\Configurator\tagged_iterator;
9+
10+
return static function (ContainerConfigurator $container) {
11+
$services = $container->services()
12+
->defaults()->public();
13+
14+
$services->set('custom_adapter', InMemoryFilesystemAdapter::class);
15+
16+
$services->set('flysystem.test.public_url_generator', PublicUrlGeneratorMock::class);
17+
$services->set('flysystem.test.temporary_url_generator', TemporaryUrlGeneratorMock::class);
18+
19+
$services->set('storages_tagged_collection', 'stdClass')
20+
->public()
21+
->property('locator', tagged_iterator('flysystem.storage', 'storage'));
22+
23+
// Aliases used to test the services construction
24+
$services->alias('flysystem.test.fs_asyncaws', 'fs_asyncaws');
25+
$services->alias('flysystem.test.fs_aws', 'fs_aws');
26+
$services->alias('flysystem.test.fs_azure', 'fs_azure');
27+
$services->alias('flysystem.test.fs_custom', 'fs_custom');
28+
$services->alias('flysystem.test.fs_ftp', 'fs_ftp');
29+
$services->alias('flysystem.test.fs_gcloud', 'fs_gcloud');
30+
$services->alias('flysystem.test.fs_lazy', 'fs_lazy');
31+
$services->alias('flysystem.test.fs_local', 'fs_local');
32+
$services->alias('flysystem.test.fs_memory', 'fs_memory');
33+
$services->alias('flysystem.test.fs_sftp', 'fs_sftp');
34+
$services->alias('flysystem.test.fs_public_url', 'fs_public_url');
35+
$services->alias('flysystem.test.fs_public_urls', 'fs_public_urls');
36+
$services->alias('flysystem.test.fs_url_generator', 'fs_url_generator');
37+
$services->alias('flysystem.test.fs_read_only', 'fs_read_only');
38+
};

tests/Kernel/config/services.yaml

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

tests/Kernel/config/tagged_collection.yaml

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

0 commit comments

Comments
 (0)