spacevim/bundle/phpcomplete.vim/tests/CompleteUnknownClass_test.vim
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

131 lines
5.4 KiB
VimL

fun! SetUp()
let g:phpcomplete_complete_for_unknown_classes = 1
" disable built-in functions
let g:php_builtin_object_functions = {}
" disable tags
exe ':set tags='
endf
fun! TestCase_returns_class_properties_from_current_file()
call SetUp()
" load fixture with variables in it
let path = expand('%:p:h')."/".'fixtures/CompleteUnknownClass/foo_properties.class.php'
below 1new
exe ":silent! edit ".path
let res = phpcomplete#CompleteUnknownClass("prop", "$a->")
call VUAssertEquals([
\ {'word': 'property1', 'info': ' ', 'kind': 'v'},
\ {'word': 'property2', 'info': ' ', 'kind': 'v'}],
\ res)
silent! bw! %
endf
fun! TestCase_returns_functions_from_current_file()
call SetUp()
" load fixture with methods and functions in it
let path = expand('%:p:h')."/".'fixtures/CompleteUnknownClass/foo_methods.class.php'
below 1new
exe ":silent! edit ".path
let res = phpcomplete#CompleteUnknownClass("met", "$a->")
" TODO: At this moment, the code finds private and protected methods, it should not do that
" TODO: At this moment, the code doesn't take filter for staticness of results
call VUAssertEquals([
\ {'word': 'method1(', 'info': 'method1($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'method2(', 'info': 'method2($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'method3(', 'info': 'method3($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'method4(', 'info': 'method4($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'method5(', 'info': 'method5($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'method6(', 'info': 'method6($foo)', 'menu': '$foo)', 'kind': 'f'}],
\ res)
silent! bw! %
endf
fun! TestCase_completes_function_signature_from_tags_if_field_available()
call SetUp()
" disable tags
exe 'set tags='.expand('%:p:h')."/".'fixtures/CompleteUnknownClass/patched_tags'
" load an empty fixture so no local functions / variables show up
let path = expand('%:p:h')."/".'fixtures/CompleteUnknownClass/empty.php'
below 1new
exe ":silent! edit ".path
let res = phpcomplete#CompleteUnknownClass("method_with_", "$a->")
" TODO: At this moment, the code finds functions that are not in a class
" (so they are no methods)
" TODO: At this moment, the code doesn't take filter for staticness
call VUAssertEquals([
\ {'word': 'method_with_arguments(', 'info': "method_with_arguments($bar = 42, $foo = '') - fixtures/CompleteUnknownClass/irrelevant.class.php", 'menu': "$bar = 42, $foo = '') - fixtures/CompleteUnknownClass/irrelevant.class.php", 'kind': 'f'}],
\ res)
silent! bw! %
endf
fun! TestCase_returns_functions_from_tags()
call SetUp()
" disable tags
exe 'set tags='.expand('%:p:h')."/".'fixtures/CompleteUnknownClass/tags'
" load an empty fixture so no local functions / variables show up
let path = expand('%:p:h')."/".'fixtures/CompleteUnknownClass/empty.php'
below 1new
exe ":silent! edit ".path
let res = phpcomplete#CompleteUnknownClass("fun", "$a->")
" TODO: At this moment, the code finds functions that are not in a class
" (so they are no methods)
" TODO: At this moment, the code doesn't take filter for staticness
call VUAssertEquals([
\ {'word': 'function1(', 'info': 'function1($baz = ''foo'') - fixtures/CompleteUnknownClass/irrelevant.php', 'menu': '$baz = ''foo'') - fixtures/CompleteUnknownClass/irrelevant.php', 'kind': 'f'},
\ {'word': 'function2(', 'info': 'function2($baz = ''foo'') - fixtures/CompleteUnknownClass/irrelevant.php', 'menu': '$baz = ''foo'') - fixtures/CompleteUnknownClass/irrelevant.php', 'kind': 'f'},
\ {'word': 'function3(', 'info': 'function3() - fixtures/CompleteUnknownClass/irrelevant.php', 'menu': ') - fixtures/CompleteUnknownClass/irrelevant.php', 'kind': 'f'},
\ {'word': 'function4(', 'info': 'function4() - fixtures/CompleteUnknownClass/irrelevant.php', 'menu': ') - fixtures/CompleteUnknownClass/irrelevant.php', 'kind': 'f'}],
\ res)
silent! bw! %
endf
fun! TestCase_returns_built_in_object_functions()
call SetUp()
" load an empty fixture so no local functions / variables show up
let path = expand('%:p:h')."/".'fixtures/CompleteUnknownClass/empty.php'
below 1new
exe ":silent! edit ".path
" disable built-in functions
let g:php_builtin_object_functions = {
\ 'DateTime::add(': 'DateInterval $interval | DateTime',
\ 'DateTime::setDate(': 'int $year, int $month, int $day | DateTime',
\ }
let res = phpcomplete#CompleteUnknownClass("set", "$d->")
" TODO: At this moment, the code doesn't take filter for staticness
call VUAssertEquals([{
\ 'word': 'setDate(',
\ 'info': 'DateTime::setDate(int $year, int $month, int $day | DateTime',
\ 'menu': 'int $year, int $month, int $day | DateTime',
\ 'kind': 'f'}],
\ res)
silent! bw! %
endf
fun! TestCase_returns_empty_list_when_unknown_class_completion_disabled()
call SetUp()
let g:phpcomplete_complete_for_unknown_classes = 0
let res = phpcomplete#CompleteUnknownClass("setDat", "$d->")
call VUAssertEquals([], res)
endf
" vim: foldmethod=marker:expandtab:ts=4:sts=4