2
2
import re
3
3
import sys
4
4
import sublime
5
- from unittest import TestCase
6
5
6
+ from unittest import TestCase
7
+ from unittest .mock import patch
7
8
8
9
from Phpcs .phpcs import Sniffer
9
10
10
11
11
- class TestDiffViewInternalFunctions (TestCase ):
12
+ class TestSniffer (TestCase ):
12
13
def test_we_can_build_up_the_correct_executable_string_when_we_prefix (self ):
13
- php_path = "/bin/php"
14
+ php_path = "/opt/homebrew/ bin/php"
14
15
s = sublime .load_settings ("phpcs.sublime-settings" )
15
16
16
17
s .set ("phpcs_php_prefix_path" , php_path )
@@ -22,9 +23,20 @@ def test_we_can_build_up_the_correct_executable_string_when_we_prefix(self):
22
23
def test_we_can_build_up_the_correct_executable_string_when_we_dont_prefix (self ):
23
24
s = sublime .load_settings ("phpcs.sublime-settings" )
24
25
25
- s .set ("phpcs_php_prefix_path" , "/bin/php" )
26
+ s .set ("phpcs_php_prefix_path" , "/opt/homebrew/ bin/php" )
26
27
s .set ("phpcs_commands_to_php_prefix" , "" )
27
28
s .set ("phpcs_executable_path" , "" )
28
29
29
30
args = Sniffer ().get_executable_args ()
30
31
self .assertIn ("phpcs" , args )
32
+
33
+ @patch ("Phpcs.phpcs.Sniffer.shell_out" )
34
+ def test_we_can_parse_phpcs_standards_output (self , shell_mock ):
35
+ shell_mock .return_value = (
36
+ "The installed coding standards are One, NeutronStandard, Two and Three"
37
+ )
38
+ standards = Sniffer ().get_standards_available ()
39
+
40
+ expected = ["One" , "NeutronStandard" , "Two" , "Three" ]
41
+
42
+ self .assertEqual (expected , standards )
0 commit comments