| @@ 11-24 (lines=14) @@ | ||
| 8 | ||
| 9 | class AttributeTest extends TestCase |
|
| 10 | { |
|
| 11 | public function testParse() |
|
| 12 | { |
|
| 13 | $origin = 'foo'; |
|
| 14 | $parsed = 'bar'; |
|
| 15 | ||
| 16 | $attr = new Attribute(); |
|
| 17 | $this->assertSame($origin, $attr->parse($origin)); |
|
| 18 | ||
| 19 | $transformerProphecy = $this->prophesize(TransformerInterface::class); |
|
| 20 | $transformerProphecy->transform($origin)->shouldBeCalledTimes(1)->willReturn($parsed); |
|
| 21 | ||
| 22 | $attr->transformer = $transformerProphecy->reveal(); |
|
| 23 | $this->assertSame($parsed, $attr->parse($origin)); |
|
| 24 | } |
|
| 25 | ||
| 26 | public function testDump() |
|
| 27 | { |
|
| @@ 26-39 (lines=14) @@ | ||
| 23 | $this->assertSame($parsed, $attr->parse($origin)); |
|
| 24 | } |
|
| 25 | ||
| 26 | public function testDump() |
|
| 27 | { |
|
| 28 | $origin = 'foo'; |
|
| 29 | $parsed = 'bar'; |
|
| 30 | ||
| 31 | $attr = new Attribute(); |
|
| 32 | $this->assertSame($parsed, $attr->dump($parsed)); |
|
| 33 | ||
| 34 | $transformerProphecy = $this->prophesize(TransformerInterface::class); |
|
| 35 | $transformerProphecy->reverse($parsed)->shouldBeCalledTimes(1)->willReturn($origin); |
|
| 36 | ||
| 37 | $attr->transformer = $transformerProphecy->reveal(); |
|
| 38 | $this->assertSame($origin, $attr->dump($parsed)); |
|
| 39 | } |
|
| 40 | } |
|
| 41 | ||
| @@ 59-72 (lines=14) @@ | ||
| 56 | $this->assertSame($transformed, $lines->read()); // test read cache, should only transform once |
|
| 57 | } |
|
| 58 | ||
| 59 | public function testWrite() |
|
| 60 | { |
|
| 61 | $line = 'value'; |
|
| 62 | $transformed = ['value' => 'value']; |
|
| 63 | ||
| 64 | $transformerProphecy = $this->prophesize(TransformerInterface::class); |
|
| 65 | $transformerProphecy->reverse($transformed)->shouldBeCalledTimes(1)->willReturn($line); |
|
| 66 | ||
| 67 | $streamProphecy = $this->prophesize(StreamInterface::class); |
|
| 68 | $streamProphecy->putLine($line)->shouldBeCalled(); |
|
| 69 | ||
| 70 | $lines = new Lines($streamProphecy->reveal(), $transformerProphecy->reveal()); |
|
| 71 | $lines->write($transformed); |
|
| 72 | } |
|
| 73 | } |
|
| 74 | ||