@@ -103,7 +103,41 @@ public function testCompareSimilarClassMethod()
103103 $ this ->assertDifferences ($ differences );
104104 }
105105
106- public function testCompareSimilarClassMethodWithDifferentSignature ()
106+ public function testCompareSimilarClassMethodWithDifferentSignatureVariables ()
107+ {
108+ $ before = new Registry ();
109+ $ after = new Registry ();
110+
111+ $ beforeClass = new Class_ ('tmp ' , [
112+ 'stmts ' => [
113+ new ClassMethod ('tmpMethod ' , [
114+ 'params ' => [
115+ new Param ('a ' , null ),
116+ ],
117+ ]),
118+ ],
119+ ]);
120+ $ before ->addClass ($ beforeClass );
121+
122+ $ afterClass = new Class_ ('tmp ' , [
123+ 'stmts ' => [
124+ new ClassMethod ('tmpMethod ' , [
125+ 'params ' => [
126+ new Param ('b ' , null ),
127+ ],
128+ ]),
129+ ],
130+ ]);
131+ $ after ->addClass ($ afterClass );
132+
133+ $ differences = $ before ->compare ($ after );
134+
135+ $ this ->assertDifferences ($ differences , 0 , 0 , 0 , 0 , 0 , 1 );
136+ $ this ->assertSame ('Method parameter mismatch. ' , $ differences ['class ' ][Registry::PATCH ][0 ]->getReason ());
137+ $ this ->assertSame ('tmp::tmpMethod ' , $ differences ['class ' ][Registry::PATCH ][0 ]->getTarget ());
138+ }
139+
140+ public function testCompareSimilarClassMethodWithDifferentSignatureTypehint ()
107141 {
108142 $ before = new Registry ();
109143 $ after = new Registry ();
@@ -137,6 +171,41 @@ public function testCompareSimilarClassMethodWithDifferentSignature()
137171 $ this ->assertSame ('tmp::tmpMethod ' , $ differences ['class ' ][Registry::MAJOR ][0 ]->getTarget ());
138172 }
139173
174+ public function testCompareSimilarClassMethodWithDifferentSignatureLength ()
175+ {
176+ $ before = new Registry ();
177+ $ after = new Registry ();
178+
179+ $ beforeClass = new Class_ ('tmp ' , [
180+ 'stmts ' => [
181+ new ClassMethod ('tmpMethod ' , [
182+ 'params ' => [
183+ new Param ('a ' , null , 'A ' ),
184+ new Param ('b ' , null , 'B ' ),
185+ ],
186+ ]),
187+ ],
188+ ]);
189+ $ before ->addClass ($ beforeClass );
190+
191+ $ afterClass = new Class_ ('tmp ' , [
192+ 'stmts ' => [
193+ new ClassMethod ('tmpMethod ' , [
194+ 'params ' => [
195+ new Param ('b ' , null , 'B ' ),
196+ ],
197+ ]),
198+ ],
199+ ]);
200+ $ after ->addClass ($ afterClass );
201+
202+ $ differences = $ before ->compare ($ after );
203+
204+ $ this ->assertDifferences ($ differences , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 );
205+ $ this ->assertSame ('Method parameter mismatch. ' , $ differences ['class ' ][Registry::MAJOR ][0 ]->getReason ());
206+ $ this ->assertSame ('tmp::tmpMethod ' , $ differences ['class ' ][Registry::MAJOR ][0 ]->getTarget ());
207+ }
208+
140209 public function testCompareMissingClassMethod ()
141210 {
142211 $ before = new Registry ();
@@ -289,14 +358,63 @@ public function testCompareSimilarFunction()
289358 $ this ->assertDifferences ($ differences );
290359 }
291360
292- public function testCompareSimilarFunctionWithDifferentSignature ()
361+ public function testCompareSimilarFunctionWithDifferentSignatureVariables ()
362+ {
363+ $ before = new Registry ();
364+ $ after = new Registry ();
365+
366+ $ before ->addFunction (new Function_ ('tmp ' , [
367+ 'params ' => [
368+ new Param ('a ' , null ),
369+ ],
370+ ]));
371+
372+ $ after ->addFunction (new Function_ ('tmp ' , [
373+ 'params ' => [
374+ new Param ('b ' , null ),
375+ ],
376+ ]));
377+
378+ $ differences = $ before ->compare ($ after );
379+
380+ $ this ->assertDifferences ($ differences , 0 , 1 );
381+ $ this ->assertSame ('Function parameter mismatch. ' , $ differences ['function ' ][Registry::PATCH ][0 ]->getReason ());
382+ $ this ->assertSame ('tmp ' , $ differences ['function ' ][Registry::PATCH ][0 ]->getTarget ());
383+ }
384+
385+ public function testCompareSimilarFunctionWithDifferentSignatureTypehint ()
386+ {
387+ $ before = new Registry ();
388+ $ after = new Registry ();
389+
390+ $ before ->addFunction (new Function_ ('tmp ' , [
391+ 'params ' => [
392+ new Param ('a ' , null , 'A ' ),
393+ ],
394+ ]));
395+
396+ $ after ->addFunction (new Function_ ('tmp ' , [
397+ 'params ' => [
398+ new Param ('a ' , null , 'B ' ),
399+ ],
400+ ]));
401+
402+ $ differences = $ before ->compare ($ after );
403+
404+ $ this ->assertDifferences ($ differences , 0 , 0 , 0 , 1 );
405+ $ this ->assertSame ('Function parameter mismatch. ' , $ differences ['function ' ][Registry::MAJOR ][0 ]->getReason ());
406+ $ this ->assertSame ('tmp ' , $ differences ['function ' ][Registry::MAJOR ][0 ]->getTarget ());
407+ }
408+
409+ public function testCompareSimilarFunctionWithDifferentSignatureLength ()
293410 {
294411 $ before = new Registry ();
295412 $ after = new Registry ();
296413
297414 $ before ->addFunction (new Function_ ('tmp ' , [
298415 'params ' => [
299416 new Param ('a ' , null , 'A ' ),
417+ new Param ('b ' , null , 'B ' ),
300418 ],
301419 ]));
302420
0 commit comments