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