Skip to content

Commit dd7d326

Browse files
committed
Move test options from Yaml file to PHP
1 parent 8274494 commit dd7d326

File tree

2 files changed

+92
-78
lines changed

2 files changed

+92
-78
lines changed

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.

0 commit comments

Comments
 (0)