Completed
Pull Request — master (#1109)
by Abdeali
02:49
created

bears.tests.linters.PHPLintBearTest.setUp()   A

Complexity

Conditions 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 9
rs 9.6667
1
import os
2
import subprocess
3
import sys
4
from queue import Queue
5
6
sys.path.insert(0, ".")
7
import unittest
8
from bears.tests.LocalBearTestHelper import LocalBearTestHelper
9
from bears.linters.PHPLintBear import PHPLintBear
10
from coalib.settings.Section import Section
11
12
13
class PHPLintBearTest(LocalBearTestHelper):
14
    def setUp(self):
15
        self.section = Section("test section")
16
        self.uut = PHPLintBear(self.section, Queue())
17
        self.test_file1 = os.path.join(os.path.dirname(__file__),
18
                                       "test_files",
19
                                       "phplint_test1.php")
20
        self.test_file2 = os.path.join(os.path.dirname(__file__),
21
                                       "test_files",
22
                                       "phplint_test2.php")
23
24
    def test_run(self):
25
        # Test a file with errors and warnings
26
        self.assertLinesInvalid(
27
            self.uut,
28
            [],
29
            self.test_file1)
30
31
        # Test a file without any issues
32
        self.assertLinesValid(
33
            self.uut,
34
            [],
35
            self.test_file2)
36
37
38
def skip_test():
39
    try:
40
        subprocess.Popen(['php', '--version'],
41
                         stdout=subprocess.PIPE,
42
                         stderr=subprocess.PIPE)
43
        return False
44
    except OSError:
45
        return "PHP is not installed."
46
47
48
if __name__ == '__main__':
49
    unittest.main(verbosity=2)
50