Code Duplication    Length = 43-43 lines in 2 locations

tests/unit/Modify/ReFormatTest.php 2 locations

@@ 135-177 (lines=43) @@
132
        static::assertSame($target, $this->reFormatter->reFormat($file, $format));
133
    }
134
135
    public function testCanReFormatALocalInputFile()
136
    {
137
        $file = m::mock(LocalFileNodeInterface::class, FormatAwareInterface::class);
138
        $target = m::mock(LocalFileNodeInterface::class, FormatAwareInterface::class);
139
140
        $file->shouldReceive('getPath')
141
             ->andReturn('/tmp/file.txt');
142
143
        $file->shouldReceive('getClone')
144
             ->andReturn($target);
145
        $target->shouldReceive('setPath')
146
               ->with('/tmp/file-format.txt')
147
               ->andReturn($target);
148
149
        $format = m::mock(FormatInterface::class);
150
151
        $target->shouldReceive('setFormat')
152
               ->with($format)
153
               ->andReturn($target);
154
155
        $reader = m::mock(FileReader::class);
156
        $this->builder->shouldReceive('build')
157
                      ->with(FileReader::class, $file, null, $this->parserFactory)
158
                      ->andReturn($reader);
159
        $writer = m::mock(FileWriter::class);
160
        $this->builder->shouldReceive('build')
161
                      ->with(FileWriter::Class, $target, $format, $this->formatterFactory)
162
                      ->andReturn($writer);
163
164
        $iterator = new ArrayIterator(['first', 'second']);
165
166
        $reader->shouldReceive('fetch')
167
               ->andReturn($iterator);
168
169
        $writer->shouldReceive('insertOne')
170
               ->with('first')
171
               ->once();
172
        $writer->shouldReceive('insertOne')
173
               ->with('second')
174
               ->once();
175
176
        static::assertSame($target, $this->reFormatter->reFormat($file, $format));
177
    }
178
179
    public function testCanReformatWithIntputAndOutputFiles()
180
    {
@@ 277-319 (lines=43) @@
274
        static::assertSame($target, $this->reFormatter->modify($file, ['output' => $target]));
275
    }
276
277
    public function testModifyWithFormatOption()
278
    {
279
        $file = m::mock(LocalFileNodeInterface::class, FormatAwareInterface::class);
280
        $target = m::mock(LocalFileNodeInterface::class, FormatAwareInterface::class);
281
282
        $file->shouldReceive('getPath')
283
             ->andReturn('/tmp/file.txt');
284
285
        $file->shouldReceive('getClone')
286
             ->andReturn($target);
287
        $target->shouldReceive('setPath')
288
               ->with('/tmp/file-format.txt')
289
               ->andReturn($target);
290
291
        $format = m::mock(FormatInterface::class);
292
293
        $target->shouldReceive('setFormat')
294
               ->with($format)
295
               ->andReturn($target);
296
297
        $reader = m::mock(FileReader::class);
298
        $this->builder->shouldReceive('build')
299
                      ->with(FileReader::class, $file, null, $this->parserFactory)
300
                      ->andReturn($reader);
301
        $writer = m::mock(FileWriter::class);
302
        $this->builder->shouldReceive('build')
303
                      ->with(FileWriter::Class, $target, $format, $this->formatterFactory)
304
                      ->andReturn($writer);
305
306
        $iterator = new ArrayIterator(['first', 'second']);
307
308
        $reader->shouldReceive('fetch')
309
               ->andReturn($iterator);
310
311
        $writer->shouldReceive('insertOne')
312
               ->with('first')
313
               ->once();
314
        $writer->shouldReceive('insertOne')
315
               ->with('second')
316
               ->once();
317
318
        static::assertSame($target, $this->reFormatter->modify($file, ['format' => $format]));
319
    }
320
}
321