def test_create_command__with_path_based_standard(self): config = {'standard': 'test/CodeStandards'} tool = Phpcs(self.problems, config, '/some/path') result = tool.create_command(['some/file.php']) expected = [ 'phpcs', '--report=checkstyle', '--standard=/some/path/test/CodeStandards', '--extensions=php', 'some/file.php' ] eq_(result, expected)
def test_create_command__with_builtin_standard(self): config = { 'standard': 'Zend', 'tab_width': 4, } tool = Phpcs(self.problems, config, root_dir) result = tool.create_command(['some/file.php']) expected = [ 'phpcs', '--report=checkstyle', '--standard=Zend', '--extensions=php', '--tab-width=4', '/src/some/file.php' ] self.assertEqual(result, expected)
def test_create_command__with_path_based_standard(self): config = {"standard": "test/CodeStandards"} tool = Phpcs(self.problems, config, "/some/path") result = tool.create_command(["some/file.php"]) expected = [ "phpcs", "--report=checkstyle", "--standard=/some/path/test/CodeStandards", "--extensions=php", "some/file.php", ] eq_(result, expected)
def test_create_command__with_path_based_standard(self): config = { 'standard': 'test/CodeStandards' } tool = Phpcs(self.problems, config, '/some/path') result = tool.create_command(['some/file.php']) expected = [ 'phpcs', '--report=checkstyle', '--standard=/some/path/test/CodeStandards', '--extensions=php', 'some/file.php' ] eq_(result, expected)
def test_create_command__with_builtin_standard(self): command = 'vendor/bin/phpcs' if phpcs_missing: command = 'phpcs' config = { 'standard': 'Zend', 'tab_width': 4, } tool = Phpcs(self.problems, config, '/some/path') result = tool.create_command(['some/file.php']) expected = [ command, '--report=checkstyle', '--standard=Zend', '--extensions=php', '--tab-width=4', 'some/file.php' ] eq_(result, expected)
def test_create_command__ignore_option_as_list(self): config = { 'standard': 'PSR2', 'extensions': ['php', 'ctp'], 'exclude': ['rule1', 'rule2'], 'ignore': ['tests/fixtures/phpcs/*', 'tests/fixtures/eslint/*'] } tool = Phpcs(self.problems, config, root_dir) result = tool.create_command(['some/file.php']) expected = [ 'phpcs', '--report=checkstyle', '--standard=PSR2', '--ignore=tests/fixtures/phpcs/*,tests/fixtures/eslint/*', '--exclude=rule1,rule2', '--extensions=php,ctp', '/src/some/file.php' ] self.assertEqual(result, expected)
def test_create_command__with_path_based_standard(self): config = { 'standard': 'test/CodeStandards', 'tab_width': 4, } tool = Phpcs(self.problems, config, root_dir) result = tool.create_command(['some/file.php']) expected = [ 'phpcs', '--report=checkstyle', '--standard=/src/test/CodeStandards', '--extensions=php', '--tab-width=4', '/src/some/file.php' ] self.assertEqual(result, expected)
def test_create_command__ignore_option_as_list(self): config = { 'standard': 'PSR2', 'extensions': ['php', 'ctp'], 'exclude': ['rule1', 'rule2'], 'ignore': ['tests/fixtures/phpcs/*', 'tests/fixtures/eslint/*'] } tool = Phpcs(self.problems, config) result = tool.create_command(['some/file.php']) command = 'vendor/bin/phpcs' if phpcs_missing: command = 'phpcs' expected = [ command, '--report=checkstyle', '--standard=PSR2', '--ignore=tests/fixtures/phpcs/*,tests/fixtures/eslint/*', '--exclude=rule1,rule2', '--extensions=php,ctp', 'some/file.php' ] eq_(result, expected)
def test_create_command__with_path_based_standard(self): command = 'vendor/bin/phpcs' if phpcs_missing: command = 'phpcs' config = { 'standard': 'test/CodeStandards', 'tab_width': 4, } tool = Phpcs(self.problems, config, '/some/path') result = tool.create_command(['some/file.php']) expected = [ command, '--report=checkstyle', '--standard=/some/path/test/CodeStandards', '--extensions=php', '--tab-width=4', 'some/file.php' ] eq_(result, expected)