Passed
Pull Request — master (#178)
by Michael
11:59 queued 09:25
created

MultipleEmptyLinesUnitTest::getWarningList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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 MultipleEmptyLines 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 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 MultipleEmptyLinesUnitTest 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 'MultipleEmptyLinesUnitTest.pass.inc':
52
                return [];
53
            case 'MultipleEmptyLinesUnitTest.fail.inc':
54
                return [
55
                    2  => 1,
56
                    14 => 1,
57
                    21 => 1,
58
                    24 => 1,
59
                    29 => 1,
60
                ];
61
        }
62
63
        throw new RuntimeException(
64
            \sprintf('%s%s is not handled by %s', \sprintf('Testfile %s in ', $testFile), __DIR__, self::class)
65
        );
66
    }
67
68
    /**
69
     * Returns the lines where warnings should occur.
70
     *
71
     * The key of the array should represent the line number and the value
72
     * should represent the number of warnings that should occur on that line.
73
     *
74
     * @return array<int, int>
75
     */
76
    protected function getWarningList(): array
77
    {
78
        return [];
79
    }
80
}
81