File tree Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1010
1111namespace PHPCSDebug \Tests \Debug ;
1212
13+ use PHP_CodeSniffer \Util \Common ;
1314use PHPCSUtils \TestUtils \UtilityMethodTestCase ;
1415
1516/**
@@ -115,6 +116,17 @@ public function testOutput()
115116 $ this ->expectOutputString ($ expected );
116117 $ this ->setOutputCallback ([$ this , 'normalizeLineEndings ' ]);
117118
119+ if (empty ($ this ->ruleset ->tokenListeners )) {
120+ // PHPCSUtils 1.0.9+.
121+ $ sniffFile = \dirname (\dirname (__DIR__ )) . \DIRECTORY_SEPARATOR . 'Sniffs ' ;
122+ $ sniffFile .= \DIRECTORY_SEPARATOR . 'Debug ' . \DIRECTORY_SEPARATOR . 'TokenListSniff.php ' ;
123+ $ sniffClassName = Common::cleanSniffClass ('PHPCSDebug \\Sniffs \\Debug \\TokenListSniff ' );
124+
125+ $ restrictions = [\strtolower ($ sniffClassName ) => true ];
126+ self ::$ phpcsFile ->ruleset ->registerSniffs ([$ sniffFile ], $ restrictions , []);
127+ self ::$ phpcsFile ->ruleset ->populateTokenListeners ();
128+ }
129+
118130 self ::$ phpcsFile ->process ();
119131 }
120132
Original file line number Diff line number Diff line change 1010
1111namespace PHPCSDebug \Tests \Debug ;
1212
13+ use PHP_CodeSniffer \Util \Common ;
1314use PHPCSUtils \TestUtils \UtilityMethodTestCase ;
1415
1516/**
@@ -135,6 +136,17 @@ public function testOutput()
135136 $ this ->expectOutputString ($ expected );
136137 $ this ->setOutputCallback ([$ this , 'normalizeLineEndings ' ]);
137138
139+ if (empty ($ this ->ruleset ->tokenListeners )) {
140+ // PHPCSUtils 1.0.9+.
141+ $ sniffFile = \dirname (\dirname (__DIR__ )) . \DIRECTORY_SEPARATOR . 'Sniffs ' ;
142+ $ sniffFile .= \DIRECTORY_SEPARATOR . 'Debug ' . \DIRECTORY_SEPARATOR . 'TokenListSniff.php ' ;
143+ $ sniffClassName = Common::cleanSniffClass ('PHPCSDebug \\Sniffs \\Debug \\TokenListSniff ' );
144+
145+ $ restrictions = [\strtolower ($ sniffClassName ) => true ];
146+ self ::$ phpcsFile ->ruleset ->registerSniffs ([$ sniffFile ], $ restrictions , []);
147+ self ::$ phpcsFile ->ruleset ->populateTokenListeners ();
148+ }
149+
138150 self ::$ phpcsFile ->process ();
139151 }
140152
Original file line number Diff line number Diff line change 1010
1111namespace PHPCSDebug \Tests \Debug ;
1212
13+ use PHP_CodeSniffer \Util \Common ;
1314use PHPCSUtils \TestUtils \UtilityMethodTestCase ;
1415
1516/**
@@ -108,6 +109,17 @@ public function testOutput()
108109 $ this ->expectOutputString ($ expected );
109110 $ this ->setOutputCallback ([$ this , 'normalizeLineEndings ' ]);
110111
112+ if (empty ($ this ->ruleset ->tokenListeners )) {
113+ // PHPCSUtils 1.0.9+.
114+ $ sniffFile = \dirname (\dirname (__DIR__ )) . \DIRECTORY_SEPARATOR . 'Sniffs ' ;
115+ $ sniffFile .= \DIRECTORY_SEPARATOR . 'Debug ' . \DIRECTORY_SEPARATOR . 'TokenListSniff.php ' ;
116+ $ sniffClassName = Common::cleanSniffClass ('PHPCSDebug \\Sniffs \\Debug \\TokenListSniff ' );
117+
118+ $ restrictions = [\strtolower ($ sniffClassName ) => true ];
119+ self ::$ phpcsFile ->ruleset ->registerSniffs ([$ sniffFile ], $ restrictions , []);
120+ self ::$ phpcsFile ->ruleset ->populateTokenListeners ();
121+ }
122+
111123 self ::$ phpcsFile ->process ();
112124 }
113125
Original file line number Diff line number Diff line change 7373 die (1 );
7474}
7575
76+ $ installedStandards = \PHP_CodeSniffer \Util \Standards::getInstalledStandardDetails ();
77+ foreach ($ installedStandards as $ details ) {
78+ \PHP_CodeSniffer \Autoload::addSearchPath ($ details ['path ' ], $ details ['namespace ' ]);
79+ }
80+
7681// Try and load the PHPCSUtils autoloader.
7782if ($ phpcsUtilsDir !== false && \file_exists ($ phpcsUtilsDir . $ ds . 'phpcsutils-autoload.php ' )) {
7883 require_once $ phpcsUtilsDir . $ ds . 'phpcsutils-autoload.php ' ;
You can’t perform that action at this time.
0 commit comments