Completed
Push — master ( 514dbf...ba76d3 )
by Wim
11s
created

BaseClass_MethodTestFrame   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 69
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Base class to use when testing methods in the Sniff.php file.
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
if (class_exists('BaseSniffTest', true) === false) {
9
    require_once dirname(dirname(__FILE__)) . '/BaseSniffTest.php';
10
}
11
12
/**
13
 * Set up and Tear down methods for testing methods in the Sniff.php file.
14
 *
15
 * @uses    BaseSniffTest
16
 * @package PHPCompatibility
17
 */
18
abstract class BaseClass_MethodTestFrame extends BaseSniffTest
19
{
20
21
    public $filename;
22
23
    /**
24
     * The PHP_CodeSniffer_File object containing parsed contents of this file.
25
     *
26
     * @var PHP_CodeSniffer_File
27
     */
28
    protected $_phpcsFile;
29
30
    /**
31
     * A wrapper for the abstract PHPCompatibility sniff.
32
     *
33
     * @var PHPCompatibility_Sniff
34
     */
35
    protected $helperClass;
36
37
38
    public static function setUpBeforeClass()
39
    {
40
        require_once dirname(__FILE__) . '/TestHelperPHPCompatibility.php';
41
    }
42
43
    protected function setUp()
44
    {
45
        parent::setUp();
46
47
        $this->helperClass = new BaseClass_TestHelperPHPCompatibility;
48
49
        $filename = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . $this->filename;
50
        $phpcs    = new PHP_CodeSniffer();
51
52
        if (version_compare(PHP_CodeSniffer::VERSION, '2.0', '<')) {
53
            $this->_phpcsFile = new PHP_CodeSniffer_File(
54
                $filename,
55
                array(),
56
                array(),
57
                array(),
58
                array(),
59
                $phpcs
60
            );
61
        }
62
        else {
63
            $this->_phpcsFile = new PHP_CodeSniffer_File(
64
                $filename,
65
                array(),
66
                array(),
67
                $phpcs
68
            );
69
        }
70
71
        $contents = file_get_contents($filename);
72
        $this->_phpcsFile->start($contents);
73
    }
74
75
    /**
76
     * Clean up after finished test.
77
     *
78
     * @return void
79
     */
80
    public function tearDown()
81
    {
82
        unset($this->_phpcsFile, $this->helperClass);
83
84
    }//end tearDown()
85
86
}
87