@@ -49,14 +49,21 @@ class DiffTest extends \PHPUnit_Framework_TestCase
49
49
const ADDED = 1 ;
50
50
const OLD = 0 ;
51
51
52
+ private $ diff ;
53
+
54
+ protected function setUp ()
55
+ {
56
+ $ this ->diff = new Diff ;
57
+ }
58
+
52
59
/**
53
60
* @covers SebastianBergmann\Diff::diff
54
61
*/
55
62
public function testComparisonErrorMessage ()
56
63
{
57
64
$ this ->assertEquals (
58
65
"--- Original \n+++ New \n@@ @@ \n-a \n+b \n" ,
59
- new Diff ('a ' , 'b ' )
66
+ $ this -> diff -> diff ('a ' , 'b ' )
60
67
);
61
68
}
62
69
@@ -69,8 +76,7 @@ public function testComparisonErrorMessage_toArray()
69
76
$ expected [] = array ('a ' , self ::REMOVED );
70
77
$ expected [] = array ('b ' , self ::ADDED );
71
78
72
- $ diff = new Diff ('a ' , 'b ' );
73
- $ this ->assertEquals ($ expected , $ diff ->toArray ());
79
+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('a ' , 'b ' ));
74
80
}
75
81
76
82
/**
@@ -80,7 +86,7 @@ public function testComparisonErrorStartSame()
80
86
{
81
87
$ this ->assertEquals (
82
88
"--- Original \n+++ New \n@@ @@ \n-ba \n+bc \n" ,
83
- new Diff ('ba ' , 'bc ' )
89
+ $ this -> diff -> diff ('ba ' , 'bc ' )
84
90
);
85
91
}
86
92
@@ -93,8 +99,7 @@ public function testComparisonErrorStartSame_toArray()
93
99
$ expected [] = array ('ba ' , self ::REMOVED );
94
100
$ expected [] = array ('bc ' , self ::ADDED );
95
101
96
- $ diff = new Diff ('ba ' , 'bc ' );
97
- $ this ->assertEquals ($ expected , $ diff ->toArray ());
102
+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('ba ' , 'bc ' ));
98
103
}
99
104
100
105
/**
@@ -104,7 +109,7 @@ public function testComparisonErrorEndSame()
104
109
{
105
110
$ this ->assertEquals (
106
111
"--- Original \n+++ New \n@@ @@ \n-ab \n+cb \n" ,
107
- new Diff ('ab ' , 'cb ' )
112
+ $ this -> diff -> diff ('ab ' , 'cb ' )
108
113
);
109
114
}
110
115
@@ -117,8 +122,7 @@ public function testComparisonErrorEndSame_toArray()
117
122
$ expected [] = array ('ab ' , self ::REMOVED );
118
123
$ expected [] = array ('cb ' , self ::ADDED );
119
124
120
- $ diff = new Diff ('ab ' , 'cb ' );
121
- $ this ->assertEquals ($ expected , $ diff ->toArray ());
125
+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('ab ' , 'cb ' ));
122
126
}
123
127
124
128
/**
@@ -128,7 +132,7 @@ public function testComparisonErrorStartAndEndSame()
128
132
{
129
133
$ this ->assertEquals (
130
134
"--- Original \n+++ New \n@@ @@ \n-abc \n+adc \n" ,
131
- new Diff ('abc ' , 'adc ' )
135
+ $ this -> diff -> diff ('abc ' , 'adc ' )
132
136
);
133
137
}
134
138
@@ -141,8 +145,7 @@ public function testComparisonErrorStartAndEndSame_toArray()
141
145
$ expected [] = array ('abc ' , self ::REMOVED );
142
146
$ expected [] = array ('adc ' , self ::ADDED );
143
147
144
- $ diff = new Diff ('abc ' , 'adc ' );
145
- $ this ->assertEquals ($ expected , $ diff ->toArray ());
148
+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('abc ' , 'adc ' ));
146
149
}
147
150
148
151
/**
@@ -152,7 +155,7 @@ public function testComparisonErrorStartSameComplete()
152
155
{
153
156
$ this ->assertEquals (
154
157
"--- Original \n+++ New \n@@ @@ \n-ab \n+abc \n" ,
155
- new Diff ('ab ' , 'abc ' )
158
+ $ this -> diff -> diff ('ab ' , 'abc ' )
156
159
);
157
160
}
158
161
@@ -165,8 +168,7 @@ public function testComparisonErrorStartSameComplete_toArray()
165
168
$ expected [] = array ('ab ' , self ::REMOVED );
166
169
$ expected [] = array ('abc ' , self ::ADDED );
167
170
168
- $ diff = new Diff ('ab ' , 'abc ' );
169
- $ this ->assertEquals ($ expected , $ diff ->toArray ());
171
+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('ab ' , 'abc ' ));
170
172
}
171
173
172
174
/**
@@ -176,7 +178,7 @@ public function testComparisonErrorEndSameComplete()
176
178
{
177
179
$ this ->assertEquals (
178
180
"--- Original \n+++ New \n@@ @@ \n-bc \n+abc \n" ,
179
- new Diff ('bc ' , 'abc ' )
181
+ $ this -> diff -> diff ('bc ' , 'abc ' )
180
182
);
181
183
}
182
184
@@ -189,8 +191,7 @@ public function testComparisonErrorEndSameComplete_toArray()
189
191
$ expected [] = array ('bc ' , self ::REMOVED );
190
192
$ expected [] = array ('abc ' , self ::ADDED );
191
193
192
- $ diff = new Diff ('bc ' , 'abc ' );
193
- $ this ->assertEquals ($ expected , $ diff ->toArray ());
194
+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('bc ' , 'abc ' ));
194
195
}
195
196
196
197
/**
@@ -200,7 +201,7 @@ public function testComparisonErrorOverlapingMatches()
200
201
{
201
202
$ this ->assertEquals (
202
203
"--- Original \n+++ New \n@@ @@ \n-abc \n+abbc \n" ,
203
- new Diff ('abc ' , 'abbc ' )
204
+ $ this -> diff -> diff ('abc ' , 'abbc ' )
204
205
);
205
206
}
206
207
@@ -213,8 +214,7 @@ public function testComparisonErrorOverlapingMatches_toArray()
213
214
$ expected [] = array ('abc ' , self ::REMOVED );
214
215
$ expected [] = array ('abbc ' , self ::ADDED );
215
216
216
- $ diff = new Diff ('abc ' , 'abbc ' );
217
- $ this ->assertEquals ($ expected , $ diff ->toArray ());
217
+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('abc ' , 'abbc ' ));
218
218
}
219
219
220
220
/**
@@ -224,7 +224,7 @@ public function testComparisonErrorOverlapingMatches2()
224
224
{
225
225
$ this ->assertEquals (
226
226
"--- Original \n+++ New \n@@ @@ \n-abcdde \n+abcde \n" ,
227
- new Diff ('abcdde ' , 'abcde ' )
227
+ $ this -> diff -> diff ('abcdde ' , 'abcde ' )
228
228
);
229
229
}
230
230
@@ -237,32 +237,32 @@ public function testComparisonErrorOverlapingMatches2_toArray()
237
237
$ expected [] = array ('abcdde ' , self ::REMOVED );
238
238
$ expected [] = array ('abcde ' , self ::ADDED );
239
239
240
- $ diff = new Diff ('abcdde ' , 'abcde ' );
241
- $ this ->assertEquals ($ expected , $ diff ->toArray ());
240
+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('abcdde ' , 'abcde ' ));
242
241
}
243
242
244
243
/**
245
244
* @covers SebastianBergmann\Diff::diff
246
245
*/
247
246
public function testEmptyDiff ()
248
247
{
249
- $ this ->assertEquals ('' , new Diff ('abc ' , 'abc ' ));
248
+ $ this ->assertEquals ('' , $ this -> diff -> diff ('abc ' , 'abc ' ));
250
249
}
251
250
252
251
/**
253
252
* @covers SebastianBergmann\Diff::toArray
254
253
*/
255
254
public function testEmptyDiff_toArray ()
256
255
{
257
- $ diff = new Diff ('abc ' , 'abc ' );
258
- $ this ->assertEquals (array (), $ diff ->toArray ());
256
+ $ this ->assertEquals (array (), $ this ->diff ->diffToArray ('abc ' , 'abc ' ));
259
257
}
260
258
261
259
public function testCustomHeader ()
262
260
{
261
+ $ diff = new Diff ('CUSTOM HEADER ' );
262
+
263
263
$ this ->assertEquals (
264
264
"CUSTOM HEADER@@ @@ \n-a \n+b \n" ,
265
- new Diff ('a ' , 'b ' , ' CUSTOM HEADER ' )
265
+ $ this -> diff -> diff ('a ' , 'b ' )
266
266
);
267
267
}
268
268
}
0 commit comments