UnnecessaryNamespaceUsageUnitTest   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 10
lcom 0
cbo 2
dl 0
loc 83
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrorList() 0 5 1
C getWarningList() 0 48 9
1
<?php
2
3
/**
4
 * This file is part of the mo4-coding-standard (phpcs standard)
5
 *
6
 * PHP version 5
7
 *
8
 * @category PHP
9
 * @package  PHP_CodeSniffer-MO4
10
 * @author   Xaver Loppenstedt <[email protected]>
11
 * @license  http://spdx.org/licenses/MIT MIT License
12
 * @version  GIT: master
13
 * @link     https://github.com/Mayflower/mo4-coding-standard
14
 */
15
16
namespace MO4\Tests\Formatting;
17
18
use PHP_CodeSniffer\Exceptions\RuntimeException;
19
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
20
21
/**
22
 * Unit test class for the UnnecessaryNamespaceUsageUnitTest sniff.
23
 *
24
 * A sniff unit test checks a .inc file for expected violations of a single
25
 * coding standard. Expected errors and warnings are stored in this class.
26
 *
27
 * @category  PHP
28
 * @package   PHP_CodeSniffer-MO4
29
 * @author    Xaver Loppenstedt <[email protected]>
30
 * @author    Marco Jantke <[email protected]>
31
 * @author    Steffen Ritter <[email protected]>
32
 * @copyright 2013 Xaver Loppenstedt, some rights reserved.
33
 * @license   http://spdx.org/licenses/MIT MIT License
34
 * @link      https://github.com/Mayflower/mo4-coding-standard
35
 */
36
class UnnecessaryNamespaceUsageUnitTest extends AbstractSniffUnitTest
37
{
38
39
40
    /**
41
     * Returns the lines where errors should occur.
42
     *
43
     * The key of the array should represent the line number and the value
44
     * should represent the number of errors that should occur on that line.
45
     *
46
     * @param string $testFile test file
47
     *
48
     * @return array<int, int>
0 ignored issues
show
Documentation introduced by
The doc-type array<int, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
49
     */
50
    protected function getErrorList($testFile='')
51
    {
52
        return array();
53
54
    }//end getErrorList()
55
56
57
    /**
58
     * Returns the lines where warnings should occur.
59
     *
60
     * The key of the array should represent the line number and the value
61
     * should represent the number of warnings that should occur on that line.
62
     *
63
     * @param string $testFile test file
64
     *
65
     * @return array<int, int>
0 ignored issues
show
Documentation introduced by
The doc-type array<int, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
66
     * @throws RuntimeException
67
     */
68
    protected function getWarningList($testFile='')
69
    {
70
        switch ($testFile) {
71
        case 'UnnecessaryNamespaceUsageUnitTest.pass.1.inc':
72
        case 'UnnecessaryNamespaceUsageUnitTest.pass.2.inc':
73
        case 'UnnecessaryNamespaceUsageUnitTest.pass.3.inc':
74
        case 'UnnecessaryNamespaceUsageUnitTest.pass.4.inc':
75
            return array();
76
        case 'UnnecessaryNamespaceUsageUnitTest.fail.1.inc':
77
            return array(
78
                    17 => 1,
79
                    19 => 1,
80
                    24 => 1,
81
                    25 => 1,
82
                    26 => 2,
83
                    28 => 1,
84
                    30 => 2,
85
                    32 => 1,
86
                    33 => 1,
87
                    40 => 1,
88
                    44 => 1,
89
                    45 => 1,
90
                    46 => 1,
91
                    52 => 1,
92
                    56 => 1,
93
                   );
94
        case 'UnnecessaryNamespaceUsageUnitTest.fail.2.inc':
95
            return array(
96
                    10 => 1,
97
                    11 => 1,
98
                   );
99
        case 'UnnecessaryNamespaceUsageUnitTest.fail.3.inc':
100
            return array(
101
                    15 => 1,
102
                    16 => 1,
103
                    17 => 1,
104
                    18 => 1,
105
                    22 => 1,
106
                    23 => 1,
107
                    25 => 3,
108
                   );
109
        case 'UnnecessaryNamespaceUsageUnitTest.fail.4.inc':
110
            return array();
111
        }//end switch
112
113
        throw new RuntimeException("Testfile {$testFile} in ".__DIR__." is not handled by ".__CLASS__);
114
115
    }//end getWarningList()
116
117
118
}//end class
119