@@ 152-181 (lines=30) @@ | ||
149 | $this->merge->contract($collection, $target); |
|
150 | } |
|
151 | ||
152 | public function testSimpleMergeFiles() |
|
153 | { |
|
154 | $collection = $this->createCollection('simple.merge/', 3); |
|
155 | ||
156 | $outputFile = new LocalFile(static::$dir . 'simple.merge.output'); |
|
157 | ||
158 | $file = $this->merge->contract($collection, $outputFile); |
|
159 | ||
160 | static::assertSame($file, $outputFile); |
|
161 | static::assertEquals( |
|
162 | [ |
|
163 | "File 1 Line 1", |
|
164 | "File 1 Line 2", |
|
165 | "File 1 Line 3", |
|
166 | "File 2 Line 1", |
|
167 | "File 2 Line 2", |
|
168 | "File 2 Line 3", |
|
169 | "File 3 Line 1", |
|
170 | "File 3 Line 2", |
|
171 | "File 3 Line 3", |
|
172 | ], |
|
173 | $file->getContents() |
|
174 | ); |
|
175 | ||
176 | $exists = $collection->filter(function (FileNodeInterface $item) { |
|
177 | return $item->exists(); |
|
178 | }); |
|
179 | ||
180 | static::assertCount(3, $exists); |
|
181 | } |
|
182 | ||
183 | /** |
|
184 | * @param string $rootDir |
|
@@ 202-231 (lines=30) @@ | ||
199 | return $collection; |
|
200 | } |
|
201 | ||
202 | public function testCallingMergeWithKeepOldFilesAsFalseDeletesAllTheFilesInTheCollection() |
|
203 | { |
|
204 | $collection = $this->createCollection('simple.merge.delete/', 3); |
|
205 | ||
206 | $outputFile = new LocalFile(static::$dir . 'simple.merge.delete.output'); |
|
207 | ||
208 | $file = $this->merge->contract($collection, $outputFile, ['keepOldFiles' => false]); |
|
209 | ||
210 | static::assertSame($file, $outputFile); |
|
211 | static::assertEquals( |
|
212 | [ |
|
213 | "File 1 Line 1", |
|
214 | "File 1 Line 2", |
|
215 | "File 1 Line 3", |
|
216 | "File 2 Line 1", |
|
217 | "File 2 Line 2", |
|
218 | "File 2 Line 3", |
|
219 | "File 3 Line 1", |
|
220 | "File 3 Line 2", |
|
221 | "File 3 Line 3", |
|
222 | ], |
|
223 | $file->getContents() |
|
224 | ); |
|
225 | ||
226 | $exists = $collection->filter(function (FileNodeInterface $item) { |
|
227 | return $item->exists(); |
|
228 | }); |
|
229 | ||
230 | static::assertCount(0, $exists); |
|
231 | } |
|
232 | ||
233 | public function testProcessFailedThrowException() |
|
234 | { |
|
@@ 251-284 (lines=34) @@ | ||
248 | $this->merge->contract($collection, $outputFile); |
|
249 | } |
|
250 | ||
251 | public function testCallingContractWillPassThroughOptions() |
|
252 | { |
|
253 | $collection = $this->createCollection('simple.contract.pass.through/', 3); |
|
254 | $outputFile = new LocalFile(static::$dir . 'simple.contract.pass.through.output'); |
|
255 | ||
256 | $file = $this->merge->contract( |
|
257 | $collection, |
|
258 | $outputFile, |
|
259 | [ |
|
260 | 'keepOldFiles' => true, |
|
261 | ] |
|
262 | ); |
|
263 | ||
264 | static::assertEquals( |
|
265 | [ |
|
266 | "File 1 Line 1", |
|
267 | "File 1 Line 2", |
|
268 | "File 1 Line 3", |
|
269 | "File 2 Line 1", |
|
270 | "File 2 Line 2", |
|
271 | "File 2 Line 3", |
|
272 | "File 3 Line 1", |
|
273 | "File 3 Line 2", |
|
274 | "File 3 Line 3", |
|
275 | ], |
|
276 | $file->getContents() |
|
277 | ); |
|
278 | ||
279 | $exists = $collection->filter(function (FileNodeInterface $item) { |
|
280 | return $item->exists(); |
|
281 | }); |
|
282 | ||
283 | static::assertCount(3, $exists); |
|
284 | } |
|
285 | ||
286 | public function testDeleteOldFilesWillDeleteAnyEmptyDirectories() |
|
287 | { |