@@ -49,14 +49,21 @@ class DiffTest extends \PHPUnit_Framework_TestCase
4949 const ADDED = 1 ;
5050 const OLD = 0 ;
5151
52+ private $ diff ;
53+
54+ protected function setUp ()
55+ {
56+ $ this ->diff = new Diff ;
57+ }
58+
5259 /**
5360 * @covers SebastianBergmann\Diff::diff
5461 */
5562 public function testComparisonErrorMessage ()
5663 {
5764 $ this ->assertEquals (
5865 "--- Original \n+++ New \n@@ @@ \n-a \n+b \n" ,
59- new Diff ('a ' , 'b ' )
66+ $ this -> diff -> diff ('a ' , 'b ' )
6067 );
6168 }
6269
@@ -69,8 +76,7 @@ public function testComparisonErrorMessage_toArray()
6976 $ expected [] = array ('a ' , self ::REMOVED );
7077 $ expected [] = array ('b ' , self ::ADDED );
7178
72- $ diff = new Diff ('a ' , 'b ' );
73- $ this ->assertEquals ($ expected , $ diff ->toArray ());
79+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('a ' , 'b ' ));
7480 }
7581
7682 /**
@@ -80,7 +86,7 @@ public function testComparisonErrorStartSame()
8086 {
8187 $ this ->assertEquals (
8288 "--- Original \n+++ New \n@@ @@ \n-ba \n+bc \n" ,
83- new Diff ('ba ' , 'bc ' )
89+ $ this -> diff -> diff ('ba ' , 'bc ' )
8490 );
8591 }
8692
@@ -93,8 +99,7 @@ public function testComparisonErrorStartSame_toArray()
9399 $ expected [] = array ('ba ' , self ::REMOVED );
94100 $ expected [] = array ('bc ' , self ::ADDED );
95101
96- $ diff = new Diff ('ba ' , 'bc ' );
97- $ this ->assertEquals ($ expected , $ diff ->toArray ());
102+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('ba ' , 'bc ' ));
98103 }
99104
100105 /**
@@ -104,7 +109,7 @@ public function testComparisonErrorEndSame()
104109 {
105110 $ this ->assertEquals (
106111 "--- Original \n+++ New \n@@ @@ \n-ab \n+cb \n" ,
107- new Diff ('ab ' , 'cb ' )
112+ $ this -> diff -> diff ('ab ' , 'cb ' )
108113 );
109114 }
110115
@@ -117,8 +122,7 @@ public function testComparisonErrorEndSame_toArray()
117122 $ expected [] = array ('ab ' , self ::REMOVED );
118123 $ expected [] = array ('cb ' , self ::ADDED );
119124
120- $ diff = new Diff ('ab ' , 'cb ' );
121- $ this ->assertEquals ($ expected , $ diff ->toArray ());
125+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('ab ' , 'cb ' ));
122126 }
123127
124128 /**
@@ -128,7 +132,7 @@ public function testComparisonErrorStartAndEndSame()
128132 {
129133 $ this ->assertEquals (
130134 "--- Original \n+++ New \n@@ @@ \n-abc \n+adc \n" ,
131- new Diff ('abc ' , 'adc ' )
135+ $ this -> diff -> diff ('abc ' , 'adc ' )
132136 );
133137 }
134138
@@ -141,8 +145,7 @@ public function testComparisonErrorStartAndEndSame_toArray()
141145 $ expected [] = array ('abc ' , self ::REMOVED );
142146 $ expected [] = array ('adc ' , self ::ADDED );
143147
144- $ diff = new Diff ('abc ' , 'adc ' );
145- $ this ->assertEquals ($ expected , $ diff ->toArray ());
148+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('abc ' , 'adc ' ));
146149 }
147150
148151 /**
@@ -152,7 +155,7 @@ public function testComparisonErrorStartSameComplete()
152155 {
153156 $ this ->assertEquals (
154157 "--- Original \n+++ New \n@@ @@ \n-ab \n+abc \n" ,
155- new Diff ('ab ' , 'abc ' )
158+ $ this -> diff -> diff ('ab ' , 'abc ' )
156159 );
157160 }
158161
@@ -165,8 +168,7 @@ public function testComparisonErrorStartSameComplete_toArray()
165168 $ expected [] = array ('ab ' , self ::REMOVED );
166169 $ expected [] = array ('abc ' , self ::ADDED );
167170
168- $ diff = new Diff ('ab ' , 'abc ' );
169- $ this ->assertEquals ($ expected , $ diff ->toArray ());
171+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('ab ' , 'abc ' ));
170172 }
171173
172174 /**
@@ -176,7 +178,7 @@ public function testComparisonErrorEndSameComplete()
176178 {
177179 $ this ->assertEquals (
178180 "--- Original \n+++ New \n@@ @@ \n-bc \n+abc \n" ,
179- new Diff ('bc ' , 'abc ' )
181+ $ this -> diff -> diff ('bc ' , 'abc ' )
180182 );
181183 }
182184
@@ -189,8 +191,7 @@ public function testComparisonErrorEndSameComplete_toArray()
189191 $ expected [] = array ('bc ' , self ::REMOVED );
190192 $ expected [] = array ('abc ' , self ::ADDED );
191193
192- $ diff = new Diff ('bc ' , 'abc ' );
193- $ this ->assertEquals ($ expected , $ diff ->toArray ());
194+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('bc ' , 'abc ' ));
194195 }
195196
196197 /**
@@ -200,7 +201,7 @@ public function testComparisonErrorOverlapingMatches()
200201 {
201202 $ this ->assertEquals (
202203 "--- Original \n+++ New \n@@ @@ \n-abc \n+abbc \n" ,
203- new Diff ('abc ' , 'abbc ' )
204+ $ this -> diff -> diff ('abc ' , 'abbc ' )
204205 );
205206 }
206207
@@ -213,8 +214,7 @@ public function testComparisonErrorOverlapingMatches_toArray()
213214 $ expected [] = array ('abc ' , self ::REMOVED );
214215 $ expected [] = array ('abbc ' , self ::ADDED );
215216
216- $ diff = new Diff ('abc ' , 'abbc ' );
217- $ this ->assertEquals ($ expected , $ diff ->toArray ());
217+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('abc ' , 'abbc ' ));
218218 }
219219
220220 /**
@@ -224,7 +224,7 @@ public function testComparisonErrorOverlapingMatches2()
224224 {
225225 $ this ->assertEquals (
226226 "--- Original \n+++ New \n@@ @@ \n-abcdde \n+abcde \n" ,
227- new Diff ('abcdde ' , 'abcde ' )
227+ $ this -> diff -> diff ('abcdde ' , 'abcde ' )
228228 );
229229 }
230230
@@ -237,32 +237,32 @@ public function testComparisonErrorOverlapingMatches2_toArray()
237237 $ expected [] = array ('abcdde ' , self ::REMOVED );
238238 $ expected [] = array ('abcde ' , self ::ADDED );
239239
240- $ diff = new Diff ('abcdde ' , 'abcde ' );
241- $ this ->assertEquals ($ expected , $ diff ->toArray ());
240+ $ this ->assertEquals ($ expected , $ this ->diff ->diffToArray ('abcdde ' , 'abcde ' ));
242241 }
243242
244243 /**
245244 * @covers SebastianBergmann\Diff::diff
246245 */
247246 public function testEmptyDiff ()
248247 {
249- $ this ->assertEquals ('' , new Diff ('abc ' , 'abc ' ));
248+ $ this ->assertEquals ('' , $ this -> diff -> diff ('abc ' , 'abc ' ));
250249 }
251250
252251 /**
253252 * @covers SebastianBergmann\Diff::toArray
254253 */
255254 public function testEmptyDiff_toArray ()
256255 {
257- $ diff = new Diff ('abc ' , 'abc ' );
258- $ this ->assertEquals (array (), $ diff ->toArray ());
256+ $ this ->assertEquals (array (), $ this ->diff ->diffToArray ('abc ' , 'abc ' ));
259257 }
260258
261259 public function testCustomHeader ()
262260 {
261+ $ diff = new Diff ('CUSTOM HEADER ' );
262+
263263 $ this ->assertEquals (
264264 "CUSTOM HEADER@@ @@ \n-a \n+b \n" ,
265- new Diff ('a ' , 'b ' , ' CUSTOM HEADER ' )
265+ $ this -> diff -> diff ('a ' , 'b ' )
266266 );
267267 }
268268}
0 commit comments