@@ 172-201 (lines=30) @@ | ||
169 | $this->merge->contract($collection, $target); |
|
170 | } |
|
171 | ||
172 | public function testSimpleMergeFiles() |
|
173 | { |
|
174 | $collection = $this->createCollection('simple.merge/', 3); |
|
175 | ||
176 | $outputFile = new LocalFile(static::$dir . 'simple.merge.output'); |
|
177 | ||
178 | $file = $this->merge->contract($collection, $outputFile); |
|
179 | ||
180 | static::assertSame($file, $outputFile); |
|
181 | static::assertEquals( |
|
182 | [ |
|
183 | "File 1 Line 1", |
|
184 | "File 1 Line 2", |
|
185 | "File 1 Line 3", |
|
186 | "File 2 Line 1", |
|
187 | "File 2 Line 2", |
|
188 | "File 2 Line 3", |
|
189 | "File 3 Line 1", |
|
190 | "File 3 Line 2", |
|
191 | "File 3 Line 3", |
|
192 | ], |
|
193 | $file->getContents() |
|
194 | ); |
|
195 | ||
196 | $exists = $collection->filter(function (FileNodeInterface $item) { |
|
197 | return $item->exists(); |
|
198 | }); |
|
199 | ||
200 | static::assertCount(3, $exists); |
|
201 | } |
|
202 | ||
203 | /** |
|
204 | * @param string $rootDir |
|
@@ 222-251 (lines=30) @@ | ||
219 | return $collection; |
|
220 | } |
|
221 | ||
222 | public function testCallingMergeWithKeepOldFilesAsFalseDeletesAllTheFilesInTheCollection() |
|
223 | { |
|
224 | $collection = $this->createCollection('simple.merge.delete/', 3); |
|
225 | ||
226 | $outputFile = new LocalFile(static::$dir . 'simple.merge.delete.output'); |
|
227 | ||
228 | $file = $this->merge->contract($collection, $outputFile, ['keepOldFiles' => false]); |
|
229 | ||
230 | static::assertSame($file, $outputFile); |
|
231 | static::assertEquals( |
|
232 | [ |
|
233 | "File 1 Line 1", |
|
234 | "File 1 Line 2", |
|
235 | "File 1 Line 3", |
|
236 | "File 2 Line 1", |
|
237 | "File 2 Line 2", |
|
238 | "File 2 Line 3", |
|
239 | "File 3 Line 1", |
|
240 | "File 3 Line 2", |
|
241 | "File 3 Line 3", |
|
242 | ], |
|
243 | $file->getContents() |
|
244 | ); |
|
245 | ||
246 | $exists = $collection->filter(function (FileNodeInterface $item) { |
|
247 | return $item->exists(); |
|
248 | }); |
|
249 | ||
250 | static::assertCount(0, $exists); |
|
251 | } |
|
252 | ||
253 | public function testProcessFailedThrowException() |
|
254 | { |
|
@@ 271-304 (lines=34) @@ | ||
268 | $this->merge->contract($collection, $outputFile); |
|
269 | } |
|
270 | ||
271 | public function testCallingContractWillPassThroughOptions() |
|
272 | { |
|
273 | $collection = $this->createCollection('simple.contract.pass.through/', 3); |
|
274 | $outputFile = new LocalFile(static::$dir . 'simple.contract.pass.through.output'); |
|
275 | ||
276 | $file = $this->merge->contract( |
|
277 | $collection, |
|
278 | $outputFile, |
|
279 | [ |
|
280 | 'keepOldFiles' => true, |
|
281 | ] |
|
282 | ); |
|
283 | ||
284 | static::assertEquals( |
|
285 | [ |
|
286 | "File 1 Line 1", |
|
287 | "File 1 Line 2", |
|
288 | "File 1 Line 3", |
|
289 | "File 2 Line 1", |
|
290 | "File 2 Line 2", |
|
291 | "File 2 Line 3", |
|
292 | "File 3 Line 1", |
|
293 | "File 3 Line 2", |
|
294 | "File 3 Line 3", |
|
295 | ], |
|
296 | $file->getContents() |
|
297 | ); |
|
298 | ||
299 | $exists = $collection->filter(function (FileNodeInterface $item) { |
|
300 | return $item->exists(); |
|
301 | }); |
|
302 | ||
303 | static::assertCount(3, $exists); |
|
304 | } |
|
305 | ||
306 | public function testDeleteOldFilesWillDeleteAnyEmptyDirectories() |
|
307 | { |