@@ -169,35 +169,13 @@ public static function dataDeprecatedSniffsListDoesNotShowNeedsCsMode()
169169 public function testDeprecatedSniffsListDoesNotShowWhenSelectedSniffsAreNotDeprecated ()
170170 {
171171 $ standard = __DIR__ .'/ShowSniffDeprecationsTest.xml ' ;
172- $ config = new ConfigDouble (['. ' , "--standard= $ standard " ]);
173- $ ruleset = new Ruleset ($ config );
174-
175- /*
176- * Apply sniff restrictions.
177- * For tests we need to manually trigger this if the standard is "installed", like with the fixtures these tests use.
178- */
179-
180- $ restrictions = [];
181- $ sniffs = [
182- 'TestStandard.SetProperty.AllowedAsDeclared ' ,
183- 'TestStandard.SetProperty.AllowedViaStdClass ' ,
172+ $ cliArgs = [
173+ '. ' ,
174+ "--standard= $ standard " ,
175+ '--sniffs=TestStandard.SetProperty.AllowedAsDeclared,TestStandard.SetProperty.AllowedViaStdClass ' ,
184176 ];
185- foreach ($ sniffs as $ sniffCode ) {
186- $ parts = explode ('. ' , strtolower ($ sniffCode ));
187- $ sniffName = $ parts [0 ].'\\sniffs \\' .$ parts [1 ].'\\' .$ parts [2 ].'sniff ' ;
188- $ restrictions [strtolower ($ sniffName )] = true ;
189- }
190-
191- $ sniffFiles = [];
192- $ allSniffs = $ ruleset ->sniffCodes ;
193- foreach ($ allSniffs as $ sniffName ) {
194- $ sniffFile = str_replace ('\\' , DIRECTORY_SEPARATOR , $ sniffName );
195- $ sniffFile = __DIR__ .DIRECTORY_SEPARATOR .$ sniffFile .'.php ' ;
196- $ sniffFiles [] = $ sniffFile ;
197- }
198-
199- $ ruleset ->registerSniffs ($ sniffFiles , $ restrictions , []);
200- $ ruleset ->populateTokenListeners ();
177+ $ config = new ConfigDouble ($ cliArgs );
178+ $ ruleset = new Ruleset ($ config );
201179
202180 $ this ->expectOutputString ('' );
203181
@@ -215,38 +193,20 @@ public function testDeprecatedSniffsListDoesNotShowWhenSelectedSniffsAreNotDepre
215193 public function testDeprecatedSniffsListDoesNotShowWhenAllDeprecatedSniffsAreExcluded ()
216194 {
217195 $ standard = __DIR__ .'/ShowSniffDeprecationsTest.xml ' ;
218- $ config = new ConfigDouble (['. ' , "--standard= $ standard " ]);
219- $ ruleset = new Ruleset ($ config );
220-
221- /*
222- * Apply sniff restrictions.
223- * For tests we need to manually trigger this if the standard is "installed", like with the fixtures these tests use.
224- */
225-
226- $ exclusions = [];
227- $ exclude = [
196+ $ exclude = [
228197 'TestStandard.Deprecated.WithLongReplacement ' ,
229198 'TestStandard.Deprecated.WithoutReplacement ' ,
230199 'TestStandard.Deprecated.WithReplacement ' ,
231200 'TestStandard.Deprecated.WithReplacementContainingLinuxNewlines ' ,
232201 'TestStandard.Deprecated.WithReplacementContainingNewlines ' ,
233202 ];
234- foreach ($ exclude as $ sniffCode ) {
235- $ parts = explode ('. ' , strtolower ($ sniffCode ));
236- $ sniffName = $ parts [0 ].'\\sniffs \\' .$ parts [1 ].'\\' .$ parts [2 ].'sniff ' ;
237- $ exclusions [strtolower ($ sniffName )] = true ;
238- }
239-
240- $ sniffFiles = [];
241- $ allSniffs = $ ruleset ->sniffCodes ;
242- foreach ($ allSniffs as $ sniffName ) {
243- $ sniffFile = str_replace ('\\' , DIRECTORY_SEPARATOR , $ sniffName );
244- $ sniffFile = __DIR__ .DIRECTORY_SEPARATOR .$ sniffFile .'.php ' ;
245- $ sniffFiles [] = $ sniffFile ;
246- }
247-
248- $ ruleset ->registerSniffs ($ sniffFiles , [], $ exclusions );
249- $ ruleset ->populateTokenListeners ();
203+ $ cliArgs = [
204+ '. ' ,
205+ "--standard= $ standard " ,
206+ '--exclude= ' .implode (', ' , $ exclude ),
207+ ];
208+ $ config = new ConfigDouble ($ cliArgs );
209+ $ ruleset = new Ruleset ($ config );
250210
251211 $ this ->expectOutputString ('' );
252212
0 commit comments