Skip to content

Commit 73d11f8

Browse files
committed
Add adapter definition factory tests
1 parent 5f49be5 commit 73d11f8

4 files changed

Lines changed: 159 additions & 11 deletions

File tree

composer.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,22 @@
2626
"symfony/options-resolver": "^4.2"
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "^7.4",
30-
"league/flysystem-memory": "^1.0",
31-
"league/flysystem-cached-adapter": "^1.0",
32-
"symfony/var-dumper": "^4.1",
33-
"spatie/flysystem-dropbox": "^1.0",
34-
"superbalist/flysystem-google-storage": "^7.2",
3529
"jackalope/jackalope-doctrine-dbal": "^1.3",
36-
"league/flysystem-azure-blob-storage": "^0.1.5",
3730
"league/flysystem-aws-s3-v3": "^1.0",
31+
"league/flysystem-azure-blob-storage": "^0.1.5",
32+
"league/flysystem-cached-adapter": "^1.0",
33+
"league/flysystem-memory": "^1.0",
34+
"league/flysystem-phpcr": "^1.1",
3835
"league/flysystem-rackspace": "^1.0",
3936
"league/flysystem-replicate-adapter": "^1.0",
4037
"league/flysystem-sftp": "^1.0",
4138
"league/flysystem-webdav": "^1.0",
42-
"league/flysystem-phpcr": "^1.1",
43-
"league/flysystem-ziparchive": "^1.0"
39+
"league/flysystem-ziparchive": "^1.0",
40+
"phpunit/phpunit": "^7.4",
41+
"spatie/flysystem-dropbox": "^1.0",
42+
"superbalist/flysystem-google-storage": "^7.2",
43+
"symfony/var-dumper": "^4.1",
44+
"symfony/yaml": "^4.2"
4445
},
4546
"config": {
4647
"preferred-install": {

src/Adapter/AdapterDefinitionFactory.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace League\FlysystemBundle\Adapter;
1313

1414
use League\FlysystemBundle\Adapter\Builder\AdapterDefinitionBuilderInterface;
15-
use League\FlysystemBundle\Adapter\Builder\LocalAdapterDefinitionBuilder;
1615
use Symfony\Component\DependencyInjection\Definition;
1716

1817
/**
@@ -30,7 +29,15 @@ class AdapterDefinitionFactory
3029
public function __construct()
3130
{
3231
$this->builders = [
33-
new LocalAdapterDefinitionBuilder($this),
32+
new Builder\AwsAdapterDefinitionBuilder($this),
33+
new Builder\AzureAdapterDefinitionBuilder($this),
34+
new Builder\DropboxAdapterDefinitionBuilder($this),
35+
new Builder\GcloudAdapterDefinitionBuilder($this),
36+
new Builder\LocalAdapterDefinitionBuilder($this),
37+
new Builder\PhpcrAdapterDefinitionBuilder($this),
38+
new Builder\RackspaceAdapterDefinitionBuilder($this),
39+
new Builder\WebdavAdapterDefinitionBuilder($this),
40+
new Builder\ZipAdapterDefinitionBuilder($this),
3441
];
3542
}
3643

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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;
13+
14+
use League\FlysystemBundle\Adapter\AdapterDefinitionFactory;
15+
use PHPUnit\Framework\TestCase;
16+
use Symfony\Component\DependencyInjection\Definition;
17+
use Symfony\Component\Yaml\Yaml;
18+
19+
class AdapterDefinitionFactoryTest extends TestCase
20+
{
21+
public function provideConfigOptions()
22+
{
23+
$config = Yaml::parseFile(__DIR__.'/Fixtures/full_config.yaml');
24+
25+
foreach ($config as $fs) {
26+
yield $fs['adapter'] => [$fs['adapter'], $fs['options']];
27+
}
28+
}
29+
30+
/**
31+
* @dataProvider provideConfigOptions
32+
*/
33+
public function testCreateDefinition($name, $options)
34+
{
35+
$factory = new AdapterDefinitionFactory();
36+
37+
$definition = $factory->createDefinition($name, $options);
38+
$this->assertInstanceOf(Definition::class, $definition);
39+
}
40+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
fs_aws:
2+
adapter: 'aws'
3+
options:
4+
client: 'aws_client_service'
5+
bucket: 'bucket_name'
6+
prefix: 'optional/path/prefix'
7+
8+
fs_azure:
9+
adapter: 'azure'
10+
options:
11+
client: 'azure_client_service'
12+
container: 'container_name'
13+
prefix: 'optional/path/prefix'
14+
15+
fs_cached:
16+
adapter: 'cache'
17+
options:
18+
store: 'flysystem.cache.memory'
19+
source: 'fs_local'
20+
21+
fs_dropbox:
22+
adapter: 'dropbox'
23+
options:
24+
client: 'dropbox_client_service'
25+
prefix: 'optional/path/prefix'
26+
27+
fs_ftp:
28+
adapter: 'ftp'
29+
options:
30+
host: 'ftp.example.com'
31+
username: 'username'
32+
password: 'password'
33+
port: 21
34+
root: '/path/to/root'
35+
passive: true
36+
ssl: true
37+
timeout: 30
38+
39+
fs_gcloud:
40+
adapter: 'gcloud'
41+
options:
42+
client: 'gcloud_client_service'
43+
bucket: 'bucket_name'
44+
prefix: 'optional/path/prefix'
45+
api_url: 'https://storage.googleapis.com'
46+
47+
fs_local:
48+
adapter: 'local'
49+
options:
50+
directory: '%kernel.project_dir%/storage'
51+
lock: 0
52+
skip_links: false
53+
permissions:
54+
file:
55+
public: 0744
56+
private: 0700
57+
dir:
58+
public: 0755
59+
private: 0700
60+
61+
fs_phpcr:
62+
adapter: 'phpcr'
63+
options:
64+
session: 'phpcr_session_service'
65+
root: '/root'
66+
67+
fs_rackspace:
68+
adapter: 'rackspace'
69+
options:
70+
client: 'rackspace_container_service'
71+
prefix: 'optional/path/prefix'
72+
73+
fs_replicate:
74+
adapter: 'replicate'
75+
options:
76+
source: 'fs_aws'
77+
replica: 'fs_local'
78+
79+
fs_sftp:
80+
adapter: 'sftp'
81+
options:
82+
host: 'example.com'
83+
port: 22
84+
username: 'username'
85+
password: 'password'
86+
privateKey: 'path/to/or/contents/of/privatekey'
87+
root: '/path/to/root'
88+
timeout: 10
89+
90+
fs_webdav:
91+
adapter: 'webdav'
92+
options:
93+
client: 'webdav_client_service'
94+
prefix: 'optional/path/prefix'
95+
use_stream_copy: false
96+
97+
fs_zip:
98+
adapter: 'zip'
99+
options:
100+
path: '%kernel.project_dir%/archive.zip'

0 commit comments

Comments
 (0)