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

150 lines
9.6 KiB
VimL

fun! SetUp()
let g:fixture_class_content = readfile(expand('%:p:h').'/'.'fixtures/CompleteUserClass/user_extended.class.php')[2:]
let g:commented_fixture_class_content = readfile(expand('%:p:h').'/'.'fixtures/CompleteUserClass/commented_foo.class.php')[2:]
let g:phpcomplete_relax_static_constraint = 0
let g:phpcomplete_parse_docblock_comments = 0
endf
fun! TestCase_returns_everyting_instance_related_when_scope_is_in_class()
call SetUp()
let ret = phpcomplete#CompleteUserClass('$u->', '', g:fixture_class_content, 'private')
call VUAssertEquals([
\{'word': 'A_CONST', 'info': 'A_CONST', 'menu': '', 'kind': 'd'},
\{'word': 'final_private_method(', 'info': 'final_private_method($foo = null)', 'menu': '$foo = null)', 'kind': 'f'},
\{'word': 'naked_public_method(', 'info': 'naked_public_method()', 'menu': ')', 'kind': 'f'},
\{'word': 'private_method(', 'info': 'private_method($foo)', 'menu': '$foo)', 'kind': 'f'},
\{'word': 'private_property', 'info': '', 'menu': '', 'kind': 'v'},
\{'word': 'protected_method(', 'info': 'protected_method($foo)', 'menu': '$foo)', 'kind': 'f'},
\{'word': 'protected_property', 'info': '', 'menu': '', 'kind': 'v'},
\{'word': 'public_final_method(', 'info': 'public_final_method($foo, $anotherfoo = '''')', 'menu': '$foo, $anotherfoo = '''')', 'kind': 'f'},
\{'word': 'public_method(', 'info': 'public_method($foo)', 'menu': '$foo)', 'kind': 'f'},
\{'word': 'public_method_with_amp(', 'info': 'public_method_with_amp($foo)', 'menu': '$foo)', 'kind': 'f'},
\{'word': 'public_property1', 'info': '', 'menu': '', 'kind': 'v'},
\{'word': 'public_property2', 'info': '', 'menu': '', 'kind': 'v'}],
\ ret)
endfun
fun! TestCase_returns_everyting_instance_related_when_scope_is_out_of_class()
call SetUp()
let ret = phpcomplete#CompleteUserClass('$u->', '', g:fixture_class_content, 'public')
call VUAssertEquals([
\{'word': 'A_CONST', 'info': 'A_CONST', 'menu': '', 'kind': 'd'},
\{'word': 'naked_public_method(', 'info': 'naked_public_method()', 'menu': ')', 'kind': 'f'},
\{'word': 'public_final_method(', 'info': 'public_final_method($foo, $anotherfoo = '''')', 'menu': '$foo, $anotherfoo = '''')', 'kind': 'f'},
\{'word': 'public_method(', 'info': 'public_method($foo)', 'menu': '$foo)', 'kind': 'f'},
\{'word': 'public_method_with_amp(', 'info': 'public_method_with_amp($foo)', 'menu': '$foo)', 'kind': 'f'},
\{'word': 'public_property1', 'info': '', 'menu': '', 'kind': 'v'},
\{'word': 'public_property2', 'info': '', 'menu': '', 'kind': 'v'}],
\ ret)
endfun
fun! TestCase_returns_everyting_static_when_scope_is_in_class()
call SetUp()
let ret = phpcomplete#CompleteUserClass('UserClass::', '', g:fixture_class_content, 'private')
call VUAssertEquals([
\ {'word': '$private_static_property', 'info': '', 'menu': '', 'kind': 'v'},
\ {'word': '$protected_static_property', 'info': '', 'menu': '', 'kind': 'v'},
\ {'word': '$public_static_property', 'info': '', 'menu': '', 'kind': 'v'},
\ {'word': 'A_CONST', 'info': 'A_CONST', 'menu': '', 'kind': 'd'},
\ {'word': 'final_static_public_method(', 'info': 'final_static_public_method()', 'menu': ')', 'kind': 'f'},
\ {'word': 'private_static_method(', 'info': 'private_static_method($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'protected_static_method(', 'info': 'protected_static_method($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'public_final_static_method(', 'info': 'public_final_static_method( $foo, $anotherfoo = array() )', 'menu': ' $foo, $anotherfoo = array() )', 'kind': 'f'},
\ {'word': 'public_static_method(', 'info': 'public_static_method($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'static_final_protected_method(', 'info': 'static_final_protected_method()', 'menu': ')', 'kind': 'f'},
\ {'word': 'static_public_method(', 'info': 'static_public_method($foo)', 'menu': '$foo)', 'kind': 'f'}],
\ ret)
endfun
fun! TestCase_filters_for_instane_level_prefix()
call SetUp()
let ret = phpcomplete#CompleteUserClass('$u->', 'public_', g:fixture_class_content, 'private')
call VUAssertEquals([
\ {'word': 'public_final_method(', 'info': 'public_final_method($foo, $anotherfoo = '''')', 'menu': '$foo, $anotherfoo = '''')', 'kind': 'f'},
\ {'word': 'public_method(', 'info': 'public_method($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'public_method_with_amp(', 'info': 'public_method_with_amp($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'public_property1', 'info': '', 'menu': '', 'kind': 'v'},
\ {'word': 'public_property2', 'info': '', 'menu': '', 'kind': 'v'}],
\ ret)
endfun
fun! TestCase_filters_for_static_property_names()
call SetUp()
let ret = phpcomplete#CompleteUserClass('UserClass::', '$private_', g:fixture_class_content, 'private')
call VUAssertEquals([
\ {'word': '$private_static_property', 'info': '', 'menu': '', 'kind': 'v'}],
\ ret)
endfun
fun! TestCase_returns_everyting_static_when_scope_is_out_of_class()
call SetUp()
let ret = phpcomplete#CompleteUserClass('UserClass::', '', g:fixture_class_content, 'public')
call VUAssertEquals([
\ {'word': '$public_static_property', 'info': '', 'menu': '', 'kind': 'v'},
\ {'word': 'A_CONST', 'info': 'A_CONST', 'menu': '', 'kind': 'd'},
\ {'word': 'final_static_public_method(', 'info': 'final_static_public_method()', 'menu': ')', 'kind': 'f'},
\ {'word': 'public_final_static_method(', 'info': 'public_final_static_method( $foo, $anotherfoo = array() )', 'menu': ' $foo, $anotherfoo = array() )', 'kind': 'f'},
\ {'word': 'public_static_method(', 'info': 'public_static_method($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'static_public_method(', 'info': 'static_public_method($foo)', 'menu': '$foo)', 'kind': 'f'}],
\ ret)
endfun
fun! TestCase_returns_non_explicit_static_methods_when_phpcomplete_relax_static_constraint_enabled()
call SetUp()
let g:phpcomplete_relax_static_constraint = 1
let ret = phpcomplete#CompleteUserClass('UserClass::', '', g:fixture_class_content, 'public')
call VUAssertEquals([
\ {'word': '$public_static_property', 'info': '', 'menu': '', 'kind': 'v'},
\ {'word': 'A_CONST', 'info': 'A_CONST', 'menu': '', 'kind': 'd'},
\ {'word': 'final_static_public_method(', 'info': 'final_static_public_method()', 'menu': ')', 'kind': 'f'},
\ {'word': 'naked_public_method(', 'info': 'naked_public_method()', 'menu': ')', 'kind': 'f'},
\ {'word': 'public_final_method(', 'info': 'public_final_method($foo, $anotherfoo = '''')', 'menu': '$foo, $anotherfoo = '''')', 'kind': 'f'},
\ {'word': 'public_final_static_method(', 'info': 'public_final_static_method( $foo, $anotherfoo = array() )', 'menu': ' $foo, $anotherfoo = array() )', 'kind': 'f'},
\ {'word': 'public_method(', 'info': 'public_method($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'public_method_with_amp(', 'info': 'public_method_with_amp($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'public_static_method(', 'info': 'public_static_method($foo)', 'menu': '$foo)', 'kind': 'f'},
\ {'word': 'static_public_method(', 'info': 'static_public_method($foo)', 'menu': '$foo)', 'kind': 'f'}],
\ ret)
endfun
fun! TestCase_returns_types_for_properties_and_return_types_from_docblock_comments()
call SetUp()
let g:phpcomplete_parse_docblock_comments = 1
let ret = phpcomplete#CompleteUserClass('$u->', 'commented', g:commented_fixture_class_content, 'public')
call VUAssertEquals([
\ {'word': 'commented_from_docblock', 'info': "Description:\n Foo\n \n @property DateTime $commented_from_docblock\n", 'menu': '', 'kind': 'v'},
\ {'word': 'commented_method(', 'info': "commented_method($foo, $bar, $baz = '')\n\nReturn:\n\tstring: description of return\n", 'menu': "$foo, $bar, $baz = '') | string", 'kind': 'f'},
\ {'word': 'commented_property', 'info': "Type:\n\tFoo\n", 'menu': 'Foo', 'kind': 'v'}],
\ ret)
endfun
fun! TestCase_returns_static_properties_with_only_a_dollarsign_base()
call SetUp()
let ret = phpcomplete#CompleteUserClass('self::', '$', g:fixture_class_content, 'private')
call VUAssertEquals([
\ {'word': '$private_static_property', 'info': '', 'menu': '', 'kind': 'v'},
\ {'word': '$protected_static_property', 'info': '', 'menu': '', 'kind': 'v'},
\ {'word': '$public_static_property', 'info': '', 'menu': '', 'kind': 'v'}],
\ ret)
endfun
fun! TestCase_gets_functions_from_implemented_interfaces()
call SetUp()
let fixture_content = readfile(expand('%:p:h').'/'.'fixtures/CompleteUserClass/user_interface_implemented.php')[4:7]
let ret = phpcomplete#CompleteUserClass('$f->', '', fixture_content, 'public')
call VUAssertEquals([
\ {'word': 'bar(', 'info': 'bar($baz = 42)', 'menu': '$baz = 42)', 'kind': 'f'}],
\ ret)
endf
" vim: foldmethod=marker:expandtab:ts=4:sts=4