22import re
33import sys
44import sublime
5- from unittest import TestCase
65
6+ from unittest import TestCase
7+ from unittest .mock import patch
78
89from Phpcs .phpcs import Sniffer
910
1011
11- class TestDiffViewInternalFunctions (TestCase ):
12+ class TestSniffer (TestCase ):
1213 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"
1415 s = sublime .load_settings ("phpcs.sublime-settings" )
1516
1617 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):
2223 def test_we_can_build_up_the_correct_executable_string_when_we_dont_prefix (self ):
2324 s = sublime .load_settings ("phpcs.sublime-settings" )
2425
25- s .set ("phpcs_php_prefix_path" , "/bin/php" )
26+ s .set ("phpcs_php_prefix_path" , "/opt/homebrew/ bin/php" )
2627 s .set ("phpcs_commands_to_php_prefix" , "" )
2728 s .set ("phpcs_executable_path" , "" )
2829
2930 args = Sniffer ().get_executable_args ()
3031 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