1818 */
1919abstract class AbstractSniffTest extends TestCase
2020{
21- /**
22- * @var StubbedEnvironment
23- */
24- private $ env ;
25-
26- /**
27- * @var Linter
28- */
29- private $ lint ;
30-
31- public function setUp ()
32- {
33- $ this ->env = new StubbedEnvironment ();
34- $ this ->lint = new Linter ($ this ->env , new Tokenizer ($ this ->env ));
35- }
36-
3721 /**
3822 * Should call $this->checkGenericSniff(new Sniff(), [...]);
3923 */
@@ -45,16 +29,18 @@ abstract public function testSniff();
4529 */
4630 protected function checkGenericSniff (SniffInterface $ sniff , array $ expects )
4731 {
32+ $ env = new StubbedEnvironment ();
33+ $ tokenizer = new Tokenizer ($ env );
34+ $ linter = new Linter ($ env , $ tokenizer );
4835 $ ruleset = new Ruleset ();
49- $ fixer = new Fixer ($ ruleset , new Tokenizer ($ this ->env ));
5036
5137 try {
5238 $ class = new ReflectionClass (get_called_class ());
5339 $ className = $ class ->getShortName ();
5440 $ file = __DIR__ .'/Fixtures/ ' .$ className .'.twig ' ;
5541
5642 $ ruleset ->addSniff ($ sniff );
57- $ report = $ this -> lint ->run ([$ file ], $ ruleset );
43+ $ report = $ linter ->run ([$ file ], $ ruleset );
5844 } catch (Exception $ e ) {
5945 $ this ->fail ($ e ->getMessage ());
6046
@@ -75,6 +61,7 @@ protected function checkGenericSniff(SniffInterface $sniff, array $expects)
7561
7662 $ fixedFile = __DIR__ .'/Fixtures/ ' .$ className .'.fixed.twig ' ;
7763 if (file_exists ($ fixedFile )) {
64+ $ fixer = new Fixer ($ ruleset , $ tokenizer );
7865 $ sniff ->enableFixer ($ fixer );
7966 $ fixer ->fixFile ($ file );
8067
0 commit comments