summaryrefslogtreecommitdiff
path: root/test/fixers
diff options
context:
space:
mode:
authortmn-o3 <tomorrow2009@live.jp>2017-08-20 05:47:21 +0000
committertmn-o3 <tomorrow2009@live.jp>2017-08-20 05:47:21 +0000
commit5a9a365aed333560c9490dbddc8f382f47c08564 (patch)
treedad86e2b78fcf35e10e756ee8262dc2d640e007d /test/fixers
parente5d0a17694897dc8e234f534cfa33fc3483d8e12 (diff)
downloadale-5a9a365aed333560c9490dbddc8f382f47c08564.zip
add phpcbf fixer
Diffstat (limited to 'test/fixers')
-rw-r--r--test/fixers/test_phpcbf_fixer_callback.vader56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/fixers/test_phpcbf_fixer_callback.vader b/test/fixers/test_phpcbf_fixer_callback.vader
new file mode 100644
index 00000000..c2fe3a66
--- /dev/null
+++ b/test/fixers/test_phpcbf_fixer_callback.vader
@@ -0,0 +1,56 @@
+Before:
+ Save g:ale_php_phpcbf_executable
+ Save g:ale_php_phpcbf_standard
+ Save g:ale_php_phpcbf_use_global
+
+ let g:ale_php_phpcbf_executable = 'phpcbf_test'
+ let g:ale_php_phpcbf_standard = ''
+ let g:ale_php_phpcbf_use_global = 0
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+ silent cd ..
+ silent cd command_callback
+ let g:dir = getcwd()
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(project with phpcbf should use local by default):
+ call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php')
+
+ AssertEqual
+ \ g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf',
+ \ ale#fixers#phpcbf#GetExecutable(bufnr(''))
+
+Execute(use-global should override local detection):
+ let g:ale_php_phpcbf_use_global = 1
+ call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php')
+
+ AssertEqual
+ \ 'phpcbf_test',
+ \ ale#fixers#phpcbf#GetExecutable(bufnr(''))
+
+Execute(project without phpcbf should use global):
+ call ale#test#SetFilename('php_paths/project-without-phpcbf/foo/test.php')
+
+ AssertEqual
+ \ 'phpcbf_test',
+ \ ale#fixers#phpcbf#GetExecutable(bufnr(''))
+
+Execute(The phpcbf callback should return the correct default values):
+ call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php')
+
+ AssertEqual
+ \ {'command': ale#Escape(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf') . ' --stdin-path=%s ' },
+ \ ale#fixers#phpcbf#Fix(bufnr(''))
+
+Execute(The phpcbf callback should include the phpcbf_standard option):
+ let g:ale_php_phpcbf_standard = 'phpcbf_ruleset.xml'
+ call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php')
+
+ AssertEqual
+ \ {'command': ale#Escape(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf') . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml'},
+ \ ale#fixers#phpcbf#Fix(bufnr(''))
+