Code Duplication    Length = 45-45 lines in 2 locations

tests/unit/Modify/ReFormatTest.php 2 locations

@@ 138-182 (lines=45) @@
135
        static::assertSame($target, $this->reFormatter->reFormat($file, $format));
136
    }
137
138
    public function testCanReFormatALocalInputFile()
139
    {
140
        $file = m::mock(LocalFileNodeInterface::class, FormatAwareInterface::class);
141
        $target = m::mock(LocalFileNodeInterface::class, FormatAwareInterface::class);
142
143
        $file->shouldReceive('getPath')
144
             ->andReturn('/tmp/file.txt');
145
        $file->shouldReceive('exists')
146
             ->andReturn(true);
147
148
        $file->shouldReceive('getClone')
149
             ->andReturn($target);
150
        $target->shouldReceive('setPath')
151
               ->with('/tmp/file-format.txt')
152
               ->andReturn($target);
153
154
        $format = m::mock(FormatInterface::class);
155
156
        $target->shouldReceive('setFormat')
157
               ->with($format)
158
               ->andReturn($target);
159
160
        $reader = m::mock(FileReader::class);
161
        $this->builder->shouldReceive('build')
162
                      ->with(FileReader::class, $file, null, $this->parserFactory)
163
                      ->andReturn($reader);
164
        $writer = m::mock(FileWriter::class);
165
        $this->builder->shouldReceive('build')
166
                      ->with(FileWriter::Class, $target, $format, $this->formatterFactory)
167
                      ->andReturn($writer);
168
169
        $iterator = new ArrayIterator(['first', 'second']);
170
171
        $reader->shouldReceive('fetch')
172
               ->andReturn($iterator);
173
174
        $writer->shouldReceive('insertOne')
175
               ->with('first')
176
               ->once();
177
        $writer->shouldReceive('insertOne')
178
               ->with('second')
179
               ->once();
180
181
        static::assertSame($target, $this->reFormatter->reFormat($file, $format));
182
    }
183
184
    public function testCanReformatWithIntputAndOutputFiles()
185
    {
@@ 291-335 (lines=45) @@
288
        static::assertSame($target, $this->reFormatter->modify($file, ['output' => $target]));
289
    }
290
291
    public function testModifyWithFormatOption()
292
    {
293
        $file = m::mock(LocalFileNodeInterface::class, FormatAwareInterface::class);
294
        $target = m::mock(LocalFileNodeInterface::class, FormatAwareInterface::class);
295
296
        $file->shouldReceive('getPath')
297
             ->andReturn('/tmp/file.txt');
298
        $file->shouldReceive('exists')
299
             ->andReturn(true);
300
301
        $file->shouldReceive('getClone')
302
             ->andReturn($target);
303
        $target->shouldReceive('setPath')
304
               ->with('/tmp/file-format.txt')
305
               ->andReturn($target);
306
307
        $format = m::mock(FormatInterface::class);
308
309
        $target->shouldReceive('setFormat')
310
               ->with($format)
311
               ->andReturn($target);
312
313
        $reader = m::mock(FileReader::class);
314
        $this->builder->shouldReceive('build')
315
                      ->with(FileReader::class, $file, null, $this->parserFactory)
316
                      ->andReturn($reader);
317
        $writer = m::mock(FileWriter::class);
318
        $this->builder->shouldReceive('build')
319
                      ->with(FileWriter::Class, $target, $format, $this->formatterFactory)
320
                      ->andReturn($writer);
321
322
        $iterator = new ArrayIterator(['first', 'second']);
323
324
        $reader->shouldReceive('fetch')
325
               ->andReturn($iterator);
326
327
        $writer->shouldReceive('insertOne')
328
               ->with('first')
329
               ->once();
330
        $writer->shouldReceive('insertOne')
331
               ->with('second')
332
               ->once();
333
334
        static::assertSame($target, $this->reFormatter->modify($file, ['format' => $format]));
335
    }
336
337
    public function testReFormatWithDeleteOldFile()
338
    {