Skip to content

Commit 49a1386

Browse files
committed
Update to Swap 3.4
1 parent df315dd commit 49a1386

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

DependencyInjection/Configuration.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,17 @@ public function getConfigTreeBuilder()
5454
->end()
5555
->arrayNode('providers')
5656
->children()
57-
->append($this->createSimpleProviderNode('fixer'))
57+
->arrayNode('fixer')
58+
->children()
59+
->integerNode('priority')->defaultValue(0)->end()
60+
->scalarNode('access_key')
61+
->treatFalseLike(null)
62+
->treatTrueLike(null)
63+
->isRequired()
64+
->cannotBeEmpty()
65+
->end()
66+
->end()
67+
->end()
5868
->append($this->createSimpleProviderNode('google'))
5969
->append($this->createSimpleProviderNode('cryptonator'))
6070
->append($this->createSimpleProviderNode('webservicex'))

Resources/doc/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public function registerBundles()
2828
florianv_swap:
2929
providers:
3030
google: ~ # Google Finance
31-
fixer: ~ # Fixer
31+
fixer:
32+
access_key: secret # Fixer
3233
webservicex: ~ # WebserviceX
3334
cryptonator: ~ # Cryptonator
3435
russian_central_bank: ~ # Russian Central Bank
@@ -67,6 +68,7 @@ florianv_swap:
6768
google: ~
6869
#priority: 0 (default)
6970
fixer:
71+
access_key: secret
7072
priority: 1
7173
```
7274

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function testValidCacheConfig(array $cache)
8383
{
8484
$this->processor->processConfiguration($this->configuration, [
8585
'florianv_swap' => [
86-
'providers' => ['fixer' => null],
86+
'providers' => ['fixer' => ['access_key' => 'YOUR_KEY']],
8787
'cache' => $cache,
8888
],
8989
]);
@@ -100,7 +100,7 @@ public function testInvalidCacheConfig(array $cache)
100100

101101
$this->processor->processConfiguration($this->configuration, [
102102
'florianv_swap' => [
103-
'providers' => ['fixer' => null],
103+
'providers' => ['fixer' => ['access_key' => 'YOUR_KEY']],
104104
'cache' => $cache,
105105
],
106106
]);
@@ -112,7 +112,7 @@ public function provideValidProvidersConfigs()
112112
[['central_bank_of_czech_republic' => null]],
113113
[['central_bank_of_republic_turkey' => []]],
114114
[['european_central_bank' => null]],
115-
[['fixer' => null]],
115+
[['fixer' => ['access_key' => 'YOUR_KEY']]],
116116
[['google' => null]],
117117
[['national_bank_of_romania' => null]],
118118
[['webservicex' => null]],

Tests/DependencyInjection/FlorianvSwapExtensionTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testNoProvider()
6767

6868
public function testFixerProvider()
6969
{
70-
$this->buildContainer(['fixer' => null]);
70+
$this->buildContainer(['fixer' => ['access_key' => 'test']]);
7171
}
7272

7373
public function testForgeProvider()
@@ -78,7 +78,7 @@ public function testForgeProvider()
7878
public function testProviderPriorities()
7979
{
8080
$this->buildContainer([
81-
'fixer' => null,
81+
'fixer' => ['access_key' => 'YOUR_KEY'],
8282
'google' => [
8383
'priority' => 3,
8484
],
@@ -104,19 +104,19 @@ public function testProviderPriorities()
104104
// Fixer third
105105
$this->assertEquals($calls[2][0], 'add');
106106
$this->assertEquals($calls[2][1][0], 'fixer');
107-
$this->assertEquals($calls[2][1][1], []);
107+
$this->assertEquals($calls[2][1][1], ['access_key' => 'YOUR_KEY']);
108108
}
109109

110110
public function testCacheMissTtl()
111111
{
112112
$this->expectException(InvalidConfigurationException::class);
113113

114-
$this->buildContainer(['fixer' => null], ['ttl' => null]);
114+
$this->buildContainer(['fixer' => ['access_key' => 'YOUR_KEY']], ['ttl' => null]);
115115
}
116116

117117
public function testArrayCache()
118118
{
119-
$this->buildContainer(['fixer' => null], ['type' => 'array', 'ttl' => 60]);
119+
$this->buildContainer(['fixer' => ['access_key' => 'YOUR_KEY']], ['type' => 'array', 'ttl' => 60]);
120120

121121
$this->assertCache(Adapter\ArrayAdapter::class, [60]);
122122
}
@@ -127,14 +127,14 @@ public function testApcuCache()
127127
$this->markTestSkipped('APCU is not enabled');
128128
}
129129

130-
$this->buildContainer(['fixer' => null], ['type' => 'apcu']);
130+
$this->buildContainer(['fixer' => ['access_key' => 'YOUR_KEY']], ['type' => 'apcu']);
131131

132132
$this->assertCache(Adapter\ApcuAdapter::class, ['swap', 3600]);
133133
}
134134

135135
public function testFilesystemCache()
136136
{
137-
$this->buildContainer(['fixer' => null], ['type' => 'filesystem']);
137+
$this->buildContainer(['fixer' => ['access_key' => 'YOUR_KEY']], ['type' => 'filesystem']);
138138

139139
$this->assertCache(Adapter\FilesystemAdapter::class, ['swap', 3600]);
140140
}
@@ -145,7 +145,7 @@ public function testFilesystemCache()
145145
* @param array $providers
146146
* @param array $cache
147147
*/
148-
private function buildContainer(array $providers = ['fixer' => null], array $cache = [])
148+
private function buildContainer(array $providers = ['fixer' => ['access_key' => 'test']], array $cache = [])
149149
{
150150
$this->extension->load([
151151
'florianv_swap' => [

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"require": {
1616
"php": "^5.6|^7.0",
1717
"symfony/framework-bundle": "~3.0",
18-
"florianv/swap": "~3.0"
18+
"florianv/swap": "^3.4"
1919
},
2020
"require-dev": {
2121
"php-http/guzzle6-adapter": "^1.0",

0 commit comments

Comments
 (0)