| @@ 111-130 (lines=20) @@ | ||
| 108 | new FileReader($file); |
|
| 109 | } |
|
| 110 | ||
| 111 | public function testNodeWithFormatWillUseThatFormat() |
|
| 112 | { |
|
| 113 | $stream = m::mock(StreamInterface::class); |
|
| 114 | ||
| 115 | $file = m::mock(FileNodeInterface::class, NodeStreamInterface::class, FormatAwareInterface::class); |
|
| 116 | $file->shouldReceive('getStream') |
|
| 117 | ->with('r') |
|
| 118 | ->andReturn($stream); |
|
| 119 | ||
| 120 | $format = m::mock(FormatInterface::class, JsonFormatInterface::class); |
|
| 121 | $format->shouldReceive('getType') |
|
| 122 | ->andReturn('json'); |
|
| 123 | ||
| 124 | $file->shouldReceive('getFormat') |
|
| 125 | ->andReturn($format); |
|
| 126 | ||
| 127 | $reader = new FileReader($file); |
|
| 128 | ||
| 129 | static::assertInstanceOf(ReaderInterface::class, $reader); |
|
| 130 | } |
|
| 131 | ||
| 132 | public function testProvidingAParserFactoryWillUseTheFactory() |
|
| 133 | { |
|
| @@ 71-89 (lines=19) @@ | ||
| 68 | new FileWriter($file); |
|
| 69 | } |
|
| 70 | ||
| 71 | public function testNodeWithFormatWillUseThatFormat() |
|
| 72 | { |
|
| 73 | $stream = m::mock(StreamInterface::class); |
|
| 74 | ||
| 75 | $file = m::mock(FileNodeInterface::class, NodeStreamInterface::class, FormatAwareInterface::class); |
|
| 76 | $file->shouldReceive('getStream') |
|
| 77 | ->with('a+') |
|
| 78 | ->andReturn($stream); |
|
| 79 | ||
| 80 | $format = m::mock(CsvFormat::class) |
|
| 81 | ->makePartial(); |
|
| 82 | ||
| 83 | $file->shouldReceive('getFormat') |
|
| 84 | ->andReturn($format); |
|
| 85 | ||
| 86 | $writer = new FileWriter($file); |
|
| 87 | ||
| 88 | static::assertInstanceOf(WriterInterface::class, $writer); |
|
| 89 | } |
|
| 90 | ||
| 91 | public function testProvidingAParserFactoryWillUseTheFactory() |
|
| 92 | { |
|