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