Skip to content

Commit 3b2ed5c

Browse files
authored
Allow for DropboxV2 (#47)
* Allow for DropboxV2 * Fixed broken tests * Make exception for lower versions of PHPUnit
1 parent 61e9fa0 commit 3b2ed5c

File tree

7 files changed

+44
-48
lines changed

7 files changed

+44
-48
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ install:
6666

6767
script:
6868
- composer validate --strict --no-check-lock
69-
# - $TEST_COMMAND
69+
- $TEST_COMMAND

Changelog.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 2.1.3
4+
5+
### Fixed
6+
7+
- Fixed bug that made DropboxV2 config unavailable.
8+
39
## 2.1.2
410

511
### Fixed

DependencyInjection/BMBackupManagerExtension.php

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use League\Flysystem\Adapter\Local;
77
use League\Flysystem\AwsS3v3\AwsS3Adapter;
88
use League\Flysystem\Dropbox\DropboxAdapter;
9-
use Nyholm\DSN;
109
use Srmklive\Dropbox\Adapter\DropboxAdapter as Dropbox2Adapter;
1110
use League\Flysystem\Rackspace\RackspaceAdapter;
1211
use League\Flysystem\Sftp\SftpAdapter;

DependencyInjection/Configuration.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ public function getConfigTreeBuilder()
2525
if (!isset($config['type'])) {
2626
throw new InvalidConfigurationException(sprintf('You must define a "type" for storage "%s"', $name));
2727
}
28-
$validTypes = ['Local', 'AwsS3', 'Rackspace', 'Dropbox', 'Ftp', 'Sftp'];
29-
if (!in_array($config['type'], $validTypes)) {
30-
throw new InvalidConfigurationException(sprintf('Type must be one of "%s", got "%s"', implode(', ', $validTypes), $config['type']));
31-
}
3228

3329
switch ($config['type']) {
3430
case 'Local':
@@ -43,12 +39,18 @@ public function getConfigTreeBuilder()
4339
case 'Dropbox':
4440
$this->validateAuthenticationType(['token', 'key', 'secret', 'app', 'root'], $config, 'Dropbox');
4541
break;
42+
case 'DropboxV2':
43+
$this->validateAuthenticationType(['token', 'root'], $config, 'DropboxV2');
44+
break;
4645
case 'Ftp':
4746
$this->validateAuthenticationType(['host', 'username', 'password', 'root', 'port', 'passive', 'ssl', 'timeout'], $config, 'Ftp');
4847
break;
4948
case 'Sftp':
5049
$this->validateAuthenticationType(['host', 'username', 'password', 'root', 'port', 'timeout', 'privateKey'], $config, 'Sftp');
5150
break;
51+
default:
52+
$validTypes = ['Local', 'AwsS3', 'Rackspace', 'Dropbox', 'DropboxV2', 'Ftp', 'Sftp'];
53+
throw new InvalidConfigurationException(sprintf('Type must be one of "%s", got "%s"', implode(', ', $validTypes), $config['type']));
5254
}
5355
}
5456

Tests/Functional/BundleInitializationTest.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ public function testNoConfig()
5757

5858
public function testNoDependencies()
5959
{
60-
$this->expectException(\LogicException::class);
60+
if (method_exists($this, 'expectException')) {
61+
$this->expectException(\LogicException::class);
62+
} else {
63+
// Legacy
64+
$this->setExpectedException(\LogicException::class);
65+
}
6166

6267
// Create a new Kernel
6368
$kernel = $this->createKernel();

Tests/Unit/DependencyInjection/BMBackupManagerExtensionTest.php

-32
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,6 @@ public function testReplacementOfConfig()
3333
$this->assertContainerBuilderHasServiceDefinitionWithArgument('backup_manager.config_database', 0, $dbConfig);
3434
}
3535

36-
public function testDsn()
37-
{
38-
$storageConfig = ['local'=>['type'=>'Local', 'root'=>'/foo']];
39-
$dbConfig = ['dev'=>[
40-
'type'=>'mysql',
41-
'host'=>'host.com',
42-
'port'=>'3306',
43-
'user'=>'user',
44-
'pass'=>'pass',
45-
'database'=>'db',
46-
// The DSN should override them all.
47-
'dsn'=>'pgsql://root:[email protected]:5432/test_db',
48-
]];
49-
50-
$this->load([
51-
'storage' => $storageConfig,
52-
'database' => $dbConfig,
53-
]);
54-
55-
$parsedConfig = ['dev'=>[
56-
'type'=>'pgsql',
57-
'host'=>'127.0.0.1',
58-
'port'=>'5432',
59-
'user'=>'root',
60-
'pass'=>'root_pass',
61-
'database'=>'test_db',
62-
]];
63-
64-
$this->assertContainerBuilderHasServiceDefinitionWithArgument('backup_manager.config_storage', 0, $storageConfig);
65-
$this->assertContainerBuilderHasServiceDefinitionWithArgument('backup_manager.config_database', 0, $parsedConfig);
66-
}
67-
6836
/**
6937
* Make sure we can have multiple storage names with the same type
7038
*/

Tests/Unit/DependencyInjection/ConfigurationTest.php

+25-9
Original file line numberDiff line numberDiff line change
@@ -135,32 +135,48 @@ public function testSingleTransactionOnValid()
135135
);
136136
}
137137

138-
public function testDsn()
138+
public function testNoType()
139139
{
140140
$this->assertConfigurationIsInvalid(array(
141141
[
142142
'database'=>[
143143
'dev'=>[
144-
'dsn' => 'pgsql://root:[email protected]:5432/test_db',
145-
'singleTransaction' => true,
144+
146145
],
147146
],
148147
]
149-
)
148+
),
149+
'You must define a "type" or "dsn" for database "dev"'
150150
);
151151
}
152-
public function testNoType()
152+
153+
/**
154+
*
155+
* @dataProvider validStorageTypes
156+
*/
157+
public function testStorageTypes($type)
153158
{
154-
$this->assertConfigurationIsInvalid(array(
159+
$this->assertConfigurationIsValid(array(
155160
[
156161
'database'=>[
157162
'dev'=>[
158-
163+
'type' => 'mysql'
159164
],
160165
],
166+
'storage' => [
167+
'foo' => [
168+
'type' => $type,
169+
]
170+
]
161171
]
162-
),
163-
'You must define a "type" or "dsn" for database "dev"'
172+
)
164173
);
165174
}
175+
176+
public function validStorageTypes()
177+
{
178+
return [
179+
['Local'],['AwsS3'], ['Rackspace'], ['Dropbox'], ['DropboxV2'], ['Ftp'], ['Sftp'],
180+
];
181+
}
166182
}

0 commit comments

Comments
 (0)