@@ -37,12 +37,13 @@ class MissingDocblockSniffTest extends MoodleCSBaseTestCase
3737 */
3838 public function testMissingDocblockSniff (
3939 string $ fixture ,
40+ ?string $ fixtureFilename ,
4041 array $ errors ,
4142 array $ warnings
4243 ): void {
4344 $ this ->setStandard ('moodle ' );
4445 $ this ->setSniff ('moodle.Commenting.MissingDocblock ' );
45- $ this ->setFixture (sprintf ("%s/fixtures/%s.php " , __DIR__ , $ fixture ));
46+ $ this ->setFixture (sprintf ("%s/fixtures/MissingDocblock/ %s.php " , __DIR__ , $ fixture ), $ fixtureFilename );
4647 $ this ->setWarnings ($ warnings );
4748 $ this ->setErrors ($ errors );
4849 $ this ->setComponentMapping ([
@@ -55,9 +56,10 @@ public function testMissingDocblockSniff(
5556 public static function docblockCorrectnessProvider (): array {
5657 $ cases = [
5758 'Multiple artifacts in a file ' => [
58- 'fixture ' => 'missing_docblock_multiple_artifacts ' ,
59+ 'fixture ' => 'multiple_artifacts ' ,
60+ 'fixtureFilename ' => null ,
5961 'errors ' => [
60- 1 => 'Missing docblock for file missing_docblock_multiple_artifacts .php ' ,
62+ 1 => 'Missing docblock for file multiple_artifacts .php ' ,
6163 34 => 'Missing docblock for function missing_docblock_in_function ' ,
6264 38 => 'Missing docblock for class missing_docblock_in_class ' ,
6365 95 => 'Missing docblock for interface missing_docblock_interface ' ,
@@ -74,96 +76,80 @@ public static function docblockCorrectnessProvider(): array {
7476 ],
7577 ],
7678 'File level tag, no class ' => [
77- 'fixture ' => 'missing_docblock_class_without_docblock ' ,
79+ 'fixture ' => 'class_without_docblock ' ,
80+ 'fixtureFilename ' => null ,
7881 'errors ' => [
7982 11 => 'Missing docblock for class class_without_docblock ' ,
8083 ],
8184 'warnings ' => [],
8285 ],
8386 'Class only (incorrect whitespace) ' => [
84- 'fixture ' => 'missing_docblock_class_only_with_incorrect_whitespace ' ,
87+ 'fixture ' => 'class_only_with_incorrect_whitespace ' ,
88+ 'fixtureFilename ' => null ,
8589 'errors ' => [
8690 11 => 'Missing docblock for class class_only_with_incorrect_whitespace ' ,
8791 ],
8892 'warnings ' => [],
8993 ],
9094 'Class only (correct) ' => [
91- 'fixture ' => 'missing_docblock_class_only ' ,
95+ 'fixture ' => 'class_only ' ,
96+ 'fixtureFilename ' => null ,
9297 'errors ' => [],
9398 'warnings ' => [],
9499 ],
95100 'Class only with attributes (correct) ' => [
96- 'fixture ' => 'missing_docblock_class_only_with_attributes ' ,
101+ 'fixture ' => 'class_only_with_attributes ' ,
102+ 'fixtureFilename ' => null ,
97103 'errors ' => [],
98104 'warnings ' => [],
99105 ],
100106 'Class only with attributes and incorrect whitespace ' => [
101- 'fixture ' => 'missing_docblock_class_only_with_attributes_incorrect_whitespace ' ,
107+ 'fixture ' => 'class_only_with_attributes_incorrect_whitespace ' ,
108+ 'fixtureFilename ' => null ,
102109 'errors ' => [
103110 13 => 'Missing docblock for class class_only_with_attributes_incorrect_whitespace ' ,
104111 ],
105112 'warnings ' => [],
106113 ],
107114 'Class and file (correct) ' => [
108- 'fixture ' => 'missing_docblock_class_and_file ' ,
115+ 'fixture ' => 'class_and_file ' ,
116+ 'fixtureFilename ' => null ,
109117 'errors ' => [],
110118 'warnings ' => [],
111119 ],
112120 'Interface only (correct) ' => [
113- 'fixture ' => 'missing_docblock_interface_only ' ,
121+ 'fixture ' => 'interface_only ' ,
122+ 'fixtureFilename ' => null ,
114123 'errors ' => [],
115124 'warnings ' => [],
116125 ],
117126 'Trait only (correct) ' => [
118- 'fixture ' => 'missing_docblock_trait_only ' ,
127+ 'fixture ' => 'trait_only ' ,
128+ 'fixtureFilename ' => null ,
119129 'errors ' => [],
120130 'warnings ' => [],
121131 ],
132+ 'Testcase ' => [
133+ 'fixture ' => 'testcase_class ' ,
134+ 'fixtureFilename ' => '/lib/tests/example_test.php ' ,
135+ 'errors ' => [
136+ 3 => 'Missing docblock for class example_test ' ,
137+ ],
138+ 'warnings ' => [
139+ 12 => 'Missing docblock for function test_the_thing ' ,
140+ ],
141+ ],
122142 ];
123143
124144 if (version_compare (PHP_VERSION , '8.1.0 ' ) >= 0 ) {
125145 $ cases ['Enum only (correct) ' ] = [
126- 'fixture ' => 'missing_docblock_enum_only ' ,
146+ 'fixture ' => 'enum_only ' ,
147+ 'fixtureFilename ' => null ,
127148 'errors ' => [],
128149 'warnings ' => [],
129150 ];
130151 }
131152
132153 return $ cases ;
133154 }
134-
135- public function testMissingDocblockSniffWithTest (): void {
136- $ content = <<<EOF
137- phpcs_input_file: /lib/tests/example_test.php
138- <?php
139-
140- class example_test extends advanced_testcase {
141- public function setUp(): void {
142- }
143- public function tearDown(): void {
144- }
145- public static function setUpBeforeClass(): void {
146- }
147- public static function tearDownAfterClass(): void {
148- }
149- public function test_the_thing(): void {
150- }
151- }
152- EOF ;
153-
154- $ this ->setStandard ('moodle ' );
155- $ this ->setSniff ('moodle.Commenting.MissingDocblock ' );
156- $ this ->setFixtureFileContent ($ content );
157- $ this ->setWarnings ([
158- 12 => 'Missing docblock for function test_the_thing ' ,
159- ]);
160- $ this ->setErrors ([
161- 3 => 'Missing docblock for class example_test ' ,
162- ]);
163- $ this ->setComponentMapping ([
164- 'local_codechecker ' => dirname (__DIR__ ),
165- ]);
166-
167- $ this ->verifyCsResults ();
168- }
169155}
0 commit comments