@@ -96,7 +96,69 @@ public function createDataProvider()
96
96
* @param array $config
97
97
* @param array $currentConfig
98
98
* @param string $updatedConfig
99
- * @dataProvider readDataProvider
99
+ * @dataProvider getUpdateRecursiveDataProvider
100
+ */
101
+ public function testUpdateRecursive (array $ config , array $ currentConfig , $ updatedConfig )
102
+ {
103
+ $ filePath = '/path/to/file ' ;
104
+ $ this ->fileListMock ->expects ($ this ->once ())
105
+ ->method ('getEnv ' )
106
+ ->willReturn ($ filePath );
107
+ $ this ->readerMock ->expects ($ this ->once ())
108
+ ->method ('read ' )
109
+ ->willReturn ($ currentConfig );
110
+ $ this ->fileMock ->expects ($ this ->once ())
111
+ ->method ('filePutContents ' )
112
+ ->with ($ filePath , $ updatedConfig );
113
+
114
+ $ this ->writer ->updateRecursive ($ config );
115
+ }
116
+
117
+ /**
118
+ * @return array
119
+ */
120
+ public function getUpdateRecursiveDataProvider ()
121
+ {
122
+ return [
123
+ [
124
+ [],
125
+ [],
126
+ "<?php \nreturn array ( \n); " ,
127
+ ],
128
+ [
129
+ ['key ' => 'value ' ],
130
+ ['key1 ' => 'value1 ' ],
131
+ "<?php \nreturn array ( \n 'key1' => 'value1', \n 'key' => 'value', \n); " ,
132
+ ],
133
+ [
134
+ ['key1 ' => 'value1 ' , 'key2 ' => 'value2 ' ],
135
+ ['key1 ' => 'value0 ' , 'key3 ' => 'value3 ' ],
136
+ "<?php \nreturn array ( \n 'key1' => 'value1', \n 'key3' => 'value3', \n 'key2' => 'value2', \n); " ,
137
+ ],
138
+ [
139
+ [
140
+ 'key1 ' => [
141
+ 'key12 ' => 'value2new ' ,
142
+ 'key13 ' => 'value3new ' ,
143
+ ]
144
+ ],
145
+ [
146
+ 'key1 ' => [
147
+ 'key11 ' => 'value1 ' ,
148
+ 'key12 ' => 'value2 ' ,
149
+ ]
150
+ ],
151
+ "<?php \nreturn array ( \n 'key1' => \n array ( \n 'key11' => 'value1', \n" .
152
+ " 'key12' => 'value2new', \n 'key13' => 'value3new', \n ), \n); "
153
+ ],
154
+ ];
155
+ }
156
+
157
+ /**
158
+ * @param array $config
159
+ * @param array $currentConfig
160
+ * @param string $updatedConfig
161
+ * @dataProvider getUpdateDataProvider
100
162
*/
101
163
public function testUpdate (array $ config , array $ currentConfig , $ updatedConfig )
102
164
{
@@ -117,7 +179,7 @@ public function testUpdate(array $config, array $currentConfig, $updatedConfig)
117
179
/**
118
180
* @return array
119
181
*/
120
- public function readDataProvider ()
182
+ public function getUpdateDataProvider ()
121
183
{
122
184
return [
123
185
[
@@ -135,6 +197,22 @@ public function readDataProvider()
135
197
['key1 ' => 'value0 ' , 'key3 ' => 'value3 ' ],
136
198
"<?php \nreturn array ( \n 'key1' => 'value1', \n 'key3' => 'value3', \n 'key2' => 'value2', \n); " ,
137
199
],
200
+ [
201
+ [
202
+ 'key1 ' => [
203
+ 'key12 ' => 'value2new ' ,
204
+ 'key13 ' => 'value3new ' ,
205
+ ]
206
+ ],
207
+ [
208
+ 'key1 ' => [
209
+ 'key11 ' => 'value1 ' ,
210
+ 'key12 ' => 'value2 ' ,
211
+ ]
212
+ ],
213
+ "<?php \nreturn array ( \n 'key1' => \n array ( \n" .
214
+ " 'key12' => 'value2new', \n 'key13' => 'value3new', \n ), \n); "
215
+ ]
138
216
];
139
217
}
140
218
}
0 commit comments