]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/linter/test_phpstan.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '56df844d3c39ec494dacc69eae34272b27db185a' as '.vim/bundle/asyncomplete'
[etc/vim.git] / .vim / bundle / ale / test / linter / test_phpstan.vader
1 Before:
2   call ale#assert#SetUpLinterTest('php', 'phpstan')
3
4   let g:old_dir = g:dir
5
6   " Create a temporary directory and work within it, otherwise these tests
7   " cannot be run in parallel.
8   let g:parent_dir = tempname()
9   let g:dir = ale#path#Simplify(g:parent_dir . '/src')
10
11   call mkdir(g:parent_dir, '', 0750)
12   call mkdir(g:dir, '', 0750)
13
14   silent! execute 'cd ' . fnameescape(g:dir)
15   silent! noautocmd execute 'file ' . fnameescape(ale#path#Simplify(g:dir . '/test.php'))
16
17   call delete('./phpstan.neon')
18
19   GivenCommandOutput ['0.10.2']
20
21 After:
22   silent! execute 'cd ' . fnameescape(g:old_dir)
23   call delete(g:dir, 'rf')
24   let g:dir = g:old_dir
25   unlet! g:old_dir
26   call ale#assert#TearDownLinterTest()
27
28 Execute(The local phpstan executable should be used):
29   call mkdir('vendor/bin', 'p', 0750)
30   call writefile([''], 'vendor/bin/phpstan')
31   call ale#test#SetFilename('phpstan-test-files/foo/test.php')
32
33   let g:executable = ale#path#Simplify(g:dir . '/vendor/bin/phpstan')
34
35   AssertLinter g:executable,
36   \ ale#Escape(g:executable) . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('4') . ' %s'
37   AssertLinterCwd v:null
38
39 Execute(use_global should override local executable detection):
40   let g:ale_php_phpstan_use_global = 1
41
42   call mkdir('vendor/bin', 'p', 0750)
43   call writefile([''], 'vendor/bin/phpstan')
44   call ale#test#SetFilename('phpstan-test-files/foo/test.php')
45
46   AssertLinter 'phpstan',
47   \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('4') . ' %s'
48
49 Execute(Custom executables should be used for the executable and command):
50   let g:ale_php_phpstan_executable = 'phpstan_test'
51
52   AssertLinter 'phpstan_test',
53   \ ale#Escape('phpstan_test') . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('4') . ' %s'
54
55 Execute(project with level set to 3):
56   call ale#test#SetFilename('phpstan-test-files/foo/test.php')
57   let g:ale_php_phpstan_level = 3
58
59   AssertLinter 'phpstan',
60   \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('3') . ' %s'
61
62 Execute(Custom phpstan configuration file):
63   let g:ale_php_phpstan_configuration = 'phpstan_config'
64
65   AssertLinter 'phpstan',
66   \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -c ' . ale#Escape('phpstan_config') . ' -l ' . ale#Escape('4') . ' %s'
67
68 Execute(Choose the right format for error format param):
69   GivenCommandOutput ['0.10.3']
70
71   AssertLinter 'phpstan', [
72   \ ale#Escape('phpstan') . ' --version',
73   \ ale#Escape('phpstan') . ' analyze --no-progress --error-format json -l ' . ale#Escape('4') . ' %s'
74   \ ]
75
76 Execute(Configuration file exists in current directory):
77   call writefile(['parameters:', '  level: 7'], './phpstan.neon')
78   let g:ale_php_phpstan_level = ''
79   let g:ale_php_phpstan_configuration = ''
80
81   AssertLinter 'phpstan', [
82   \ ale#Escape('phpstan') . ' --version',
83   \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json %s'
84   \ ]
85   AssertLinterCwd g:dir
86
87 Execute(Configuration dist file exists in current directory):
88   call writefile(['parameters:', '  level: 7'], './phpstan.neon.dist')
89   let g:ale_php_phpstan_level = ''
90   let g:ale_php_phpstan_configuration = ''
91
92   AssertLinter 'phpstan', [
93   \ ale#Escape('phpstan') . ' --version',
94   \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json %s'
95   \ ]
96   AssertLinterCwd g:dir
97
98 Execute(Configuration file exists in current directory, but force phpstan level):
99   call writefile(['parameters:', '  level: 7'], './phpstan.neon')
100   let g:ale_php_phpstan_configuration = ''
101   let g:ale_php_phpstan_level = '7'
102
103   AssertLinter 'phpstan', [
104   \ ale#Escape('phpstan') . ' --version',
105   \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('7') . ' %s'
106   \ ]
107
108 Execute(Configuration file exists in current directory, but force phpstan configuration):
109   call writefile(['parameters:', '  level: 7'], './phpstan.neon')
110   let g:ale_php_phpstan_level = ''
111   let g:ale_php_phpstan_configuration = 'phpstan.custom.neon'
112
113   AssertLinter 'phpstan', [
114   \ ale#Escape('phpstan') . ' --version',
115   \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -c ' . ale#Escape('phpstan.custom.neon') . ' %s'
116   \ ]
117
118 Execute(Autoload parameter is added to the command):
119   let g:ale_php_phpstan_autoload = 'autoload.php'
120
121   AssertLinter 'phpstan',
122   \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -a ' . ale#Escape('autoload.php') . ' -l ' . ale#Escape('4') . ' %s'
123
124 Execute(Memory limit parameter is added to the command):
125   let g:ale_php_phpstan_memory_limit = '500M'
126
127   AssertLinter 'phpstan',
128   \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('4') . ' --memory-limit=' . ale#Escape('500M') . ' %s'
129
130 Execute(Directory is changed to that of the configuration file):
131   call writefile([], '../phpstan.neon')
132
133   AssertLinterCwd g:parent_dir
134   AssertLinter 'phpstan',
135   \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json %s'