Skip to content

Commit 625975c

Browse files
authored
Merge pull request #242 from rodrigoprimo/test-coverage-doc-comment
Generic/DocComment: improve code coverage
2 parents c4e51d8 + 91cc7bb commit 625975c

File tree

7 files changed

+129
-52
lines changed

7 files changed

+129
-52
lines changed

src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc renamed to src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,12 @@
259259
* @return void
260260
*/
261261

262-
/** No docblock close tag. Must be last test without new line.
262+
// Tests to check handling empty doc comments.
263+
/**
264+
*/
265+
266+
/**
267+
*
268+
*
269+
*
270+
*/

src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc.fixed renamed to src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc.fixed

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,12 @@
264264
* @return void
265265
*/
266266

267-
/** No docblock close tag. Must be last test without new line.
267+
// Tests to check handling empty doc comments.
268+
/**
269+
*/
270+
271+
/**
272+
*
273+
*
274+
*
275+
*/

src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js renamed to src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,23 @@
248248
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
249249
* @link http://pear.php.net/package/PHP_CodeSniffer
250250
*/
251+
252+
/**
253+
* Do something.
254+
*
255+
* @codeCoverageIgnore
256+
*
257+
* @phpcs:disable Stnd.Cat.SniffName
258+
*
259+
* @return void
260+
*/
261+
262+
// Tests to check handling empty doc comments.
263+
/**
264+
*/
265+
266+
/**
267+
*
268+
*
269+
*
270+
*/

src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js.fixed renamed to src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,23 @@
253253
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
254254
* @link http://pear.php.net/package/PHP_CodeSniffer
255255
*/
256+
257+
/**
258+
* Do something.
259+
*
260+
* @codeCoverageIgnore
261+
*
262+
* @phpcs:disable Stnd.Cat.SniffName
263+
*
264+
* @return void
265+
*/
266+
267+
// Tests to check handling empty doc comments.
268+
/**
269+
*/
270+
271+
/**
272+
*
273+
*
274+
*
275+
*/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
// Intentional parse error. Testing that the sniff is *not* triggered
4+
// in this case
5+
6+
/** No docblock close tag. Must be last test without new line.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Intentional parse error. Testing that the sniff is *not* triggered
2+
// in this case
3+
4+
/** No docblock close tag. Must be last test without new line.

src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php

Lines changed: 61 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -41,59 +41,70 @@ public function setCliValues($testFile, $config)
4141
* The key of the array should represent the line number and the value
4242
* should represent the number of errors that should occur on that line.
4343
*
44+
* @param string $testFile The name of the file being tested.
45+
*
4446
* @return array(int => int)
4547
*/
46-
public function getErrorList()
48+
public function getErrorList($testFile='')
4749
{
48-
return [
49-
14 => 1,
50-
16 => 1,
51-
18 => 1,
52-
23 => 1,
53-
26 => 1,
54-
30 => 1,
55-
32 => 1,
56-
38 => 2,
57-
40 => 1,
58-
41 => 1,
59-
51 => 1,
60-
54 => 1,
61-
58 => 1,
62-
60 => 2,
63-
67 => 1,
64-
69 => 2,
65-
80 => 1,
66-
81 => 2,
67-
88 => 1,
68-
91 => 1,
69-
95 => 1,
70-
156 => 1,
71-
158 => 1,
72-
170 => 3,
73-
171 => 3,
74-
179 => 1,
75-
183 => 1,
76-
184 => 2,
77-
185 => 1,
78-
186 => 1,
79-
187 => 2,
80-
193 => 1,
81-
196 => 1,
82-
199 => 1,
83-
203 => 1,
84-
206 => 1,
85-
211 => 1,
86-
214 => 4,
87-
218 => 1,
88-
220 => 2,
89-
222 => 1,
90-
224 => 3,
91-
243 => 1,
92-
244 => 1,
93-
246 => 1,
94-
248 => 1,
95-
249 => 1,
96-
];
50+
switch ($testFile) {
51+
case 'DocCommentUnitTest.1.inc':
52+
case 'DocCommentUnitTest.1.js':
53+
return [
54+
14 => 1,
55+
16 => 1,
56+
18 => 1,
57+
23 => 1,
58+
26 => 1,
59+
30 => 1,
60+
32 => 1,
61+
38 => 2,
62+
40 => 1,
63+
41 => 1,
64+
51 => 1,
65+
54 => 1,
66+
58 => 1,
67+
60 => 2,
68+
67 => 1,
69+
69 => 2,
70+
80 => 1,
71+
81 => 2,
72+
88 => 1,
73+
91 => 1,
74+
95 => 1,
75+
156 => 1,
76+
158 => 1,
77+
170 => 3,
78+
171 => 3,
79+
179 => 1,
80+
183 => 1,
81+
184 => 2,
82+
185 => 1,
83+
186 => 1,
84+
187 => 2,
85+
193 => 1,
86+
196 => 1,
87+
199 => 1,
88+
203 => 1,
89+
206 => 1,
90+
211 => 1,
91+
214 => 4,
92+
218 => 1,
93+
220 => 2,
94+
222 => 1,
95+
224 => 3,
96+
243 => 1,
97+
244 => 1,
98+
246 => 1,
99+
248 => 1,
100+
249 => 1,
101+
263 => 1,
102+
266 => 1,
103+
];
104+
105+
default:
106+
return [];
107+
}//end switch
97108

98109
}//end getErrorList()
99110

0 commit comments

Comments
 (0)