|
@@ 184-214 (lines=31) @@
|
| 181 |
|
static::assertSame($target, $this->reFormatter->reFormat($file, $format)); |
| 182 |
|
} |
| 183 |
|
|
| 184 |
|
public function testCanReformatWithIntputAndOutputFiles() |
| 185 |
|
{ |
| 186 |
|
$file = m::mock(FileNodeInterface::class, FormatAwareInterface::class); |
| 187 |
|
$target = m::mock(LocalFileNodeInterface::class, FormatAwareInterface::class); |
| 188 |
|
|
| 189 |
|
$file->shouldReceive('exists') |
| 190 |
|
->andReturn(true); |
| 191 |
|
|
| 192 |
|
$reader = m::mock(FileReader::class); |
| 193 |
|
$this->builder->shouldReceive('build') |
| 194 |
|
->with(FileReader::class, $file, null, $this->parserFactory) |
| 195 |
|
->andReturn($reader); |
| 196 |
|
$writer = m::mock(FileWriter::class); |
| 197 |
|
$this->builder->shouldReceive('build') |
| 198 |
|
->with(FileWriter::Class, $target, null, $this->formatterFactory) |
| 199 |
|
->andReturn($writer); |
| 200 |
|
|
| 201 |
|
$iterator = new ArrayIterator(['first', 'second']); |
| 202 |
|
|
| 203 |
|
$reader->shouldReceive('fetch') |
| 204 |
|
->andReturn($iterator); |
| 205 |
|
|
| 206 |
|
$writer->shouldReceive('insertOne') |
| 207 |
|
->with('first') |
| 208 |
|
->once(); |
| 209 |
|
$writer->shouldReceive('insertOne') |
| 210 |
|
->with('second') |
| 211 |
|
->once(); |
| 212 |
|
|
| 213 |
|
static::assertSame($target, $this->reFormatter->reFormat($file, null, $target)); |
| 214 |
|
} |
| 215 |
|
|
| 216 |
|
public function testInputAndOutputFormatsArePassedToReaderAndWriter() |
| 217 |
|
{ |
|
@@ 259-289 (lines=31) @@
|
| 256 |
|
$this->reFormatter->modify($file); |
| 257 |
|
} |
| 258 |
|
|
| 259 |
|
public function testModifyWithOutputFileSet() |
| 260 |
|
{ |
| 261 |
|
$file = m::mock(FileNodeInterface::class, FormatAwareInterface::class); |
| 262 |
|
$target = m::mock(LocalFileNodeInterface::class, FormatAwareInterface::class); |
| 263 |
|
|
| 264 |
|
$file->shouldReceive('exists') |
| 265 |
|
->andReturn(true); |
| 266 |
|
|
| 267 |
|
$reader = m::mock(FileReader::class); |
| 268 |
|
$this->builder->shouldReceive('build') |
| 269 |
|
->with(FileReader::class, $file, null, $this->parserFactory) |
| 270 |
|
->andReturn($reader); |
| 271 |
|
$writer = m::mock(FileWriter::class); |
| 272 |
|
$this->builder->shouldReceive('build') |
| 273 |
|
->with(FileWriter::Class, $target, null, $this->formatterFactory) |
| 274 |
|
->andReturn($writer); |
| 275 |
|
|
| 276 |
|
$iterator = new ArrayIterator(['first', 'second']); |
| 277 |
|
|
| 278 |
|
$reader->shouldReceive('fetch') |
| 279 |
|
->andReturn($iterator); |
| 280 |
|
|
| 281 |
|
$writer->shouldReceive('insertOne') |
| 282 |
|
->with('first') |
| 283 |
|
->once(); |
| 284 |
|
$writer->shouldReceive('insertOne') |
| 285 |
|
->with('second') |
| 286 |
|
->once(); |
| 287 |
|
|
| 288 |
|
static::assertSame($target, $this->reFormatter->modify($file, ['output' => $target])); |
| 289 |
|
} |
| 290 |
|
|
| 291 |
|
public function testModifyWithFormatOption() |
| 292 |
|
{ |