diff options
author | w0rp <devw0rp@gmail.com> | 2017-08-02 22:34:09 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-08-02 22:34:09 +0100 |
commit | 6e07cf5b12fb633473d374f3dabc37ff16a9e979 (patch) | |
tree | 5f537c4c93c9c0ca1ae1f1d27de0dd7849d66b67 | |
parent | 1356cf8e01c307ea9ad54677059dbf3aed52426d (diff) | |
download | ale-6e07cf5b12fb633473d374f3dabc37ff16a9e979.zip |
Cover the PHP language server functions with Vader tests
3 files changed, 53 insertions, 1 deletions
diff --git a/ale_linters/php/langserver.vim b/ale_linters/php/langserver.vim index d82cd63b..d772e90d 100644 --- a/ale_linters/php/langserver.vim +++ b/ale_linters/php/langserver.vim @@ -12,7 +12,7 @@ function! ale_linters#php#langserver#GetExecutable(buffer) abort endfunction function! ale_linters#php#langserver#GetCommand(buffer) abort - return 'php ' . ale_linters#php#langserver#GetExecutable(a:buffer) + return 'php ' . ale#Escape(ale_linters#php#langserver#GetExecutable(a:buffer)) endfunction function! ale_linters#php#langserver#GetLanguage(buffer) abort diff --git a/test/command_callback/php-langserver-project/vendor/bin/php-language-server.php b/test/command_callback/php-langserver-project/vendor/bin/php-language-server.php new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/php-langserver-project/vendor/bin/php-language-server.php diff --git a/test/command_callback/test_php_langserver_callbacks.vader b/test/command_callback/test_php_langserver_callbacks.vader new file mode 100644 index 00000000..d5030450 --- /dev/null +++ b/test/command_callback/test_php_langserver_callbacks.vader @@ -0,0 +1,52 @@ +Before: + Save ale_php_langserver_executable + Save ale_php_langserver_config_path + Save ale_php_langserver_use_global + + unlet! ale_php_langserver_executable + unlet! ale_php_langserver_config_path + unlet! ale_php_langserver_use_global + + runtime ale_linters/php/langserver.vim + + call ale#test#SetDirectory('/testplugin/test/command_callback') + +After: + Restore + + if isdirectory(g:dir . '/.git') + call delete(g:dir . '/.git', 'd') + endif + + call ale#test#RestoreDirectory() + call ale#linter#Reset() + +Execute(The default executable path should be correct): + AssertEqual + \ 'php-language-server.php', + \ ale_linters#php#langserver#GetExecutable(bufnr('')) + AssertEqual + \ 'php ' . ale#Escape('php-language-server.php'), + \ ale_linters#php#langserver#GetCommand(bufnr('')) + +Execute(Vendor executables should be detected): + call ale#test#SetFilename('php-langserver-project/test.php') + + AssertEqual + \ g:dir . '/php-langserver-project/vendor/bin/php-language-server.php', + \ ale_linters#php#langserver#GetExecutable(bufnr('')) + AssertEqual + \ 'php ' . ale#Escape( + \ g:dir + \ . '/php-langserver-project/vendor/bin/php-language-server.php' + \ ), + \ ale_linters#php#langserver#GetCommand(bufnr('')) + +Execute(The language string should be correct): + AssertEqual 'php', ale_linters#php#langserver#GetLanguage(bufnr('')) + +Execute(The project path should be correct for .git directories): + call ale#test#SetFilename('php-langserver-project/test.php') + call mkdir(g:dir . '/.git') + + AssertEqual g:dir, ale_linters#php#langserver#GetProjectRoot(bufnr('')) |