spacevim/bundle/phpcomplete.vim/tests/CompleteUse_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

124 lines
5.2 KiB
VimL

fun! SetUp()
" normalize g:phpcomplete_min_num_of_chars_for_namespace_completion option
let g:phpcomplete_min_num_of_chars_for_namespace_completion = 2
" disable built-in classes
let g:php_builtin_classnames = {}
" disable built-in interfaces
let g:php_builtin_interfaces = {}
" disable built-in interfaces
let g:php_builtin_interfacenames = {}
" disable tags
exe ':set tags='
endf
fun! TestCase_completes_builtin_classes()
call SetUp()
let g:php_builtin_classnames = {
\ 'arrayaccess': '',
\ 'arrayobject': '',
\ }
let g:php_builtin_classes = {
\ 'arrayaccess':{
\ 'name': 'ArrayAccess',
\ },
\ 'arrayobject':{
\ 'name': 'ArrayObject',
\ },
\ }
" returns every builtin class when nothing typed in
let res = phpcomplete#CompleteUse('')
call VUAssertEquals([
\{'word': 'ArrayAccess', 'kind': 'c'},
\{'word': 'ArrayObject', 'kind': 'c'}],
\res)
" returns every builtin class when only a \ typed in
let res = phpcomplete#CompleteUse('\')
call VUAssertEquals([
\{'word': 'ArrayAccess', 'kind': 'c'},
\{'word': 'ArrayObject', 'kind': 'c'}],
\res)
" filters to the typed in string
let res = phpcomplete#CompleteUse('ArrayO')
call VUAssertEquals([
\{'word': 'ArrayObject', 'kind': 'c'}]
\, res)
" removes the leading \ when its in the base, php manual doesn't recommend
" to type out those since imports are always absolute
let res = phpcomplete#CompleteUse('\ArrayO')
call VUAssertEquals([
\{'word': 'ArrayObject', 'kind': 'c'}]
\, res)
endf
fun! TestCase_completes_namespaces_from_tags()
call SetUp()
exe ':set tags='.expand('%:p:h').'/'.'fixtures/CompleteUse/tags'
let res = phpcomplete#CompleteUse('Ass')
call VUAssertEquals([
\ {'word': 'Assetic', 'menu': 'fixtures/CompleteUse/foo.php', 'info': 'fixtures/CompleteUse/foo.php', 'kind': 'n'},
\ {'word': 'Assetic\Asset', 'menu': 'fixtures/CompleteUse/foo.php', 'info': 'fixtures/CompleteUse/foo.php', 'kind': 'n'},
\ {'word': 'Assetic\Asset\Iterator', 'menu': 'fixtures/CompleteUse/foo.oho', 'info': 'fixtures/CompleteUse/foo.oho', 'kind': 'n'},
\ {'word': 'Assetic\Cache', 'menu': 'fixtures/CompleteUse/foo.php', 'info': 'fixtures/CompleteUse/foo.php', 'kind': 'n'}],
\ res)
" removes the leading \ when its in the base, php manual doesn't recommend
" to type out those since imports are always absolute
let res = phpcomplete#CompleteUse('\Ass')
call VUAssertEquals([
\ {'word': 'Assetic', 'menu': 'fixtures/CompleteUse/foo.php', 'info': 'fixtures/CompleteUse/foo.php', 'kind': 'n'},
\ {'word': 'Assetic\Asset', 'menu': 'fixtures/CompleteUse/foo.php', 'info': 'fixtures/CompleteUse/foo.php', 'kind': 'n'},
\ {'word': 'Assetic\Asset\Iterator', 'menu': 'fixtures/CompleteUse/foo.oho', 'info': 'fixtures/CompleteUse/foo.oho', 'kind': 'n'},
\ {'word': 'Assetic\Cache', 'menu': 'fixtures/CompleteUse/foo.php', 'info': 'fixtures/CompleteUse/foo.php', 'kind': 'n'}],
\ res)
" Should return traits too (tags with kind "t")
let res = phpcomplete#CompleteUse('Some')
call VUAssertEquals([
\ {'word': 'SomeTrait', 'menu': 'fixtures/CompleteUse/foo.php', 'info': 'fixtures/CompleteUse/foo.php', 'kind': 't'}],
\ res)
endf
fun! TestCase_completes_namespaces_and_classes_from_tags_when_a_leading_namespace_is_already_typed_in()
call SetUp()
exe ':set tags='.expand('%:p:h').'/'.'fixtures/CompleteUse/tags'
let res = phpcomplete#CompleteUse('Assetic\Asset\Ba')
call VUAssertEquals([
\ {'word': 'Assetic\Asset\BaseAsset', 'menu': 'fixtures/CompleteUse/foo.php', 'info': 'fixtures/CompleteUse/foo.php', 'kind': 'c'}],
\ res)
" should complete tags matching the word after the last \ when no
" namespaces found in tags file
exe ':set tags='.expand('%:p:h').'/'.'fixtures/CompleteUse/old_style_tags'
let res = phpcomplete#CompleteUse('Assetic\Asset\Ba')
call VUAssertEquals([
\ {'word': 'Assetic\Asset\BaseAsset', 'menu': 'fixtures/CompleteUse/foo.php', 'info': 'fixtures/CompleteUse/foo.php', 'kind': 'c'}],
\ res)
endf
fun! TestCase_honors_the_min_num_of_chars_for_namespace_completion_setting_for_namespaces()
call SetUp()
exe ':set tags='.expand('%:p:h').'/'.'fixtures/CompleteUse/tags'
let g:phpcomplete_min_num_of_chars_for_namespace_completion = 99
let res = phpcomplete#CompleteUse('Assetic\')
call VUAssertEquals([], res)
endf
fun! TestCase_honors_the_min_num_of_chars_for_namespace_completion_setting_for_classnames()
call SetUp()
exe ':set tags='.expand('%:p:h').'/'.'fixtures/CompleteUse/tags'
let g:phpcomplete_min_num_of_chars_for_namespace_completion = 99
let res = phpcomplete#CompleteUse('Assetic\Asset\Ba')
call VUAssertEquals([], res)
endf
" vim: foldmethod=marker:expandtab:ts=4:sts=4