9
9
10
10
namespace PHP_CodeSniffer \Standards \Generic \Tests \Files ;
11
11
12
+ use PHP_CodeSniffer \Files \DummyFile ;
13
+ use PHP_CodeSniffer \Ruleset ;
14
+ use PHP_CodeSniffer \Tests \ConfigDouble ;
12
15
use PHP_CodeSniffer \Tests \Standards \AbstractSniffUnitTest ;
13
16
14
17
/**
@@ -20,6 +23,24 @@ final class LowercasedFilenameUnitTest extends AbstractSniffUnitTest
20
23
{
21
24
22
25
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
+
23
44
/**
24
45
* Returns the lines where errors should occur.
25
46
*
@@ -58,4 +79,28 @@ public function getWarningList()
58
79
}//end getWarningList()
59
80
60
81
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
+
61
106
}//end class
0 commit comments