99
1010namespace PHP_CodeSniffer \Standards \Generic \Tests \Files ;
1111
12+ use PHP_CodeSniffer \Files \DummyFile ;
13+ use PHP_CodeSniffer \Ruleset ;
14+ use PHP_CodeSniffer \Tests \ConfigDouble ;
1215use PHP_CodeSniffer \Tests \Standards \AbstractSniffUnitTest ;
1316
1417/**
@@ -20,6 +23,24 @@ final class LowercasedFilenameUnitTest extends AbstractSniffUnitTest
2023{
2124
2225
26+ /**
27+ * Get a list of all test files to check.
28+ *
29+ * @param string $testFileBase The base path that the unit tests files will have.
30+ *
31+ * @return string[]
32+ */
33+ protected function getTestFiles ($ testFileBase )
34+ {
35+ $ testFileDir = dirname ($ testFileBase );
36+ $ testFiles = parent ::getTestFiles ($ testFileBase );
37+ $ testFiles [] = $ testFileDir .DIRECTORY_SEPARATOR .'lowercased_filename_unit_test.inc ' ;
38+
39+ return $ testFiles ;
40+
41+ }//end getTestFiles()
42+
43+
2344 /**
2445 * Returns the lines where errors should occur.
2546 *
@@ -58,4 +79,28 @@ public function getWarningList()
5879 }//end getWarningList()
5980
6081
82+ /**
83+ * Test the sniff bails early when handling STDIN.
84+ *
85+ * @return void
86+ */
87+ public function testStdIn ()
88+ {
89+ $ config = new ConfigDouble ();
90+ $ config ->standards = ['Generic ' ];
91+ $ config ->sniffs = ['Generic.Files.LowercasedFilename ' ];
92+
93+ $ ruleset = new Ruleset ($ config );
94+
95+ $ content = '<?php ' ;
96+ $ file = new DummyFile ($ content , $ ruleset , $ config );
97+ $ file ->process ();
98+
99+ $ this ->assertSame (0 , $ file ->getErrorCount ());
100+ $ this ->assertSame (0 , $ file ->getWarningCount ());
101+ $ this ->assertCount (0 , $ file ->getErrors ());
102+
103+ }//end testStdIn()
104+
105+
61106}//end class
0 commit comments