Code Duplication    Length = 30-34 lines in 3 locations

tests/integration/Modify/Contract/MergeFilesTest.php 3 locations

@@ 159-188 (lines=30) @@
156
        $this->merge->contract($collection, $target);
157
    }
158
159
    public function testSimpleMergeFiles()
160
    {
161
        $collection = $this->createCollection('simple.merge/', 3);
162
163
        $outputFile = new LocalFile(static::$dir . 'simple.merge.output');
164
165
        $file = $this->merge->contract($collection, $outputFile);
166
167
        static::assertSame($file, $outputFile);
168
        static::assertEquals(
169
            [
170
                "File 1 Line 1",
171
                "File 1 Line 2",
172
                "File 1 Line 3",
173
                "File 2 Line 1",
174
                "File 2 Line 2",
175
                "File 2 Line 3",
176
                "File 3 Line 1",
177
                "File 3 Line 2",
178
                "File 3 Line 3",
179
            ],
180
            $file->getContents()
181
        );
182
183
        $exists = $collection->filter(function (FileNodeInterface $item) {
184
            return $item->exists();
185
        });
186
187
        static::assertCount(3, $exists);
188
    }
189
190
    /**
191
     * @param string $rootDir
@@ 209-238 (lines=30) @@
206
        return $collection;
207
    }
208
209
    public function testCallingMergeWithKeepOldFilesAsFalseDeletesAllTheFilesInTheCollection()
210
    {
211
        $collection = $this->createCollection('simple.merge.delete/', 3);
212
213
        $outputFile = new LocalFile(static::$dir . 'simple.merge.delete.output');
214
215
        $file = $this->merge->contract($collection, $outputFile, ['keepOldFiles' => false]);
216
217
        static::assertSame($file, $outputFile);
218
        static::assertEquals(
219
            [
220
                "File 1 Line 1",
221
                "File 1 Line 2",
222
                "File 1 Line 3",
223
                "File 2 Line 1",
224
                "File 2 Line 2",
225
                "File 2 Line 3",
226
                "File 3 Line 1",
227
                "File 3 Line 2",
228
                "File 3 Line 3",
229
            ],
230
            $file->getContents()
231
        );
232
233
        $exists = $collection->filter(function (FileNodeInterface $item) {
234
            return $item->exists();
235
        });
236
237
        static::assertCount(0, $exists);
238
    }
239
240
    public function testProcessFailedThrowException()
241
    {
@@ 258-291 (lines=34) @@
255
        $this->merge->contract($collection, $outputFile);
256
    }
257
258
    public function testCallingContractWillPassThroughOptions()
259
    {
260
        $collection = $this->createCollection('simple.contract.pass.through/', 3);
261
        $outputFile = new LocalFile(static::$dir . 'simple.contract.pass.through.output');
262
263
        $file = $this->merge->contract(
264
            $collection,
265
            $outputFile,
266
            [
267
                'keepOldFiles' => true,
268
            ]
269
        );
270
271
        static::assertEquals(
272
            [
273
                "File 1 Line 1",
274
                "File 1 Line 2",
275
                "File 1 Line 3",
276
                "File 2 Line 1",
277
                "File 2 Line 2",
278
                "File 2 Line 3",
279
                "File 3 Line 1",
280
                "File 3 Line 2",
281
                "File 3 Line 3",
282
            ],
283
            $file->getContents()
284
        );
285
286
        $exists = $collection->filter(function (FileNodeInterface $item) {
287
            return $item->exists();
288
        });
289
290
        static::assertCount(3, $exists);
291
    }
292
293
    public function testDeleteOldFilesWillDeleteAnyEmptyDirectories()
294
    {