Skip to content

Commit 6d91efd

Browse files
SpacePossumsebastianbergmann
authored andcommitted
More strict testing.
1 parent 852dd59 commit 6d91efd

File tree

5 files changed

+37
-47
lines changed

5 files changed

+37
-47
lines changed

tests/ChunkTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,35 @@ public function testCanBeCreatedWithoutArguments()
3434

3535
public function testStartCanBeRetrieved()
3636
{
37-
$this->assertEquals(0, $this->chunk->getStart());
37+
$this->assertSame(0, $this->chunk->getStart());
3838
}
3939

4040
public function testStartRangeCanBeRetrieved()
4141
{
42-
$this->assertEquals(1, $this->chunk->getStartRange());
42+
$this->assertSame(1, $this->chunk->getStartRange());
4343
}
4444

4545
public function testEndCanBeRetrieved()
4646
{
47-
$this->assertEquals(0, $this->chunk->getEnd());
47+
$this->assertSame(0, $this->chunk->getEnd());
4848
}
4949

5050
public function testEndRangeCanBeRetrieved()
5151
{
52-
$this->assertEquals(1, $this->chunk->getEndRange());
52+
$this->assertSame(1, $this->chunk->getEndRange());
5353
}
5454

5555
public function testLinesCanBeRetrieved()
5656
{
57-
$this->assertEquals([], $this->chunk->getLines());
57+
$this->assertSame([], $this->chunk->getLines());
5858
}
5959

6060
public function testLinesCanBeSet()
6161
{
62-
$this->assertEquals([], $this->chunk->getLines());
62+
$this->assertSame([], $this->chunk->getLines());
6363

6464
$testValue = ['line0', 'line1'];
6565
$this->chunk->setLines($testValue);
66-
$this->assertEquals($testValue, $this->chunk->getLines());
66+
$this->assertSame($testValue, $this->chunk->getLines());
6767
}
6868
}

tests/DifferTest.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function setUp()
4646
*/
4747
public function testArrayRepresentationOfDiffCanBeRenderedUsingTimeEfficientLcsImplementation(array $expected, $from, $to)
4848
{
49-
$this->assertEquals($expected, $this->differ->diffToArray($from, $to, new TimeEfficientLongestCommonSubsequenceCalculator));
49+
$this->assertSame($expected, $this->differ->diffToArray($from, $to, new TimeEfficientLongestCommonSubsequenceCalculator));
5050
}
5151

5252
/**
@@ -57,7 +57,7 @@ public function testArrayRepresentationOfDiffCanBeRenderedUsingTimeEfficientLcsI
5757
*/
5858
public function testTextRepresentationOfDiffCanBeRenderedUsingTimeEfficientLcsImplementation($expected, $from, $to)
5959
{
60-
$this->assertEquals($expected, $this->differ->diff($from, $to, new TimeEfficientLongestCommonSubsequenceCalculator));
60+
$this->assertSame($expected, $this->differ->diff($from, $to, new TimeEfficientLongestCommonSubsequenceCalculator));
6161
}
6262

6363
/**
@@ -68,7 +68,7 @@ public function testTextRepresentationOfDiffCanBeRenderedUsingTimeEfficientLcsIm
6868
*/
6969
public function testArrayRepresentationOfDiffCanBeRenderedUsingMemoryEfficientLcsImplementation(array $expected, $from, $to)
7070
{
71-
$this->assertEquals($expected, $this->differ->diffToArray($from, $to, new MemoryEfficientLongestCommonSubsequenceCalculator));
71+
$this->assertSame($expected, $this->differ->diffToArray($from, $to, new MemoryEfficientLongestCommonSubsequenceCalculator));
7272
}
7373

7474
/**
@@ -79,22 +79,22 @@ public function testArrayRepresentationOfDiffCanBeRenderedUsingMemoryEfficientLc
7979
*/
8080
public function testTextRepresentationOfDiffCanBeRenderedUsingMemoryEfficientLcsImplementation($expected, $from, $to)
8181
{
82-
$this->assertEquals($expected, $this->differ->diff($from, $to, new MemoryEfficientLongestCommonSubsequenceCalculator));
82+
$this->assertSame($expected, $this->differ->diff($from, $to, new MemoryEfficientLongestCommonSubsequenceCalculator));
8383
}
8484

8585
public function testCustomHeaderCanBeUsed()
8686
{
8787
$differ = new Differ('CUSTOM HEADER');
8888

89-
$this->assertEquals(
89+
$this->assertSame(
9090
"CUSTOM HEADER@@ @@\n-a\n+b\n",
9191
$differ->diff('a', 'b')
9292
);
9393
}
9494

9595
public function testTypesOtherThanArrayAndStringCanBePassed()
9696
{
97-
$this->assertEquals(
97+
$this->assertSame(
9898
"--- Original\n+++ New\n@@ @@\n-1\n+2\n",
9999
$this->differ->diff(1, 2)
100100
);
@@ -385,29 +385,19 @@ public function textForNoNonDiffLinesProvider()
385385
];
386386
}
387387

388-
/**
389-
* @requires PHPUnit 5.7
390-
*/
391388
public function testDiffToArrayInvalidFromType()
392389
{
393-
$differ = new Differ;
394-
395390
$this->expectException('\InvalidArgumentException');
396391
$this->expectExceptionMessageRegExp('#^"from" must be an array or string\.$#');
397392

398-
$differ->diffToArray(null, '');
393+
$this->differ->diffToArray(null, '');
399394
}
400395

401-
/**
402-
* @requires PHPUnit 5.7
403-
*/
404396
public function testDiffInvalidToType()
405397
{
406-
$differ = new Differ;
407-
408398
$this->expectException('\InvalidArgumentException');
409399
$this->expectExceptionMessageRegExp('#^"to" must be an array or string\.$#');
410400

411-
$differ->diffToArray('', new \stdClass);
401+
$this->differ->diffToArray('', new \stdClass);
412402
}
413403
}

tests/LineTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public function testCanBeCreatedWithoutArguments()
3434

3535
public function testTypeCanBeRetrieved()
3636
{
37-
$this->assertEquals(Line::UNCHANGED, $this->line->getType());
37+
$this->assertSame(Line::UNCHANGED, $this->line->getType());
3838
}
3939

4040
public function testContentCanBeRetrieved()
4141
{
42-
$this->assertEquals('', $this->line->getContent());
42+
$this->assertSame('', $this->line->getContent());
4343
}
4444
}

tests/LongestCommonSubsequenceTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testBothEmpty()
5353
$to = [];
5454
$common = $this->implementation->calculate($from, $to);
5555

56-
$this->assertEquals([], $common);
56+
$this->assertSame([], $common);
5757
}
5858

5959
public function testIsStrictComparison()
@@ -65,7 +65,7 @@ public function testIsStrictComparison()
6565
$to = $from;
6666
$common = $this->implementation->calculate($from, $to);
6767

68-
$this->assertEquals($from, $common);
68+
$this->assertSame($from, $common);
6969

7070
$to = [
7171
false, false, false, false, false, false,
@@ -79,7 +79,7 @@ public function testIsStrictComparison()
7979

8080
$common = $this->implementation->calculate($from, $to);
8181

82-
$this->assertEquals($expected, $common);
82+
$this->assertSame($expected, $common);
8383
}
8484

8585
public function testEqualSequences()
@@ -90,7 +90,7 @@ public function testEqualSequences()
9090
$to = $range;
9191
$common = $this->implementation->calculate($from, $to);
9292

93-
$this->assertEquals($range, $common);
93+
$this->assertSame($range, $common);
9494
}
9595
}
9696

@@ -99,18 +99,18 @@ public function testDistinctSequences()
9999
$from = ['A'];
100100
$to = ['B'];
101101
$common = $this->implementation->calculate($from, $to);
102-
$this->assertEquals([], $common);
102+
$this->assertSame([], $common);
103103

104104
$from = ['A', 'B', 'C'];
105105
$to = ['D', 'E', 'F'];
106106
$common = $this->implementation->calculate($from, $to);
107-
$this->assertEquals([], $common);
107+
$this->assertSame([], $common);
108108

109109
foreach ($this->stress_sizes as $size) {
110110
$from = \range(1, $size);
111111
$to = \range($size + 1, $size * 2);
112112
$common = $this->implementation->calculate($from, $to);
113-
$this->assertEquals([], $common);
113+
$this->assertSame([], $common);
114114
}
115115
}
116116

@@ -120,21 +120,21 @@ public function testCommonSubsequence()
120120
$to = ['A', 'B', 'D', 'E', 'H'];
121121
$expected = ['A', 'E'];
122122
$common = $this->implementation->calculate($from, $to);
123-
$this->assertEquals($expected, $common);
123+
$this->assertSame($expected, $common);
124124

125125
$from = ['A', 'C', 'E', 'F', 'G'];
126126
$to = ['B', 'C', 'D', 'E', 'F', 'H'];
127127
$expected = ['C', 'E', 'F'];
128128
$common = $this->implementation->calculate($from, $to);
129-
$this->assertEquals($expected, $common);
129+
$this->assertSame($expected, $common);
130130

131131
foreach ($this->stress_sizes as $size) {
132132
$from = $size < 2 ? [1] : \range(1, $size + 1, 2);
133133
$to = $size < 3 ? [1] : \range(1, $size + 1, 3);
134134
$expected = $size < 6 ? [1] : \range(1, $size + 1, 6);
135135
$common = $this->implementation->calculate($from, $to);
136136

137-
$this->assertEquals($expected, $common);
137+
$this->assertSame($expected, $common);
138138
}
139139
}
140140

@@ -145,18 +145,18 @@ public function testSingleElementSubsequenceAtStart()
145145
$to = \array_slice($from, 0, 1);
146146
$common = $this->implementation->calculate($from, $to);
147147

148-
$this->assertEquals($to, $common);
148+
$this->assertSame($to, $common);
149149
}
150150
}
151151

152152
public function testSingleElementSubsequenceAtMiddle()
153153
{
154154
foreach ($this->stress_sizes as $size) {
155155
$from = \range(1, $size);
156-
$to = \array_slice($from, (int) $size / 2, 1);
156+
$to = \array_slice($from, (int) ($size / 2), 1);
157157
$common = $this->implementation->calculate($from, $to);
158158

159-
$this->assertEquals($to, $common);
159+
$this->assertSame($to, $common);
160160
}
161161
}
162162

@@ -167,7 +167,7 @@ public function testSingleElementSubsequenceAtEnd()
167167
$to = \array_slice($from, $size - 1, 1);
168168
$common = $this->implementation->calculate($from, $to);
169169

170-
$this->assertEquals($to, $common);
170+
$this->assertSame($to, $common);
171171
}
172172
}
173173

@@ -177,14 +177,14 @@ public function testReversedSequences()
177177
$to = ['B', 'A'];
178178
$expected = ['A'];
179179
$common = $this->implementation->calculate($from, $to);
180-
$this->assertEquals($expected, $common);
180+
$this->assertSame($expected, $common);
181181

182182
foreach ($this->stress_sizes as $size) {
183183
$from = \range(1, $size);
184184
$to = \array_reverse($from);
185185
$common = $this->implementation->calculate($from, $to);
186186

187-
$this->assertEquals([1], $common);
187+
$this->assertSame([1], $common);
188188
}
189189
}
190190

tests/ParserTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testParse()
4747

4848
$this->assertCount(1, $chunks);
4949

50-
$this->assertEquals(20, $chunks[0]->getStart());
50+
$this->assertSame(20, $chunks[0]->getStart());
5151

5252
$this->assertCount(4, $chunks[0]->getLines());
5353
}
@@ -63,9 +63,9 @@ public function testParseWithMultipleChunks()
6363
$chunks = $diffs[0]->getChunks();
6464
$this->assertCount(3, $chunks);
6565

66-
$this->assertEquals(20, $chunks[0]->getStart());
67-
$this->assertEquals(320, $chunks[1]->getStart());
68-
$this->assertEquals(600, $chunks[2]->getStart());
66+
$this->assertSame(20, $chunks[0]->getStart());
67+
$this->assertSame(320, $chunks[1]->getStart());
68+
$this->assertSame(600, $chunks[2]->getStart());
6969

7070
$this->assertCount(5, $chunks[0]->getLines());
7171
$this->assertCount(5, $chunks[1]->getLines());

0 commit comments

Comments
 (0)