summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEric Stern <github@ericstern.com>2017-06-21 13:35:40 -0700
committerw0rp <w0rp@users.noreply.github.com>2017-06-21 21:35:40 +0100
commitab534c2995dabfb8adcdc62d0ac66ed1b1110f4c (patch)
tree29418f9a0ad95d375ccaaf239c75f24850e28292 /test
parentd2806fad600e361e5b419e528c0e999bb4ac9b7f (diff)
downloadale-ab534c2995dabfb8adcdc62d0ac66ed1b1110f4c.zip
Support project's local phpcs installation (#666)
* Use locally-installed PHPCS if available * Add author * Add configuration options * Escape executable * Add tests
Diffstat (limited to 'test')
-rw-r--r--test/phpcs-test-files/project-with-phpcs/vendor/bin/phpcs0
-rw-r--r--test/test_phpcs_executable_detection.vader45
2 files changed, 45 insertions, 0 deletions
diff --git a/test/phpcs-test-files/project-with-phpcs/vendor/bin/phpcs b/test/phpcs-test-files/project-with-phpcs/vendor/bin/phpcs
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/phpcs-test-files/project-with-phpcs/vendor/bin/phpcs
diff --git a/test/test_phpcs_executable_detection.vader b/test/test_phpcs_executable_detection.vader
new file mode 100644
index 00000000..678606f8
--- /dev/null
+++ b/test/test_phpcs_executable_detection.vader
@@ -0,0 +1,45 @@
+Before:
+ let g:ale_php_phpcs_executable = 'phpcs_test'
+
+ silent! cd /testplugin/test
+ let g:dir = getcwd()
+
+ runtime ale_linters/php/phpcs.vim
+
+After:
+ let g:ale_php_phpcs_executable = 'phpcs'
+ let g:ale_php_phpcs_use_global = 0
+
+ silent execute 'cd ' . g:dir
+ unlet! g:dir
+
+ call ale#linter#Reset()
+
+Execute(project with phpcs should use local by default):
+ silent noautocmd new phpcs-test-files/project-with-phpcs/vendor/bin/phpcs
+
+ AssertEqual
+ \ g:dir . '/phpcs-test-files/project-with-phpcs/vendor/bin/phpcs',
+ \ ale_linters#php#phpcs#GetExecutable(bufnr(''))
+
+ :q
+
+Execute(use-global should override local detection):
+ let g:ale_php_phpcs_use_global = 1
+
+ silent noautocmd new phpcs-test-files/project-with-phpcs/vendor/bin/phpcs
+
+ AssertEqual
+ \ 'phpcs_test',
+ \ ale_linters#php#phpcs#GetExecutable(bufnr(''))
+
+ :q
+
+Execute(project without phpcs should use global):
+ silent noautocmd new phpcs-test-files/project-without-phpcs/vendor/bin/phpcs
+
+ AssertEqual
+ \ 'phpcs_test',
+ \ ale_linters#php#phpcs#GetExecutable(bufnr(''))
+
+ :q