File tree Expand file tree Collapse file tree 3 files changed +30
-19
lines changed
Tests/DependencyInjection Expand file tree Collapse file tree 3 files changed +30
-19
lines changed Original file line number Diff line number Diff line change @@ -144,14 +144,28 @@ public function getConfigTreeBuilder()
144144 return true ;
145145 }
146146
147- foreach ($ config as $ entry ) {
148- if (!is_array ($ entry ) || empty ($ entry )) {
149- return true ;
150- }
147+ if (!$ this ->validateArrayProviderEntry ($ config )) {
148+ return true ;
149+ }
150+
151+ return false ;
152+ })
153+ ->thenInvalid ('Invalid configuration for array provider. ' )
154+ ->end ()
155+ ->end ()
156+ ->variableNode ('historicalRates ' )
157+ ->treatFalseLike (null )
158+ ->treatTrueLike (null )
159+ ->isRequired ()
160+ ->cannotBeEmpty ()
161+ ->validate ()
162+ ->ifTrue (function ($ config ) {
163+ if (!is_array ($ config ) || empty ($ config )) {
164+ return true ;
165+ }
151166
152- if (!$ this ->validateArrayProviderEntry ($ entry )) {
153- return true ;
154- }
167+ if (!$ this ->validateArrayProviderEntry ($ config )) {
168+ return true ;
155169 }
156170
157171 return false ;
Original file line number Diff line number Diff line change @@ -66,10 +66,9 @@ florianv_swap:
6666 token : secret
6767 array :
6868 rates :
69- -
7069 ' EUR/GBP ' : 1.5
7170 ' EUR/USD ' : 1.1
72- -
71+ historicalRates :
7372 ' 2017-01-01 ' :
7473 ' EUR/GBP ' : 1.5
7574 ' EUR/USD ' : 1.1
Original file line number Diff line number Diff line change @@ -127,17 +127,15 @@ public function provideValidProvidersConfigs()
127127 [[
128128 'array ' => [
129129 'rates ' => [
130- [
131- 'EUR/USD ' => 1.1 ,
132- 'EUR/GBP ' => 1.5 ,
130+ 'EUR/USD ' => 1.1 ,
131+ 'EUR/GBP ' => 1.5 ,
132+ ],
133+ 'historicalRates ' => [
134+ '2017-01-01 ' => [
135+ 'EUR/USD ' => 1.5 ,
133136 ],
134- [
135- '2017-01-01 ' => [
136- 'EUR/USD ' => 1.5 ,
137- ],
138- '2017-01-03 ' => [
139- 'EUR/GBP ' => 1.3 ,
140- ],
137+ '2017-01-03 ' => [
138+ 'EUR/GBP ' => 1.3 ,
141139 ],
142140 ],
143141 ],
You can’t perform that action at this time.
0 commit comments