Passed
Pull Request — master (#183)
by Xaver
03:55
created

ConstantSpacingUnitTest::getErrorList()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 24
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 3
eloc 19
c 1
b 1
f 0
nc 3
nop 1
dl 0
loc 24
rs 9.6333
1
<?php
2
3
/**
4
 * This file is part of the mo4-coding-standard (phpcs standard)
5
 *
6
 * @author  Xaver Loppenstedt <[email protected]>
7
 *
8
 * @license http://spdx.org/licenses/MIT MIT License
9
 *
10
 * @link    https://github.com/mayflower/mo4-coding-standard
11
 */
12
13
declare(strict_types=1);
14
15
namespace MO4\Tests\WhiteSpace;
16
17
use PHP_CodeSniffer\Exceptions\RuntimeException;
18
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
19
20
/**
21
 * Unit test class for the VariableInDoubleQuotedString sniff.
22
 *
23
 * A sniff unit test checks a .inc file for expected violations of a single
24
 * coding standard. Expected errors and warnings are stored in this class.
25
 *
26
 * @author    Xaver Loppenstedt <[email protected]>
27
 *
28
 * @copyright 2013-2021 Xaver Loppenstedt, some rights reserved.
29
 *
30
 * @license   http://spdx.org/licenses/MIT MIT License
31
 *
32
 * @link      https://github.com/mayflower/mo4-coding-standard
33
 */
34
class ConstantSpacingUnitTest extends AbstractSniffUnitTest
35
{
36
    /**
37
     * Returns the lines where errors should occur.
38
     *
39
     * The key of the array should represent the line number and the value
40
     * should represent the number of errors that should occur on that line.
41
     *
42
     * @param string $testFile test file
43
     *
44
     * @return array<int, int>
45
     *
46
     * @throws RuntimeException
47
     */
48
    protected function getErrorList(string $testFile = ''): array
49
    {
50
        switch ($testFile) {
51
            case 'ConstantSpacingUnitTest.pass.inc':
52
                return [];
53
            case 'ConstantSpacingUnitTest.fail.inc':
54
                return [
55
                    4  => 1,
56
                    5  => 1,
57
                    6  => 1,
58
                    10 => 1,
59
                    12 => 1,
60
                    13 => 1,
61
                    14 => 1,
62
                    15 => 1,
63
                    18 => 1,
64
                    22 => 1,
65
                    23 => 1,
66
                    24 => 1,
67
                ];
68
        }
69
70
        throw new RuntimeException(
71
            \sprintf('%s%s is not handled by %s', \sprintf('Testfile %s in ', $testFile), __DIR__, self::class)
72
        );
73
    }
74
75
    /**
76
     * Returns the lines where warnings should occur.
77
     *
78
     * The key of the array should represent the line number and the value
79
     * should represent the number of warnings that should occur on that line.
80
     *
81
     * @return array<int, int>
82
     */
83
    protected function getWarningList(): array
84
    {
85
        return [];
86
    }
87
}
88