|
19 | 19 | #[Small]
|
20 | 20 | final class ChunkTest extends TestCase
|
21 | 21 | {
|
22 |
| - private Chunk $chunk; |
23 |
| - |
24 |
| - protected function setUp(): void |
| 22 | + public function testHasLines(): void |
25 | 23 | {
|
26 |
| - $this->chunk = new Chunk; |
| 24 | + $this->assertEquals([$this->line()], $this->chunk()->lines()); |
| 25 | + $this->assertEquals([$this->line()], $this->chunk()->getLines()); |
27 | 26 | }
|
28 | 27 |
|
29 |
| - public function testHasInitiallyNoLines(): void |
| 28 | + public function testHasStart(): void |
30 | 29 | {
|
31 |
| - $this->assertSame([], $this->chunk->lines()); |
32 |
| - $this->assertSame([], $this->chunk->getLines()); |
| 30 | + $this->assertSame(1, $this->chunk()->start()); |
| 31 | + $this->assertSame(1, $this->chunk()->getStart()); |
33 | 32 | }
|
34 | 33 |
|
35 |
| - public function testCanBeCreatedWithoutArguments(): void |
| 34 | + public function testHasStartRange(): void |
36 | 35 | {
|
37 |
| - $this->assertInstanceOf(Chunk::class, $this->chunk); |
| 36 | + $this->assertSame(2, $this->chunk()->startRange()); |
| 37 | + $this->assertSame(2, $this->chunk()->getStartRange()); |
38 | 38 | }
|
39 | 39 |
|
40 |
| - public function testStartCanBeRetrieved(): void |
| 40 | + public function testHasEnd(): void |
41 | 41 | {
|
42 |
| - $this->assertSame(0, $this->chunk->start()); |
43 |
| - $this->assertSame(0, $this->chunk->getStart()); |
| 42 | + $this->assertSame(3, $this->chunk()->end()); |
| 43 | + $this->assertSame(3, $this->chunk()->getEnd()); |
44 | 44 | }
|
45 | 45 |
|
46 |
| - public function testStartRangeCanBeRetrieved(): void |
| 46 | + public function testHasEndRange(): void |
47 | 47 | {
|
48 |
| - $this->assertSame(1, $this->chunk->startRange()); |
49 |
| - $this->assertSame(1, $this->chunk->getStartRange()); |
| 48 | + $this->assertSame(4, $this->chunk()->endRange()); |
| 49 | + $this->assertSame(4, $this->chunk()->getEndRange()); |
50 | 50 | }
|
51 | 51 |
|
52 |
| - public function testEndCanBeRetrieved(): void |
| 52 | + public function testLinesCanBeSet(): void |
53 | 53 | {
|
54 |
| - $this->assertSame(0, $this->chunk->end()); |
55 |
| - $this->assertSame(0, $this->chunk->getEnd()); |
56 |
| - } |
| 54 | + $chunk = $this->chunk(); |
| 55 | + $lines = [new Line(Line::ADDED, 'added'), new Line(Line::REMOVED, 'removed')]; |
57 | 56 |
|
58 |
| - public function testEndRangeCanBeRetrieved(): void |
59 |
| - { |
60 |
| - $this->assertSame(1, $this->chunk->endRange()); |
61 |
| - $this->assertSame(1, $this->chunk->getEndRange()); |
| 57 | + $chunk->setLines($lines); |
| 58 | + |
| 59 | + $this->assertSame($lines, $chunk->lines()); |
62 | 60 | }
|
63 | 61 |
|
64 |
| - public function testLinesCanBeRetrieved(): void |
| 62 | + private function chunk(): Chunk |
65 | 63 | {
|
66 |
| - $this->assertSame([], $this->chunk->lines()); |
67 |
| - $this->assertSame([], $this->chunk->getLines()); |
| 64 | + return new Chunk( |
| 65 | + 1, |
| 66 | + 2, |
| 67 | + 3, |
| 68 | + 4, |
| 69 | + [ |
| 70 | + $this->line(), |
| 71 | + ] |
| 72 | + ); |
68 | 73 | }
|
69 | 74 |
|
70 |
| - public function testLinesCanBeSet(): void |
| 75 | + private function line(): Line |
71 | 76 | {
|
72 |
| - $lines = [new Line(Line::ADDED, 'added'), new Line(Line::REMOVED, 'removed')]; |
73 |
| - |
74 |
| - $this->chunk->setLines($lines); |
75 |
| - |
76 |
| - $this->assertSame($lines, $this->chunk->lines()); |
77 |
| - $this->assertSame($lines, $this->chunk->getLines()); |
| 77 | + return new Line(Line::ADDED, 'content'); |
78 | 78 | }
|
79 | 79 | }
|
0 commit comments