@@ 178-205 (lines=28) @@ | ||
175 | static::assertSame($target, $this->reFormatter->reFormat($file, $format)); |
|
176 | } |
|
177 | ||
178 | public function testCanReformatWithIntputAndOutputFiles() |
|
179 | { |
|
180 | $file = m::mock(FileNodeInterface::class, FormatAwareInterface::class); |
|
181 | $target = m::mock(LocalFileNodeInterface::class, FormatAwareInterface::class); |
|
182 | ||
183 | $file->shouldReceive('exists') |
|
184 | ->andReturn(true); |
|
185 | ||
186 | $reader = m::mock(FileReader::class); |
|
187 | $this->builder->shouldReceive('build') |
|
188 | ->with(FileReader::class, $file, null, $this->parserFactory) |
|
189 | ->andReturn($reader); |
|
190 | $writer = m::mock(FileWriter::class); |
|
191 | $this->builder->shouldReceive('build') |
|
192 | ->with(FileWriter::Class, $target, null, $this->formatterFactory) |
|
193 | ->andReturn($writer); |
|
194 | ||
195 | $iterator = new ArrayIterator(['first', 'second']); |
|
196 | ||
197 | $reader->shouldReceive('fetch') |
|
198 | ->andReturn($iterator); |
|
199 | ||
200 | $writer->shouldReceive('insertAll') |
|
201 | ->with($iterator) |
|
202 | ->once(); |
|
203 | ||
204 | static::assertSame($target, $this->reFormatter->reFormat($file, null, $target)); |
|
205 | } |
|
206 | ||
207 | public function testInputAndOutputFormatsArePassedToReaderAndWriter() |
|
208 | { |
|
@@ 247-274 (lines=28) @@ | ||
244 | $this->reFormatter->modify($file); |
|
245 | } |
|
246 | ||
247 | public function testModifyWithOutputFileSet() |
|
248 | { |
|
249 | $file = m::mock(FileNodeInterface::class, FormatAwareInterface::class); |
|
250 | $target = m::mock(LocalFileNodeInterface::class, FormatAwareInterface::class); |
|
251 | ||
252 | $file->shouldReceive('exists') |
|
253 | ->andReturn(true); |
|
254 | ||
255 | $reader = m::mock(FileReader::class); |
|
256 | $this->builder->shouldReceive('build') |
|
257 | ->with(FileReader::class, $file, null, $this->parserFactory) |
|
258 | ->andReturn($reader); |
|
259 | $writer = m::mock(FileWriter::class); |
|
260 | $this->builder->shouldReceive('build') |
|
261 | ->with(FileWriter::Class, $target, null, $this->formatterFactory) |
|
262 | ->andReturn($writer); |
|
263 | ||
264 | $iterator = new ArrayIterator(['first', 'second']); |
|
265 | ||
266 | $reader->shouldReceive('fetch') |
|
267 | ->andReturn($iterator); |
|
268 | ||
269 | $writer->shouldReceive('insertAll') |
|
270 | ->with($iterator) |
|
271 | ->once(); |
|
272 | ||
273 | static::assertSame($target, $this->reFormatter->modify($file, ['output' => $target])); |
|
274 | } |
|
275 | ||
276 | public function testModifyWithFormatOption() |
|
277 | { |